Skip to content

Commit

Permalink
removed unnecessary tests and made bitcoin withdrawal to restricted a…
Browse files Browse the repository at this point in the history
…ddress a separate test
  • Loading branch information
ws4charlie committed Mar 1, 2024
1 parent 6745c9b commit 7c4bebe
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmd/zetae2e/local/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func bitcoinTestRoutine(
// to make it faster to catch up with the latest block header
if err := bitcoinRunner.RunE2ETestsFromNames(
e2etests.AllE2ETests,
e2etests.TestBitcoinDepositName,
e2etests.TestBitcoinWithdrawName,
e2etests.TestBitcoinWithdrawRestrictedName,
e2etests.TestZetaWithdrawBTCRevertName,
e2etests.TestCrosschainSwapName,
); err != nil {
Expand Down
1 change: 0 additions & 1 deletion cmd/zetae2e/local/erc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func erc20TestRoutine(
// run erc20 test
if err := erc20Runner.RunE2ETestsFromNames(
e2etests.AllE2ETests,
e2etests.TestERC20DepositName,
e2etests.TestERC20WithdrawName,
e2etests.TestMultipleWithdrawsName,
e2etests.TestERC20DepositAndCallRefundName,
Expand Down
1 change: 0 additions & 1 deletion cmd/zetae2e/local/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ func ethereumTestRoutine(
// to make it faster to catch up with the latest block header
if err := ethereumRunner.RunE2ETestsFromNames(
e2etests.AllE2ETests,
e2etests.TestEtherDepositName,
e2etests.TestEtherWithdrawName,
e2etests.TestEtherWithdrawRestrictedName,
e2etests.TestContextUpgradeName,
Expand Down
6 changes: 6 additions & 0 deletions e2e/e2etests/e2etests.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
TestMessagePassingName = "message_passing"
TestZRC20SwapName = "zrc20_swap"
TestBitcoinWithdrawName = "bitcoin_withdraw"
TestBitcoinWithdrawRestrictedName = "bitcoin_withdraw_restricted"
TestCrosschainSwapName = "crosschain_swap"
TestMessagePassingRevertFailName = "message_passing_revert_fail"
TestMessagePassingRevertSuccessName = "message_passing_revert_success"
Expand Down Expand Up @@ -99,6 +100,11 @@ var AllE2ETests = []runner.E2ETest{
"withdraw BTC from ZEVM",
TestBitcoinWithdraw,
},
{
TestBitcoinWithdrawRestrictedName,
"withdraw Bitcoin from ZEVM to restricted address",
TestBitcoinWithdrawRestricted,
},
{
TestCrosschainSwapName,
"testing Bitcoin ERC20 cross-chain swap",
Expand Down
14 changes: 8 additions & 6 deletions e2e/e2etests/test_bitcoin_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@ import (
)

func TestBitcoinWithdraw(r *runner.E2ERunner) {
// start mining blocks
stop := r.MineBlocks()

// withdraw 0.01 BTC from ZRC20 to BTC address
WithdrawBitcoin(r)
}

func TestBitcoinWithdrawRestricted(r *runner.E2ERunner) {
// withdraw 0.01 BTC from ZRC20 to BTC restricted address
WithdrawBitcoinRestricted(r)

// stop mining
stop <- struct{}{}
}

func withdrawBTCZRC20(r *runner.E2ERunner, to btcutil.Address, amount *big.Int) *btcjson.TxRawResult {
Expand All @@ -38,6 +34,9 @@ func withdrawBTCZRC20(r *runner.E2ERunner, to btcutil.Address, amount *big.Int)
panic(fmt.Errorf("approve receipt status is not 1"))
}

// mine blocks
stop := r.MineBlocks()

// withdraw 'amount' of BTC from ZRC20 to BTC address
tx, err = r.BTCZRC20.Withdraw(r.ZevmAuth, []byte(to.EncodeAddress()), amount)
if err != nil {
Expand Down Expand Up @@ -79,6 +78,9 @@ func withdrawBTCZRC20(r *runner.E2ERunner, to btcutil.Address, amount *big.Int)
r.Logger.Info(" ScriptPubKey: %s", txOut.ScriptPubKey.Hex)
}

// stop mining
stop <- struct{}{}

return rawTx
}

Expand Down

0 comments on commit 7c4bebe

Please sign in to comment.