Skip to content

Commit

Permalink
use explicit deposit, withdraw names for test accounts; use two colors;
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Nov 7, 2024
1 parent 2129ae7 commit 03b7c9b
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 82 deletions.
4 changes: 2 additions & 2 deletions cmd/zetae2e/config/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/config/localnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
79 changes: 30 additions & 49 deletions cmd/zetae2e/local/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,49 @@ 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"
"github.com/zeta-chain/node/e2e/runner"
"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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand Down
5 changes: 3 additions & 2 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,16 @@ 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,
!skipBitcoinSetup,
bitcoinDepositTests,
bitcoinWithdrawTests,
)
eg.Go(runnerDeposit)
eg.Go(runnerWithdraw)
eg.Go(ethereumTestRoutine(conf, deployerRunner, verbose, ethereumTests...))
}

Expand Down
8 changes: 4 additions & 4 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions contrib/localnet/scripts/start-zetacored.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 19 additions & 19 deletions e2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 03b7c9b

Please sign in to comment.