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
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion node/pkg/governor/governor.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (gov *ChainGovernor) initConfig() error {
gov.dayLengthInMinutes = 24 * 60
configTokens := tokenList()
flowCancelTokens := FlowCancelTokenList()
configChains := chainList()
configChains := ChainList()

if gov.env == common.UnsafeDevNet {
configTokens, flowCancelTokens, configChains = gov.initDevnetConfig()
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/governor/mainnet_chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/wormhole-foundation/wormhole/sdk/vaa"
)

func chainList() []chainConfigEntry {
func ChainList() []chainConfigEntry {
evan-gray marked this conversation as resolved.
Show resolved Hide resolved
return []chainConfigEntry{
{emitterChainID: vaa.ChainIDSolana, dailyLimit: 25_000_000, bigTransactionSize: 2_500_000},
{emitterChainID: vaa.ChainIDEthereum, dailyLimit: 50_000_000, bigTransactionSize: 5_000_000},
Expand Down
8 changes: 4 additions & 4 deletions node/pkg/governor/mainnet_chains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestChainListSize(t *testing.T) {
chainConfigEntries := chainList()
chainConfigEntries := ChainList()

/* Assuming that governed chains will not go down over time,
lets set a floor of expected chains to guard against parsing
Expand All @@ -18,7 +18,7 @@ func TestChainListSize(t *testing.T) {
}

func TestChainDailyLimitRange(t *testing.T) {
chainConfigEntries := chainList()
chainConfigEntries := ChainList()

/* This IS a hard limit, if daily limit is set to zero it would
basically mean no value movement is allowed for that chain*/
Expand All @@ -43,7 +43,7 @@ func TestChainDailyLimitRange(t *testing.T) {
}

func TestChainListChainPresent(t *testing.T) {
chainConfigEntries := chainList()
chainConfigEntries := ChainList()

entries := make([]vaa.ChainID, 0, len(chainConfigEntries))
for _, e := range chainConfigEntries {
Expand All @@ -59,7 +59,7 @@ func TestChainListChainPresent(t *testing.T) {
}

func TestChainListBigTransfers(t *testing.T) {
chainConfigEntries := chainList()
chainConfigEntries := ChainList()

for _, e := range chainConfigEntries {
// it's always ideal to have bigTransactionSize be less than dailyLimit
Expand Down
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