-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(
crosschain
): add support to perform withdraws in ZetaChain `onR…
…evert` call (#3348) * update contracts * add revert and withdraw test * add tx response to revert deposit * process withdraw * tests * add withdraw and revert check in test * comment lint * add tests back * update changelog * add unit tests * fix test * update condition * fix lint
- Loading branch information
Showing
14 changed files
with
454 additions
and
61 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
49 changes: 49 additions & 0 deletions
49
e2e/e2etests/test_eth_withdraw_and_call_revert_with_withdraw.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,49 @@ | ||
package e2etests | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/zeta-chain/protocol-contracts/pkg/gatewayzevm.sol" | ||
|
||
"github.com/zeta-chain/node/e2e/runner" | ||
"github.com/zeta-chain/node/e2e/utils" | ||
crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" | ||
) | ||
|
||
func TestETHWithdrawAndCallRevertWithWithdraw(r *runner.E2ERunner, args []string) { | ||
require.Len(r, args, 1) | ||
|
||
amount := utils.ParseBigInt(r, args[0]) | ||
|
||
r.ApproveETHZRC20(r.GatewayZEVMAddr) | ||
|
||
// perform the withdraw | ||
tx := r.ETHWithdrawAndArbitraryCall( | ||
r.TestDAppV2EVMAddr, | ||
amount, | ||
r.EncodeGasCall("revert"), | ||
gatewayzevm.RevertOptions{ | ||
RevertAddress: r.TestDAppV2ZEVMAddr, | ||
CallOnRevert: true, | ||
RevertMessage: []byte("withdraw"), // call withdraw in the onRevert hook | ||
OnRevertGasLimit: big.NewInt(0), | ||
}, | ||
) | ||
|
||
// wait for the cctx to be mined | ||
cctxRevert := utils.WaitCctxMinedByInboundHash(r.Ctx, tx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout) | ||
r.Logger.CCTX(*cctxRevert, "withdraw") | ||
require.Equal(r, crosschaintypes.CctxStatus_Reverted, cctxRevert.CctxStatus.Status) | ||
|
||
cctxWithdrawFromRevert := utils.WaitCctxMinedByInboundHash( | ||
r.Ctx, | ||
cctxRevert.Index, | ||
r.CctxClient, | ||
r.Logger, | ||
r.CctxTimeout, | ||
) | ||
|
||
// check the cctx status | ||
utils.RequireCCTXStatus(r, cctxWithdrawFromRevert, crosschaintypes.CctxStatus_OutboundMined) | ||
} |
Oops, something went wrong.