Skip to content

Commit

Permalink
Fix missing tron handler and tests (#15932)
Browse files Browse the repository at this point in the history
* fix missing tron handlers

* add changeset

* fix test error and linting

* fix test
  • Loading branch information
calvwang9 authored Jan 15, 2025
1 parent 547d2ed commit 186fda8
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/sharp-llamas-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#bugfix Fix missing Tron handler
3 changes: 3 additions & 0 deletions core/cmd/shell_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@ func (s *Shell) runNode(c *cli.Context) error {
if s.Config.AptosEnabled() {
enabledChains = append(enabledChains, chaintype.Aptos)
}
if s.Config.TronEnabled() {
enabledChains = append(enabledChains, chaintype.Tron)
}
err2 := app.GetKeyStore().OCR2().EnsureKeys(rootCtx, enabledChains...)
if err2 != nil {
return errors.Wrap(err2, "failed to ensure ocr key")
Expand Down
16 changes: 16 additions & 0 deletions core/services/feeds/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,12 @@ func Test_Service_CreateChainConfig(t *testing.T) {
expectedID: int64(1),
expectedChainType: proto.ChainType_CHAIN_TYPE_APTOS,
},
{
name: "Tron Chain Type",
chainType: feeds.ChainTypeTron,
expectedID: int64(1),
expectedChainType: proto.ChainType_CHAIN_TYPE_TRON,
},
}

for _, tt := range tests {
Expand Down Expand Up @@ -755,6 +761,11 @@ func Test_Service_UpdateChainConfig(t *testing.T) {
chainType: feeds.ChainTypeAptos,
expectedChainType: proto.ChainType_CHAIN_TYPE_APTOS,
},
{
name: "Tron Chain Type",
chainType: feeds.ChainTypeTron,
expectedChainType: proto.ChainType_CHAIN_TYPE_TRON,
},
}

for _, tt := range tests {
Expand Down Expand Up @@ -1722,6 +1733,11 @@ func Test_Service_SyncNodeInfo(t *testing.T) {
chainType: feeds.ChainTypeAptos,
protoType: proto.ChainType_CHAIN_TYPE_APTOS,
},
{
name: "Tron Chain Type",
chainType: feeds.ChainTypeTron,
protoType: proto.ChainType_CHAIN_TYPE_TRON,
},
}

for _, tt := range tests {
Expand Down
20 changes: 16 additions & 4 deletions core/services/keystore/ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,21 @@ func Test_OCR2KeyStore_E2E(t *testing.T) {
assert.NoError(t, err)
require.Equal(t, 3, len(keys))

straknetKeys, err := ks.GetAllOfType(chaintype.StarkNet)
assert.NoError(t, err)
require.Equal(t, 1, len(straknetKeys))
require.Equal(t, straknetKeys[0].ChainType(), chaintype.StarkNet)
starknetKeys, err := ks.GetAllOfType(chaintype.StarkNet)
require.NoError(t, err)
require.Len(t, starknetKeys, 1)
require.Equal(t, chaintype.StarkNet, starknetKeys[0].ChainType())

err = ks.EnsureKeys(ctx, chaintype.Tron)
require.NoError(t, err)

keys, err = ks.GetAll()
require.NoError(t, err)
require.Len(t, keys, 4)

tronKeys, err := ks.GetAllOfType(chaintype.Tron)
require.NoError(t, err)
require.Len(t, tronKeys, 1)
require.Equal(t, chaintype.Tron, tronKeys[0].ChainType())
})
}
1 change: 1 addition & 0 deletions core/web/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ var routesRolesMap = [...]routeRules{
{"POST", "/v2/keys/cosmos/import", false, false, false},
{"POST", "/v2/keys/starknet/import", false, false, false},
{"POST", "/v2/keys/aptos/import", false, false, false},
{"POST", "/v2/keys/tron/import", false, false, false},
{"POST", "/v2/keys/solana/export/MOCK", false, false, false},
{"POST", "/v2/keys/cosmos/export/MOCK", false, false, false},
{"POST", "/v2/keys/starknet/export/MOCK", false, false, false},
Expand Down

0 comments on commit 186fda8

Please sign in to comment.