From 03b7c9bc1c723a4924feb4490382a2a02cdb16d9 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Thu, 7 Nov 2024 14:41:45 -0600 Subject: [PATCH] use explicit deposit, withdraw names for test accounts; use two colors; --- cmd/zetae2e/config/local.yml | 4 +- cmd/zetae2e/config/localnet.yml | 4 +- cmd/zetae2e/local/bitcoin.go | 79 +++++++------------ cmd/zetae2e/local/local.go | 5 +- .../localnet/orchestrator/start-zetae2e.sh | 8 +- contrib/localnet/scripts/start-zetacored.sh | 8 +- e2e/config/config.go | 38 ++++----- 7 files changed, 64 insertions(+), 82 deletions(-) diff --git a/cmd/zetae2e/config/local.yml b/cmd/zetae2e/config/local.yml index 0e8fd7a1b9..5cc87be394 100644 --- a/cmd/zetae2e/config/local.yml +++ b/cmd/zetae2e/config/local.yml @@ -16,11 +16,11 @@ additional_accounts: bech32_address: "zeta13t3zjxvwec7g38q8mdjga37rpes9zkfvv7tkn2" evm_address: "0x8Ae229198eCE3c889C07DB648Ec7C30E6051592c" private_key: "105460aebf71b10bfdb710ef5aa6d2932ee6ff6fc317ac9c24e0979903b10a5d" - user_bitcoin1: + user_bitcoin_deposit: bech32_address: "zeta19q7czqysah6qg0n4y3l2a08gfzqxydla492v80" evm_address: "0x283d810090EdF4043E75247eAeBcE848806237fD" private_key: "7bb523963ee2c78570fb6113d886a4184d42565e8847f1cb639f5f5e2ef5b37a" - user_bitcoin2: + user_bitcoin_withdraw: bech32_address: "zeta17e77anpmzhuuam67hg6x3mtqrulqh80z9chv70" evm_address: "0xf67deecc3B15F9CEeF5eba3468ed601f3e0B9de2" private_key: "2b3306a8ac43dbf0e350b87876c131e7e12bd49563a16de9ce8aeb664b94d559" diff --git a/cmd/zetae2e/config/localnet.yml b/cmd/zetae2e/config/localnet.yml index 5d00b4f6aa..24e51223ef 100644 --- a/cmd/zetae2e/config/localnet.yml +++ b/cmd/zetae2e/config/localnet.yml @@ -16,11 +16,11 @@ additional_accounts: bech32_address: "zeta13t3zjxvwec7g38q8mdjga37rpes9zkfvv7tkn2" evm_address: "0x8Ae229198eCE3c889C07DB648Ec7C30E6051592c" private_key: "105460aebf71b10bfdb710ef5aa6d2932ee6ff6fc317ac9c24e0979903b10a5d" - user_bitcoin1: + user_bitcoin_deposit: bech32_address: "zeta19q7czqysah6qg0n4y3l2a08gfzqxydla492v80" evm_address: "0x283d810090EdF4043E75247eAeBcE848806237fD" private_key: "7bb523963ee2c78570fb6113d886a4184d42565e8847f1cb639f5f5e2ef5b37a" - user_bitcoin2: + user_bitcoin_withdraw: bech32_address: "zeta17e77anpmzhuuam67hg6x3mtqrulqh80z9chv70" evm_address: "0xf67deecc3B15F9CEeF5eba3468ed601f3e0B9de2" private_key: "2b3306a8ac43dbf0e350b87876c131e7e12bd49563a16de9ce8aeb664b94d559" diff --git a/cmd/zetae2e/local/bitcoin.go b/cmd/zetae2e/local/bitcoin.go index 28ae560f97..9f7d2f4511 100644 --- a/cmd/zetae2e/local/bitcoin.go +++ b/cmd/zetae2e/local/bitcoin.go @@ -6,7 +6,6 @@ import ( "github.com/fatih/color" "github.com/stretchr/testify/require" - "golang.org/x/sync/errgroup" "github.com/zeta-chain/node/e2e/config" "github.com/zeta-chain/node/e2e/e2etests" @@ -14,21 +13,42 @@ import ( "github.com/zeta-chain/node/testutil" ) -// startBitcoinTestRoutines starts Bitcoin deposit and withdraw tests in parallel -func startBitcoinTestRoutines( - eg *errgroup.Group, +// initBitcoinTestRunners initializes Bitcoin deposit and withdraw test runners +func initBitcoinTestRunners( conf config.Config, deployerRunner *runner.E2ERunner, verbose bool, initNetwork bool, depositTests []string, withdrawTests []string, -) { +) (func() error, func() error) { // initialize runner for deposit tests - runnerDeposit := initRunnerDeposit(conf, deployerRunner, verbose, initNetwork) + // deposit tests need Bitcoin node wallet to handle UTXOs + account := conf.AdditionalAccounts.UserBitcoinDeposit + runnerDeposit := initRunner( + "btc_deposit", + account, + conf, + deployerRunner, + color.FgYellow, + verbose, + initNetwork, + true, + ) // initialize runner for withdraw tests - runnerWithdraw := initRunnerWithdraw(conf, deployerRunner, verbose, initNetwork) + // withdraw tests DON'T use Bitcoin node wallet + account = conf.AdditionalAccounts.UserBitcoinWithdraw + runnerWithdraw := initRunner( + "btc_withdraw", + account, + conf, + deployerRunner, + color.FgHiYellow, + verbose, + initNetwork, + false, + ) // initialize funds // send BTC to TSS for gas fees and to tester ZEVM address @@ -47,39 +67,7 @@ func startBitcoinTestRoutines( routineDeposit := createTestRoutine(runnerDeposit, depositTests) routineWithdraw := createTestRoutine(runnerWithdraw, withdrawTests) - // start test routines - eg.Go(routineDeposit) - eg.Go(routineWithdraw) -} - -// initRunnerDeposit initializes the runner for deposit tests -func initRunnerDeposit( - conf config.Config, - deployerRunner *runner.E2ERunner, - verbose, initNetwork bool, -) *runner.E2ERunner { - var ( - name = "btc_deposit" - account = conf.AdditionalAccounts.UserBitcoin1 - createWallet = true // deposit tests need Bitcoin node wallet to handle UTXOs - ) - - return initRunner(name, account, conf, deployerRunner, verbose, initNetwork, createWallet) -} - -// initRunnerWithdraw initializes the runner for withdraw tests -func initRunnerWithdraw( - conf config.Config, - deployerRunner *runner.E2ERunner, - verbose, initNetwork bool, -) *runner.E2ERunner { - var ( - name = "btc_withdraw" - account = conf.AdditionalAccounts.UserBitcoin2 - createWallet = false // withdraw tests DON'T use Bitcoin node wallet - ) - - return initRunner(name, account, conf, deployerRunner, verbose, initNetwork, createWallet) + return routineDeposit, routineWithdraw } // initRunner initializes the runner for given test name and account @@ -88,16 +76,11 @@ func initRunner( account config.Account, conf config.Config, deployerRunner *runner.E2ERunner, + printColor color.Attribute, verbose, initNetwork, createWallet bool, ) *runner.E2ERunner { // initialize runner for bitcoin test - runner, err := initTestRunner( - name, - conf, - deployerRunner, - account, - runner.NewLogger(verbose, color.FgYellow, name), - ) + runner, err := initTestRunner(name, conf, deployerRunner, account, runner.NewLogger(verbose, printColor, name)) testutil.NoError(err) // setup TSS address and setup deployer wallet @@ -125,8 +108,6 @@ func initRunner( } // createTestRoutine creates a test routine for given test names -// Note: due to the extensive block generation in Bitcoin localnet, block header test is run first -// to make it faster to catch up with the latest block header func createTestRoutine(r *runner.E2ERunner, testNames []string) func() error { return func() (err error) { r.Logger.Print("🏃 starting bitcoin tests") diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index af9cedecc5..b8fda5db56 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -366,8 +366,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) { eg.Go(erc20TestRoutine(conf, deployerRunner, verbose, erc20Tests...)) eg.Go(zetaTestRoutine(conf, deployerRunner, verbose, zetaTests...)) eg.Go(zevmMPTestRoutine(conf, deployerRunner, verbose, zevmMPTests...)) - startBitcoinTestRoutines( - &eg, + runnerDeposit, runnerWithdraw := initBitcoinTestRunners( conf, deployerRunner, verbose, @@ -375,6 +374,8 @@ func localE2ETest(cmd *cobra.Command, _ []string) { bitcoinDepositTests, bitcoinWithdrawTests, ) + eg.Go(runnerDeposit) + eg.Go(runnerWithdraw) eg.Go(ethereumTestRoutine(conf, deployerRunner, verbose, ethereumTests...)) } diff --git a/contrib/localnet/orchestrator/start-zetae2e.sh b/contrib/localnet/orchestrator/start-zetae2e.sh index ac5de0418d..5d8c9c5586 100644 --- a/contrib/localnet/orchestrator/start-zetae2e.sh +++ b/contrib/localnet/orchestrator/start-zetae2e.sh @@ -98,11 +98,11 @@ fund_eth_from_config '.additional_accounts.user_zeta_test.evm_address' 10000 "ze # unlock zevm message passing tester accounts fund_eth_from_config '.additional_accounts.user_zevm_mp_test.evm_address' 10000 "zevm mp tester" -# unlock bitcoin tester1 accounts -fund_eth_from_config '.additional_accounts.user_bitcoin1.evm_address' 10000 "bitcoin tester1" +# unlock bitcoin deposit tester accounts +fund_eth_from_config '.additional_accounts.user_bitcoin_deposit.evm_address' 10000 "bitcoin deposit tester" -# unlock bitcoin tester2 accounts -fund_eth_from_config '.additional_accounts.user_bitcoin2.evm_address' 10000 "bitcoin tester2" +# unlock bitcoin withdraw tester accounts +fund_eth_from_config '.additional_accounts.user_bitcoin_withdraw.evm_address' 10000 "bitcoin withdraw tester" # unlock solana tester accounts fund_eth_from_config '.additional_accounts.user_solana.evm_address' 10000 "solana tester" diff --git a/contrib/localnet/scripts/start-zetacored.sh b/contrib/localnet/scripts/start-zetacored.sh index 367bc66a30..38047a6b46 100755 --- a/contrib/localnet/scripts/start-zetacored.sh +++ b/contrib/localnet/scripts/start-zetacored.sh @@ -242,11 +242,11 @@ then # zeta tester address=$(yq -r '.additional_accounts.user_zeta_test.bech32_address' /root/config.yml) zetacored add-genesis-account "$address" 100000000000000000000000000azeta -# bitcoin tester1 - address=$(yq -r '.additional_accounts.user_bitcoin1.bech32_address' /root/config.yml) +# bitcoin deposit tester + address=$(yq -r '.additional_accounts.user_bitcoin_deposit.bech32_address' /root/config.yml) zetacored add-genesis-account "$address" 100000000000000000000000000azeta -# bitcoin tester2 - address=$(yq -r '.additional_accounts.user_bitcoin2.bech32_address' /root/config.yml) +# bitcoin withdraw tester + address=$(yq -r '.additional_accounts.user_bitcoin_withdraw.bech32_address' /root/config.yml) zetacored add-genesis-account "$address" 100000000000000000000000000azeta # solana tester address=$(yq -r '.additional_accounts.user_solana.bech32_address' /root/config.yml) diff --git a/e2e/config/config.go b/e2e/config/config.go index e625d51f5e..3f0a8f0bf6 100644 --- a/e2e/config/config.go +++ b/e2e/config/config.go @@ -61,21 +61,21 @@ type Account struct { // AdditionalAccounts are extra accounts required to run specific tests type AdditionalAccounts struct { - UserERC20 Account `yaml:"user_erc20"` - UserZetaTest Account `yaml:"user_zeta_test"` - UserZEVMMPTest Account `yaml:"user_zevm_mp_test"` - UserBitcoin1 Account `yaml:"user_bitcoin1"` - UserBitcoin2 Account `yaml:"user_bitcoin2"` - UserSolana Account `yaml:"user_solana"` - UserEther Account `yaml:"user_ether"` - UserMisc Account `yaml:"user_misc"` - UserAdmin Account `yaml:"user_admin"` - UserMigration Account `yaml:"user_migration"` // used for TSS migration, TODO: rename (https://github.com/zeta-chain/node/issues/2780) - UserPrecompile Account `yaml:"user_precompile"` - UserV2Ether Account `yaml:"user_v2_ether"` - UserV2ERC20 Account `yaml:"user_v2_erc20"` - UserV2EtherRevert Account `yaml:"user_v2_ether_revert"` - UserV2ERC20Revert Account `yaml:"user_v2_erc20_revert"` + UserERC20 Account `yaml:"user_erc20"` + UserZetaTest Account `yaml:"user_zeta_test"` + UserZEVMMPTest Account `yaml:"user_zevm_mp_test"` + UserBitcoinDeposit Account `yaml:"user_bitcoin_deposit"` + UserBitcoinWithdraw Account `yaml:"user_bitcoin_withdraw"` + UserSolana Account `yaml:"user_solana"` + UserEther Account `yaml:"user_ether"` + UserMisc Account `yaml:"user_misc"` + UserAdmin Account `yaml:"user_admin"` + UserMigration Account `yaml:"user_migration"` // used for TSS migration, TODO: rename (https://github.com/zeta-chain/node/issues/2780) + UserPrecompile Account `yaml:"user_precompile"` + UserV2Ether Account `yaml:"user_v2_ether"` + UserV2ERC20 Account `yaml:"user_v2_erc20"` + UserV2EtherRevert Account `yaml:"user_v2_ether_revert"` + UserV2ERC20Revert Account `yaml:"user_v2_erc20_revert"` } type PolicyAccounts struct { @@ -234,8 +234,8 @@ func (a AdditionalAccounts) AsSlice() []Account { a.UserERC20, a.UserZetaTest, a.UserZEVMMPTest, - a.UserBitcoin1, - a.UserBitcoin2, + a.UserBitcoinDeposit, + a.UserBitcoinWithdraw, a.UserSolana, a.UserEther, a.UserMisc, @@ -314,11 +314,11 @@ func (c *Config) GenerateKeys() error { if err != nil { return err } - c.AdditionalAccounts.UserBitcoin1, err = generateAccount() + c.AdditionalAccounts.UserBitcoinDeposit, err = generateAccount() if err != nil { return err } - c.AdditionalAccounts.UserBitcoin2, err = generateAccount() + c.AdditionalAccounts.UserBitcoinWithdraw, err = generateAccount() if err != nil { return err }