-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix/orchestrator-logging
- Loading branch information
Showing
5 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
e2e/e2etests/test_bitcoin_deposit_and_call_revert_with_dust.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package e2etests | ||
|
||
import ( | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/zeta-chain/node/e2e/runner" | ||
"github.com/zeta-chain/node/e2e/utils" | ||
"github.com/zeta-chain/node/pkg/constant" | ||
"github.com/zeta-chain/node/testutil/sample" | ||
crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" | ||
zetabitcoin "github.com/zeta-chain/node/zetaclient/chains/bitcoin" | ||
) | ||
|
||
// TestBitcoinDepositAndCallRevertWithDust sends a Bitcoin deposit that reverts with a dust amount in the revert outbound. | ||
func TestBitcoinDepositAndCallRevertWithDust(r *runner.E2ERunner, args []string) { | ||
// Given "Live" BTC network | ||
stop := r.MineBlocksIfLocalBitcoin() | ||
defer stop() | ||
|
||
require.Len(r, args, 0) | ||
|
||
// 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.000001 = 0.00200100 should trigger the condition | ||
// As only 100 satoshis are left after the deposit | ||
const ( | ||
// depositAmount is 0.002001 BTC, chosen to result in 100 satoshis after deposit | ||
// which is below the dust threshold of 1000 satoshis | ||
depositAmount = 0.00200100 | ||
) | ||
amount := depositAmount + zetabitcoin.DefaultDepositorFee | ||
|
||
// 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) | ||
|
||
// wait for the cctx to be mined | ||
cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, txHash.String(), r.CctxClient, r.Logger, r.CctxTimeout) | ||
r.Logger.CCTX(*cctx, "deposit_and_revert") | ||
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_Reverted) | ||
|
||
// check the test was effective: the revert outbound amount is less than the dust amount | ||
require.Less(r, cctx.GetCurrentOutboundParam().Amount.Uint64(), uint64(constant.BTCWithdrawalDustAmount)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters