-
Notifications
You must be signed in to change notification settings - Fork 109
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 refactor-msgupdatechaininfo
- Loading branch information
Showing
37 changed files
with
671 additions
and
231 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package e2etests | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/zeta-chain/node/e2e/runner" | ||
"github.com/zeta-chain/node/e2e/utils" | ||
testcontract "github.com/zeta-chain/node/testutil/contracts" | ||
crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" | ||
zetabitcoin "github.com/zeta-chain/node/zetaclient/chains/bitcoin" | ||
) | ||
|
||
func TestBitcoinDepositAndCall(r *runner.E2ERunner, args []string) { | ||
// ARRANGE | ||
// Given BTC address | ||
r.SetBtcAddress(r.Name, false) | ||
|
||
// Given "Live" BTC network | ||
stop := r.MineBlocksIfLocalBitcoin() | ||
defer stop() | ||
|
||
// Given amount to send | ||
require.Len(r, args, 1) | ||
amount := parseFloat(r, args[0]) | ||
amountTotal := amount + zetabitcoin.DefaultDepositorFee | ||
|
||
// Given a list of UTXOs | ||
utxos, err := r.ListDeployerUTXOs() | ||
require.NoError(r, err) | ||
require.NotEmpty(r, utxos) | ||
|
||
// deploy an example contract in ZEVM | ||
contractAddr, _, contract, err := testcontract.DeployExample(r.ZEVMAuth, r.ZEVMClient) | ||
require.NoError(r, err) | ||
r.Logger.Print("Bitcoin: Example contract deployed at: %s", contractAddr.String()) | ||
|
||
// ACT | ||
// Send BTC to TSS address with a dummy memo | ||
data := []byte("hello satoshi") | ||
memo := append(contractAddr.Bytes(), data...) | ||
txHash, err := r.SendToTSSFromDeployerWithMemo(amountTotal, utxos, memo) | ||
require.NoError(r, err) | ||
|
||
// wait for the cctx to be mined | ||
cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, txHash.String(), r.CctxClient, r.Logger, r.CctxTimeout) | ||
r.Logger.CCTX(*cctx, "bitcoin_deposit_and_call") | ||
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined) | ||
|
||
// check if example contract has been called, 'bar' value should be set to amount | ||
amoutSats, err := zetabitcoin.GetSatoshis(amount) | ||
require.NoError(r, err) | ||
utils.MustHaveCalledExampleContract(r, contract, big.NewInt(amoutSats)) | ||
} |
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
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
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
Oops, something went wrong.