diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index dc14c9b0ff..a649521731 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -268,65 +268,66 @@ func localE2ETest(cmd *cobra.Command, _ []string) { if !skipRegular { // defines all tests, if light is enabled, only the most basic tests are run and advanced are skipped erc20Tests := []string{ - e2etests.TestERC20WithdrawName, - e2etests.TestMultipleERC20WithdrawsName, - e2etests.TestERC20DepositAndCallRefundName, - e2etests.TestZRC20SwapName, + //e2etests.TestERC20WithdrawName, + //e2etests.TestMultipleERC20WithdrawsName, + //e2etests.TestERC20DepositAndCallRefundName, + //e2etests.TestZRC20SwapName, } erc20AdvancedTests := []string{ - e2etests.TestERC20DepositRestrictedName, + //e2etests.TestERC20DepositRestrictedName, } zetaTests := []string{ - e2etests.TestZetaWithdrawName, - e2etests.TestMessagePassingExternalChainsName, - e2etests.TestMessagePassingRevertFailExternalChainsName, - e2etests.TestMessagePassingRevertSuccessExternalChainsName, + //e2etests.TestZetaWithdrawName, + //e2etests.TestMessagePassingExternalChainsName, + //e2etests.TestMessagePassingRevertFailExternalChainsName, + //e2etests.TestMessagePassingRevertSuccessExternalChainsName, } zetaAdvancedTests := []string{ - e2etests.TestZetaDepositRestrictedName, - e2etests.TestZetaDepositName, - e2etests.TestZetaDepositNewAddressName, + //e2etests.TestZetaDepositRestrictedName, + //e2etests.TestZetaDepositName, + //e2etests.TestZetaDepositNewAddressName, } zevmMPTests := []string{} zevmMPAdvancedTests := []string{ - e2etests.TestMessagePassingZEVMToEVMName, - e2etests.TestMessagePassingEVMtoZEVMName, - e2etests.TestMessagePassingEVMtoZEVMRevertName, - e2etests.TestMessagePassingZEVMtoEVMRevertName, - e2etests.TestMessagePassingZEVMtoEVMRevertFailName, - e2etests.TestMessagePassingEVMtoZEVMRevertFailName, + //e2etests.TestMessagePassingZEVMToEVMName, + //e2etests.TestMessagePassingEVMtoZEVMName, + //e2etests.TestMessagePassingEVMtoZEVMRevertName, + //e2etests.TestMessagePassingZEVMtoEVMRevertName, + //e2etests.TestMessagePassingZEVMtoEVMRevertFailName, + //e2etests.TestMessagePassingEVMtoZEVMRevertFailName, } bitcoinTests := []string{ - e2etests.TestBitcoinDonationName, - e2etests.TestBitcoinDepositName, - e2etests.TestBitcoinDepositAndCallName, - e2etests.TestBitcoinDepositAndCallRevertName, - e2etests.TestBitcoinWithdrawSegWitName, - e2etests.TestBitcoinWithdrawInvalidAddressName, - e2etests.TestZetaWithdrawBTCRevertName, - e2etests.TestCrosschainSwapName, + //e2etests.TestBitcoinDonationName, + //e2etests.TestBitcoinDepositName, + //e2etests.TestBitcoinDepositAndCallName, + //e2etests.TestBitcoinDepositAndCallRevertName, + e2etests.TestBitcoinDepositAndCallRevertWithDustName, + //e2etests.TestBitcoinWithdrawSegWitName, + //e2etests.TestBitcoinWithdrawInvalidAddressName, + //e2etests.TestZetaWithdrawBTCRevertName, + //e2etests.TestCrosschainSwapName, } bitcoinAdvancedTests := []string{ - e2etests.TestBitcoinWithdrawTaprootName, - e2etests.TestBitcoinWithdrawLegacyName, - e2etests.TestBitcoinWithdrawMultipleName, - e2etests.TestBitcoinWithdrawP2SHName, - e2etests.TestBitcoinWithdrawP2WSHName, - e2etests.TestBitcoinWithdrawRestrictedName, - e2etests.TestBitcoinStdMemoDepositName, - e2etests.TestBitcoinStdMemoDepositAndCallName, - e2etests.TestBitcoinStdMemoDepositAndCallRevertName, - e2etests.TestBitcoinStdMemoDepositAndCallRevertOtherAddressName, + //e2etests.TestBitcoinWithdrawTaprootName, + //e2etests.TestBitcoinWithdrawLegacyName, + //e2etests.TestBitcoinWithdrawMultipleName, + //e2etests.TestBitcoinWithdrawP2SHName, + //e2etests.TestBitcoinWithdrawP2WSHName, + //e2etests.TestBitcoinWithdrawRestrictedName, + //e2etests.TestBitcoinStdMemoDepositName, + //e2etests.TestBitcoinStdMemoDepositAndCallName, + //e2etests.TestBitcoinStdMemoDepositAndCallRevertName, + //e2etests.TestBitcoinStdMemoDepositAndCallRevertOtherAddressName, } ethereumTests := []string{ - e2etests.TestEtherWithdrawName, - e2etests.TestContextUpgradeName, - e2etests.TestEtherDepositAndCallName, - e2etests.TestEtherDepositAndCallRefundName, + //e2etests.TestEtherWithdrawName, + //e2etests.TestContextUpgradeName, + //e2etests.TestEtherDepositAndCallName, + //e2etests.TestEtherDepositAndCallRefundName, } ethereumAdvancedTests := []string{ - e2etests.TestEtherWithdrawRestrictedName, + //e2etests.TestEtherWithdrawRestrictedName, } precompiledContractTests := []string{} diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index 98eac4397d..872f217cd8 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -75,6 +75,7 @@ const ( TestBitcoinDepositName = "bitcoin_deposit" TestBitcoinDepositAndCallName = "bitcoin_deposit_and_call" TestBitcoinDepositAndCallRevertName = "bitcoin_deposit_and_call_revert" + TestBitcoinDepositAndCallRevertWithDustName = "bitcoin_deposit_and_call_revert_with_dust" TestBitcoinDonationName = "bitcoin_donation" TestBitcoinStdMemoDepositName = "bitcoin_std_memo_deposit" TestBitcoinStdMemoDepositAndCallName = "bitcoin_std_memo_deposit_and_call" @@ -508,6 +509,11 @@ var AllE2ETests = []runner.E2ETest{ }, TestBitcoinDepositAndCallRevert, ), + runner.NewE2ETest( + TestBitcoinDepositAndCallRevertWithDustName, + "deposit Bitcoin into ZEVM; revert with dust amount that aborts the CCTX", []runner.ArgDefinition{}, + TestBitcoinDepositAndCallRevertWithDust, + ), runner.NewE2ETest( TestBitcoinStdMemoDepositName, "deposit Bitcoin into ZEVM with standard memo", diff --git a/e2e/e2etests/test_bitcoin_deposit_and_call_revert.go b/e2e/e2etests/test_bitcoin_deposit_and_call_revert.go index eed10485bf..e90a64ad56 100644 --- a/e2e/e2etests/test_bitcoin_deposit_and_call_revert.go +++ b/e2e/e2etests/test_bitcoin_deposit_and_call_revert.go @@ -24,6 +24,8 @@ func TestBitcoinDepositAndCallRevert(r *runner.E2ERunner, args []string) { amount := parseFloat(r, args[0]) amount += zetabitcoin.DefaultDepositorFee + r.Logger.Print("BITCOIN: Amount to send: %s", args[0]) + // Given a list of UTXOs utxos, err := r.ListDeployerUTXOs() require.NoError(r, err) @@ -47,5 +49,9 @@ func TestBitcoinDepositAndCallRevert(r *runner.E2ERunner, args []string) { assert.Equal(r, r.BTCDeployerAddress.EncodeAddress(), receiver) assert.Positive(r, value) + r.Logger.Print("BITCOIN: Amount received: %d", value) + + // 0.002 + r.Logger.Info("Sent %f BTC to TSS with invalid memo, got refund of %d satoshis", amount, value) } diff --git a/e2e/e2etests/test_bitcoin_deposit_and_call_revert_with_dust.go b/e2e/e2etests/test_bitcoin_deposit_and_call_revert_with_dust.go new file mode 100644 index 0000000000..a71d65588c --- /dev/null +++ b/e2e/e2etests/test_bitcoin_deposit_and_call_revert_with_dust.go @@ -0,0 +1,56 @@ +package e2etests + +import ( + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/zeta-chain/node/e2e/runner" + "github.com/zeta-chain/node/e2e/utils" + "github.com/zeta-chain/node/testutil/sample" +) + +// TestBitcoinDepositAndCallRevertWithDust sends a Bitcoin deposit that reverts with a dust amount in the revert outbound. +// Given the dust is too smart, the CCTX should revert +func TestBitcoinDepositAndCallRevertWithDust(r *runner.E2ERunner, args []string) { + // ARRANGE + // Given BTC address + r.SetBtcAddress(r.Name, false) + + require.Len(r, args, 0) + + // Given "Live" BTC network + stop := r.MineBlocksIfLocalBitcoin() + defer stop() + + // 0.002 BTC is consumed in a deposit and revert, the dust is set to 1000 satoshis in the protocol + // Therefore the deposit amount should be 0.002 + 0.000005 = 0.00200500 should trigger the condition + // As only 500 satoshis are left after the deposit + + amount := 0.00200500 + + // Given a list of UTXOs + utxos, err := r.ListDeployerUTXOs() + require.NoError(r, err) + require.NotEmpty(r, utxos) + + // ACT + // Send BTC to TSS address with a dummy memo + // zetacore should revert cctx if call is made on a non-existing address + nonExistReceiver := sample.EthAddress() + badMemo := append(nonExistReceiver.Bytes(), []byte("gibberish-memo")...) + txHash, err := r.SendToTSSFromDeployerWithMemo(amount, utxos, badMemo) + require.NoError(r, err) + require.NotEmpty(r, txHash) + + // ASSERT + // Now we want to make sure refund TX is completed. + cctx := utils.WaitCctxRevertedByInboundHash(r.Ctx, r, txHash.String(), r.CctxClient) + + // Check revert tx receiver address and amount + receiver, value := r.QueryOutboundReceiverAndAmount(cctx.OutboundParams[1].Hash) + assert.Equal(r, r.BTCDeployerAddress.EncodeAddress(), receiver) + assert.Positive(r, value) + + r.Logger.Print("BITCOIN: Amount received: %d", value) + r.Logger.Info("Sent %f BTC to TSS with invalid memo, got refund of %d satoshis", amount, value) +}