Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node/cleanup: Add some documentation and an ignore-list to mainnet_chains_test.go #4038

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions node/pkg/governor/mainnet_tokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package governor

import (
"fmt"
"strings"
"testing"

"github.com/stretchr/testify/assert"
"github.com/wormhole-foundation/wormhole/sdk"
"github.com/wormhole-foundation/wormhole/sdk/vaa"
)

Expand Down Expand Up @@ -33,11 +33,33 @@ func TestTokenListAddressSize(t *testing.T) {
}
}

func TestTokenListChainTokensPresent(t *testing.T) {
// Flag a situation where a Governed chain does not have any governed assets. Often times when adding a mainnet chain,
// a list of tokens will be added so that they can be governed. (These tokens are sourced by CoinGecko or manually
// populated.) While this is not a hard requirement, it may represent that a developer has forgotten to take the step
// of configuring tokens when deploying the chain. This test helps to remind them.
func TestGovernedChainHasGovernedAssets(t *testing.T) {

// Add a chain ID to this set if it genuinely has no native assets that should be governed.
ignoredChains := map[vaa.ChainID]bool{
// Wormchain is an abstraction over IBC-connected chains so no assets are "native" to it
vaa.ChainIDWormchain: true,
}
if len(ignoredChains) > 0 {
ignoredOutput := []string{}
for id := range ignoredChains {
ignoredOutput = append(ignoredOutput, id.String())
}

t.Logf("This test ignored the following chains: %s\n", strings.Join(ignoredOutput, "\n"))
}

tokenConfigEntries := tokenList()

/* Assume that all chains within a token bridge will have governed tokens */
for e := range sdk.KnownTokenbridgeEmitters {
for _, chainConfigEntry := range chainList() {
e := chainConfigEntry.emitterChainID
if _, ignored := ignoredChains[e]; ignored {
return
}
t.Run(e.String(), func(t *testing.T) {
found := false
for _, tokenConfigEntry := range tokenConfigEntries {
Expand All @@ -46,10 +68,7 @@ func TestTokenListChainTokensPresent(t *testing.T) {
break
}
}

if e != vaa.ChainIDXpla && e != vaa.ChainIDAptos && e != vaa.ChainIDArbitrum && e != vaa.ChainIDWormchain {
assert.Equal(t, found, true)
}
assert.True(t, found, "Chain is governed but has no governed native assets configured")
})
}
}
Expand Down
Loading