Skip to content

Commit

Permalink
test v20 contracts integration
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Oct 16, 2024
1 parent c05a91c commit de7cd3d
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 40 deletions.
8 changes: 4 additions & 4 deletions cmd/zetae2e/local/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ func startV2Tests(eg *errgroup.Group, conf config.Config, deployerRunner *runner
verbose,
e2etests.TestV2ETHDepositName, // necessary to pay fees on ZEVM and withdraw
e2etests.TestV2ETHDepositAndCallRevertName,
e2etests.TestV2ETHDepositAndCallRevertWithCallName,
// e2etests.TestV2ETHDepositAndCallRevertWithCallName, // call on revert disabled
e2etests.TestV2ETHWithdrawAndCallRevertName,
e2etests.TestV2ETHWithdrawAndCallRevertWithCallName,
// e2etests.TestV2ETHWithdrawAndCallRevertWithCallName, // call on revert disabled
),
)

Expand All @@ -64,9 +64,9 @@ func startV2Tests(eg *errgroup.Group, conf config.Config, deployerRunner *runner
e2etests.TestOperationAddLiquidityETHName, // liquidity with gas and ERC20 are necessary for reverts
e2etests.TestOperationAddLiquidityERC20Name,
e2etests.TestV2ERC20DepositAndCallRevertName,
e2etests.TestV2ERC20DepositAndCallRevertWithCallName,
// e2etests.TestV2ERC20DepositAndCallRevertWithCallName, // call on revert disabled
e2etests.TestV2ERC20WithdrawAndCallRevertName,
e2etests.TestV2ERC20WithdrawAndCallRevertWithCallName,
// e2etests.TestV2ERC20WithdrawAndCallRevertWithCallName, // call on revert disabled
),
)
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/e2etests/e2etests.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ var AllE2ETests = []runner.E2ETest{
TestV2ERC20DepositAndCallName,
"deposit ERC20 into ZEVM and call a contract using V2 contract",
[]runner.ArgDefinition{
{Description: "amount", DefaultValue: "100000"},
{Description: "amount", DefaultValue: "10000000000000000000"},
},
TestV2ERC20DepositAndCall,
),
Expand Down
41 changes: 28 additions & 13 deletions e2e/runner/v2_setup_evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,42 +48,56 @@ func (r *E2ERunner) SetupEVMV2() {
initializerData, err := gatewayEVMABI.Pack("initialize", r.TSSAddress, r.ZetaEthAddr, r.Account.EVMAddress())
require.NoError(r, err)

// Deploy the proxy contract
proxyAddress, txProxy, _, err := erc1967proxy.DeployERC1967Proxy(
// Deploy gateway proxy contract
gatewayProxyAddress, gatewayProxyTx, _, err := erc1967proxy.DeployERC1967Proxy(
r.EVMAuth,
r.EVMClient,
gatewayEVMAddr,
initializerData,
)
require.NoError(r, err)

r.GatewayEVMAddr = proxyAddress
r.GatewayEVM, err = gatewayevm.NewGatewayEVM(proxyAddress, r.EVMClient)
r.GatewayEVMAddr = gatewayProxyAddress
r.GatewayEVM, err = gatewayevm.NewGatewayEVM(gatewayProxyAddress, r.EVMClient)
require.NoError(r, err)
r.Logger.Info("Gateway EVM contract address: %s, tx hash: %s", gatewayEVMAddr.Hex(), txGateway.Hash().Hex())

// Deploy erc20custody proxy contract
r.Logger.Info("Deploying ERC20Custody contract")
erc20CustodyNewAddr, txCustody, erc20CustodyNew, err := erc20custodyv2.DeployERC20Custody(
erc20CustodyAddr, txCustody, _, err := erc20custodyv2.DeployERC20Custody(r.EVMAuth, r.EVMClient)
require.NoError(r, err)

ensureTxReceipt(txCustody, "ERC20Custody deployment failed")

erc20CustodyABI, err := erc20custodyv2.ERC20CustodyMetaData.GetAbi()
require.NoError(r, err)

// Encode the initializer data
initializerData, err = erc20CustodyABI.Pack("initialize", r.GatewayEVMAddr, r.TSSAddress, r.Account.EVMAddress())
require.NoError(r, err)

// Deploy erc20custody proxy contract
erc20CustodyProxyAddress, erc20ProxyTx, _, err := erc1967proxy.DeployERC1967Proxy(
r.EVMAuth,
r.EVMClient,
r.GatewayEVMAddr,
r.TSSAddress,
r.Account.EVMAddress(),
erc20CustodyAddr,
initializerData,
)
require.NoError(r, err)

r.ERC20CustodyV2Addr = erc20CustodyNewAddr
r.ERC20CustodyV2 = erc20CustodyNew
r.ERC20CustodyV2Addr = erc20CustodyProxyAddress
r.ERC20CustodyV2, err = erc20custodyv2.NewERC20Custody(erc20CustodyProxyAddress, r.EVMClient)
require.NoError(r, err)
r.Logger.Info(
"ERC20CustodyV2 contract address: %s, tx hash: %s",
erc20CustodyNewAddr.Hex(),
erc20CustodyAddr.Hex(),
txCustody.Hash().Hex(),
)

ensureTxReceipt(txCustody, "ERC20CustodyV2 deployment failed")

// set custody contract in gateway
txSetCustody, err := r.GatewayEVM.SetCustody(r.EVMAuth, erc20CustodyNewAddr)
txSetCustody, err := r.GatewayEVM.SetCustody(r.EVMAuth, erc20CustodyProxyAddress)
require.NoError(r, err)

// deploy test dapp v2
Expand All @@ -96,7 +110,8 @@ func (r *E2ERunner) SetupEVMV2() {

// check contract deployment receipt
ensureTxReceipt(txDonation, "EVM donation tx failed")
ensureTxReceipt(txProxy, "Gateway proxy deployment failed")
ensureTxReceipt(gatewayProxyTx, "Gateway proxy deployment failed")
ensureTxReceipt(erc20ProxyTx, "ERC20Custody proxy deployment failed")
ensureTxReceipt(txSetCustody, "Set custody in Gateway failed")
ensureTxReceipt(txTestDAppV2, "TestDAppV2 deployment failed")

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/rakyll/statik v0.1.7
github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240819143729-b8229cd7b410
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241016044436-6d90fbcee6fa
google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0
gopkg.in/yaml.v2 v2.4.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1673,8 +1673,8 @@ github.com/zeta-chain/go-tss v0.0.0-20240907163312-b576693642e0 h1:OMuw0XgFcX0RQ
github.com/zeta-chain/go-tss v0.0.0-20240907163312-b576693642e0/go.mod h1:LN1IBRN8xQkKgdgLhl5BDGZyPm70QOTbVLejdS2FVpo=
github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2 h1:gd2uE0X+ZbdFJ8DubxNqLbOVlCB12EgWdzSNRAR82tM=
github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2/go.mod h1:x7Bkwbzt2W2lQfjOirnff0Dj+tykdbTG1FMJPVPZsvE=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240819143729-b8229cd7b410 h1:sBeVX63s/qmfT1KnIKj1Y2SK3PsFpAM/P49ODcD1CN8=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240819143729-b8229cd7b410/go.mod h1:SjT7QirtJE8stnAe1SlNOanxtfSfijJm3MGJ+Ax7w7w=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241016044436-6d90fbcee6fa h1:ArOCSMHwtSTOOLwioo99rffIt7Awag3U7PMLaHFMjn4=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241016044436-6d90fbcee6fa/go.mod h1:SjT7QirtJE8stnAe1SlNOanxtfSfijJm3MGJ+Ax7w7w=
github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U=
github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
Expand Down
2 changes: 1 addition & 1 deletion pkg/contracts/testdappv2/TestDAppV2.abi
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"type": "bytes"
}
],
"name": "onCrossChainCall",
"name": "onCall",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
Expand Down
Loading

0 comments on commit de7cd3d

Please sign in to comment.