From 2a700cf9d2a6d5afc7eceb428aac7d8feaf9470b Mon Sep 17 00:00:00 2001 From: RafilxTenfen Date: Fri, 6 Dec 2024 09:25:21 -0300 Subject: [PATCH] fix: set specific btc network type --- test/e2e/configurer/factory.go | 39 +++++++++++++++++++++--- test/e2e/initialization/config.go | 1 + test/e2e/software_upgrade_e2e_v1_test.go | 11 ++++++- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/test/e2e/configurer/factory.go b/test/e2e/configurer/factory.go index 847c8fc3..083281d8 100644 --- a/test/e2e/configurer/factory.go +++ b/test/e2e/configurer/factory.go @@ -10,6 +10,7 @@ import ( "github.com/babylonlabs-io/babylon/test/e2e/configurer/chain" "github.com/babylonlabs-io/babylon/test/e2e/containers" "github.com/babylonlabs-io/babylon/test/e2e/initialization" + bbn "github.com/babylonlabs-io/babylon/types" btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" ) @@ -34,6 +35,10 @@ type Configurer interface { RunIBCTransferChannel() error } +const ( + btcNetworkStr = string(bbn.BtcSimnet) +) + var ( // Last nodes are non validator nodes to serve as the ones using relayer. Out // validators are constantly sending bls transactions which make relayer operations @@ -52,6 +57,7 @@ var ( SnapshotInterval: 25, SnapshotKeepRecent: 10, IsValidator: true, + BtcNetwork: btcNetworkStr, }, { Name: "babylon-default-a-2", @@ -61,6 +67,7 @@ var ( SnapshotInterval: 1500, SnapshotKeepRecent: 2, IsValidator: true, + BtcNetwork: btcNetworkStr, }, { Name: "babylon-default-a-3", @@ -70,6 +77,7 @@ var ( SnapshotInterval: 1500, SnapshotKeepRecent: 2, IsValidator: false, + BtcNetwork: btcNetworkStr, }, } validatorConfigsChainB = []*initialization.NodeConfig{ @@ -81,6 +89,7 @@ var ( SnapshotInterval: 1500, SnapshotKeepRecent: 2, IsValidator: true, + BtcNetwork: btcNetworkStr, }, { Name: "babylon-default-b-2", @@ -90,6 +99,7 @@ var ( SnapshotInterval: 1500, SnapshotKeepRecent: 2, IsValidator: true, + BtcNetwork: btcNetworkStr, }, { Name: "babylon-default-b-3", @@ -99,6 +109,7 @@ var ( SnapshotInterval: 1500, SnapshotKeepRecent: 2, IsValidator: false, + BtcNetwork: btcNetworkStr, }, } ) @@ -204,7 +215,20 @@ func NewSoftwareUpgradeConfigurer(t *testing.T, isDebugLogEnabled bool, upgradeP return nil, err } - chainA := chain.New(t, containerManager, initialization.ChainAID, updateNodeConfigNameWithIdentifier(validatorConfigsChainA, identifier), nil) + cfgs := updateNodeConfigs(validatorConfigsChainA, func(cfg *initialization.NodeConfig) *initialization.NodeConfig { + return &initialization.NodeConfig{ + Name: fmt.Sprintf("%s-%s", cfg.Name, identifier), + Pruning: cfg.Pruning, + PruningKeepRecent: cfg.PruningKeepRecent, + PruningInterval: cfg.PruningInterval, + SnapshotInterval: cfg.SnapshotInterval, + SnapshotKeepRecent: cfg.SnapshotKeepRecent, + IsValidator: cfg.IsValidator, + BtcNetwork: string(bbn.BtcSignet), + } + }) + + chainA := chain.New(t, containerManager, initialization.ChainAID, cfgs, nil) if btcHeaders != nil { chainA.BTCHeaders = btcHeaders } @@ -234,9 +258,8 @@ func identifierName(t *testing.T) string { } func updateNodeConfigNameWithIdentifier(cfgs []*initialization.NodeConfig, identifier string) []*initialization.NodeConfig { - result := make([]*initialization.NodeConfig, len(cfgs)) - for i, cfg := range cfgs { - result[i] = &initialization.NodeConfig{ + return updateNodeConfigs(cfgs, func(cfg *initialization.NodeConfig) *initialization.NodeConfig { + return &initialization.NodeConfig{ Name: fmt.Sprintf("%s-%s", cfg.Name, identifier), Pruning: cfg.Pruning, PruningKeepRecent: cfg.PruningKeepRecent, @@ -244,7 +267,15 @@ func updateNodeConfigNameWithIdentifier(cfgs []*initialization.NodeConfig, ident SnapshotInterval: cfg.SnapshotInterval, SnapshotKeepRecent: cfg.SnapshotKeepRecent, IsValidator: cfg.IsValidator, + BtcNetwork: cfg.BtcNetwork, } + }) +} + +func updateNodeConfigs(cfgs []*initialization.NodeConfig, f func(cfg *initialization.NodeConfig) *initialization.NodeConfig) []*initialization.NodeConfig { + result := make([]*initialization.NodeConfig, len(cfgs)) + for i, cfg := range cfgs { + result[i] = f(cfg) } return result } diff --git a/test/e2e/initialization/config.go b/test/e2e/initialization/config.go index 2bcba9c6..c9911f87 100644 --- a/test/e2e/initialization/config.go +++ b/test/e2e/initialization/config.go @@ -46,6 +46,7 @@ type NodeConfig struct { SnapshotInterval uint64 // statesync snapshot every Nth block (0 to disable) SnapshotKeepRecent uint32 // number of recent snapshots to keep and serve (0 to keep all) IsValidator bool // flag indicating whether a node should be a validator + BtcNetwork string // The Bitcoin network used } const ( diff --git a/test/e2e/software_upgrade_e2e_v1_test.go b/test/e2e/software_upgrade_e2e_v1_test.go index 8f1ebbdd..a78c2208 100644 --- a/test/e2e/software_upgrade_e2e_v1_test.go +++ b/test/e2e/software_upgrade_e2e_v1_test.go @@ -49,6 +49,7 @@ func (s *SoftwareUpgradeV1TestnetTestSuite) SetupSuite() { preUpgradeFunc := func(chains []*chain.Config) { node := chains[0].NodeConfigs[1] uniqueAddrs := make(map[string]any) + uniqueAddrsToMint := make(map[string]any) for addr, amountToMint := range balanceToMintByAddr { uniqueAddrs[addr] = struct{}{} @@ -56,6 +57,7 @@ func (s *SoftwareUpgradeV1TestnetTestSuite) SetupSuite() { continue } + uniqueAddrsToMint[addr] = struct{}{} amountToSend := sdk.NewCoin(appparams.BaseCoinUnit, sdkmath.NewInt(amountToMint)) node.BankSendFromNode(addr, amountToSend.String()) } @@ -63,10 +65,17 @@ func (s *SoftwareUpgradeV1TestnetTestSuite) SetupSuite() { // needs to wait for a block to make sure the send tx was processed and // it queries the real balances before upgrade. node.WaitForNextBlock() + + // This does not work for 50k addresses for addr := range uniqueAddrs { + // assume that the balance prior to upgrade of each addr is zero. + s.balancesBeforeUpgrade[addr] = sdk.NewCoin(appparams.DefaultBondDenom, sdkmath.ZeroInt()) + } + + // only verifies the ones that did received something + for addr := range uniqueAddrsToMint { balance, err := node.QueryBalance(addr, appparams.DefaultBondDenom) s.NoError(err) - s.balancesBeforeUpgrade[addr] = *balance } }