Skip to content

Commit

Permalink
fix test & linter issue with loop variable. (#10426)
Browse files Browse the repository at this point in the history
* fix test & linter issue with loop variable. Change make command be cross platform and remove colons from file names

* typo fixes
  • Loading branch information
krehermann authored Aug 31, 2023
1 parent 74596ea commit 37d6bda
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ config-docs: ## Generate core node configuration documentation
.PHONY: golangci-lint
golangci-lint: ## Run golangci-lint for all issues.
[ -d "./golangci-lint" ] || mkdir ./golangci-lint && \
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.53.2 golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 > ./golangci-lint/$(shell date --iso=seconds).txt
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.53.2 golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 > ./golangci-lint/$(shell date +%Y-%m-%d_%s).txt


GORELEASER_CONFIG ?= .goreleaser.yaml
Expand Down
34 changes: 30 additions & 4 deletions core/services/chainlink/relayer_chain_interoperators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ func TestCoreRelayerChainInteroperators(t *testing.T) {
testctx := testutils.Context(t)

tests := []struct {
name string
initFuncs []chainlink.CoreRelayerChainInitFunc
name string
initFuncs []chainlink.CoreRelayerChainInitFunc
expectedRelayerNetworks map[relay.Network]struct{}

expectedEVMChainCnt int
expectedEVMNodeCnt int
Expand Down Expand Up @@ -220,6 +221,7 @@ func TestCoreRelayerChainInteroperators(t *testing.T) {
{Network: relay.EVM, ChainID: relay.ChainID(evmChainID1.String())},
{Network: relay.EVM, ChainID: relay.ChainID(evmChainID2.String())},
},
expectedRelayerNetworks: map[relay.Network]struct{}{relay.EVM: {}},
},

{name: "2 solana chain with 2 node",
Expand All @@ -235,6 +237,7 @@ func TestCoreRelayerChainInteroperators(t *testing.T) {
{Network: relay.Solana, ChainID: relay.ChainID(solanaChainID1)},
{Network: relay.Solana, ChainID: relay.ChainID(solanaChainID2)},
},
expectedRelayerNetworks: map[relay.Network]struct{}{relay.Solana: {}},
},

{name: "2 starknet chain with 4 nodes",
Expand All @@ -250,6 +253,7 @@ func TestCoreRelayerChainInteroperators(t *testing.T) {
{Network: relay.StarkNet, ChainID: relay.ChainID(starknetChainID1)},
{Network: relay.StarkNet, ChainID: relay.ChainID(starknetChainID2)},
},
expectedRelayerNetworks: map[relay.Network]struct{}{relay.StarkNet: {}},
},

{
Expand All @@ -266,6 +270,7 @@ func TestCoreRelayerChainInteroperators(t *testing.T) {
{Network: relay.Cosmos, ChainID: relay.ChainID(cosmosChainID1)},
{Network: relay.Cosmos, ChainID: relay.ChainID(cosmosChainID2)},
},
expectedRelayerNetworks: map[relay.Network]struct{}{relay.Cosmos: {}},
},

{name: "all chains",
Expand Down Expand Up @@ -317,9 +322,12 @@ func TestCoreRelayerChainInteroperators(t *testing.T) {
{Network: relay.Cosmos, ChainID: relay.ChainID(cosmosChainID1)},
{Network: relay.Cosmos, ChainID: relay.ChainID(cosmosChainID2)},
},

expectedRelayerNetworks: map[relay.Network]struct{}{relay.EVM: {}, relay.Cosmos: {}, relay.Solana: {}, relay.StarkNet: {}},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
cr, err := chainlink.NewCoreRelayerChainInteroperators(tt.initFuncs...)
Expand All @@ -342,6 +350,7 @@ func TestCoreRelayerChainInteroperators(t *testing.T) {
assert.Len(t, allNodeStats, expectedNodeCnt)
assert.Equal(t, cnt, len(allNodeStats))

gotRelayerNetworks := make(map[relay.Network]struct{})
for relayNetwork := range relay.SupportedRelays {
var expectedChainCnt, expectedNodeCnt int
switch relayNetwork {
Expand All @@ -359,11 +368,26 @@ func TestCoreRelayerChainInteroperators(t *testing.T) {

interops := cr.List(chainlink.FilterRelayersByType(relayNetwork))
assert.Len(t, cr.List(chainlink.FilterRelayersByType(relayNetwork)).Slice(), expectedChainCnt)
if len(interops.Slice()) > 0 {
gotRelayerNetworks[relayNetwork] = struct{}{}
}

// check legacy chains for those that haven't migrated fully to the loop relayer interface
if relayNetwork == relay.EVM {
assert.Len(t, cr.LegacyEVMChains().Slice(), expectedChainCnt)
_, wantEVM := tt.expectedRelayerNetworks[relay.EVM]
if wantEVM {
assert.Len(t, cr.LegacyEVMChains().Slice(), expectedChainCnt)
} else {
assert.Nil(t, cr.LegacyEVMChains())
}
}
if relayNetwork == relay.Cosmos {
assert.Len(t, cr.LegacyCosmosChains().Slice(), expectedChainCnt)
_, wantCosmos := tt.expectedRelayerNetworks[relay.Cosmos]
if wantCosmos {
assert.Len(t, cr.LegacyCosmosChains().Slice(), expectedChainCnt)
} else {
assert.Nil(t, cr.LegacyCosmosChains())
}
}

nodesStats, cnt, err := interops.NodeStatuses(testctx, 0, 0)
Expand All @@ -372,6 +396,7 @@ func TestCoreRelayerChainInteroperators(t *testing.T) {
assert.Equal(t, cnt, len(nodesStats))

}
assert.EqualValues(t, gotRelayerNetworks, tt.expectedRelayerNetworks)

allRelayerIds := [][]relay.ID{
tt.expectedEVMRelayerIds,
Expand Down Expand Up @@ -410,6 +435,7 @@ func TestCoreRelayerChainInteroperators(t *testing.T) {
assert.ErrorIs(t, err, chainlink.ErrNoSuchRelayer)

})

}

t.Run("bad init func", func(t *testing.T) {
Expand Down

0 comments on commit 37d6bda

Please sign in to comment.