Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: test cronos integration [AXE-1916] #249

Merged
merged 10 commits into from
Oct 2, 2023
18 changes: 15 additions & 3 deletions test/AxelarGatewayUpgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('AxelarGatewayUpgrade', () => {

let ownerWallet;
let governanceAddress;
let buffer;

let interchainGovernanceFactory;
let interchainGovernance;
Expand Down Expand Up @@ -70,7 +71,7 @@ describe('AxelarGatewayUpgrade', () => {
});

const deployGateway = async () => {
const buffer = isHardhat ? 10 * 60 * 60 : 10;
buffer = isHardhat ? 10 * 60 * 60 : 10;

const operatorAddresses = getAddresses(operators);

Expand Down Expand Up @@ -163,9 +164,20 @@ describe('AxelarGatewayUpgrade', () => {
sourceEventIndex,
);

await expect(interchainGovernance.execute(commandIdGateway, governanceChain, governanceAddress, payload, getGasOptions()))
const txExecute = await interchainGovernance.execute(
commandIdGateway,
governanceChain,
governanceAddress,
payload,
getGasOptions(),
);
const receiptExecute = await txExecute.wait();
const minimumEta = (await ethers.provider.getBlock(receiptExecute.blockNumber)).timestamp + buffer;
const finalEta = minimumEta > eta ? minimumEta : eta;

await expect(txExecute)
.to.emit(interchainGovernance, 'ProposalScheduled')
.withArgs(proposalHash, target, calldata, nativeValue, eta);
.withArgs(proposalHash, target, calldata, nativeValue, finalEta);

await waitFor(timeDelay);

Expand Down
5 changes: 4 additions & 1 deletion test/BurnableMintableCappedERC20.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ describe('BurnableMintableCappedERC20', () => {
.to.emit(token, 'Transfer')
.withArgs(ethers.constants.AddressZero, user.address, amount);

await token.connect(user).approve(owner.address, MaxUint256);
await token
.connect(user)
.approve(owner.address, MaxUint256)
.then((tx) => tx.wait());

await token.burnFrom(user.address, amount);

Expand Down
53 changes: 36 additions & 17 deletions test/gmp/GeneralMessagePassing.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const chai = require('chai');
const { ethers } = require('hardhat');
const { ethers, network } = require('hardhat');
const {
utils: { defaultAbiCoder, arrayify, keccak256 },
} = ethers;
Expand All @@ -19,6 +19,7 @@ const {
getAddresses,
getChainId,
getWeightedProxyDeployParams,
getGasOptions,
} = require('../utils');

describe('GeneralMessagePassing', () => {
Expand Down Expand Up @@ -97,7 +98,7 @@ describe('GeneralMessagePassing', () => {

const proxy = await gatewayProxyFactory.deploy(gatewayImplementation.address, params).then((d) => d.deployed());

await auth.transferOwnership(proxy.address).then((tx) => tx.wait());
await auth.transferOwnership(proxy.address).then((tx) => tx.wait(network.config.confirmations));

gateway = gatewayFactory.attach(proxy.address);

Expand Down Expand Up @@ -142,12 +143,19 @@ describe('GeneralMessagePassing', () => {
tokenA = await mintableCappedERC20Factory.deploy(nameA, symbolA, decimals, capacity).then((d) => d.deployed());
tokenB = await mintableCappedERC20Factory.deploy(nameB, symbolB, decimals, capacity).then((d) => d.deployed());

await sourceChainGateway.execute(
await getSignedWeightedExecuteInput(await getTokenDeployData(false), [operatorWallet], [1], 1, [operatorWallet]),
);
await destinationChainGateway.execute(
await getSignedWeightedExecuteInput(await getTokenDeployData(true), [operatorWallet], [1], 1, [operatorWallet]),
);
await sourceChainGateway
.execute(
await getSignedWeightedExecuteInput(await getTokenDeployData(false), [operatorWallet], [1], 1, [operatorWallet]),
getGasOptions(),
blockchainguyy marked this conversation as resolved.
Show resolved Hide resolved
)
.then((tx) => tx.wait(network.config.confirmations));

await destinationChainGateway
blockchainguyy marked this conversation as resolved.
Show resolved Hide resolved
.execute(
await getSignedWeightedExecuteInput(await getTokenDeployData(true), [operatorWallet], [1], 1, [operatorWallet]),
getGasOptions(),
)
.then((tx) => tx.wait(network.config.confirmations));

destinationChainTokenSwapper = await destinationChainTokenSwapperFactory
.deploy(tokenA.address, tokenB.address)
Expand All @@ -159,15 +167,22 @@ describe('GeneralMessagePassing', () => {
.deploy(sourceChainGateway.address, sourceChainGasService.address, destinationChain, destinationChainSwapExecutable.address)
.then((d) => d.deployed());

await tokenA.mint(destinationChainGateway.address, 1e9);
await tokenB.mint(destinationChainTokenSwapper.address, 1e9);
await tokenA.mint(destinationChainGateway.address, 1e9).then((tx) => tx.wait(network.config.confirmations));
await tokenB.mint(destinationChainTokenSwapper.address, 1e9).then((tx) => tx.wait(network.config.confirmations));

await sourceChainGateway.execute(
await getSignedWeightedExecuteInput(await getMintData(symbolA, userWallet.address, 1e9), [operatorWallet], [1], 1, [
operatorWallet,
]),
);
await tokenA.connect(ownerWallet).mint(userWallet.address, 1e9);
await sourceChainGateway
.execute(
await getSignedWeightedExecuteInput(await getMintData(symbolA, userWallet.address, 1e9), [operatorWallet], [1], 1, [
operatorWallet,
]),
getGasOptions(),
)
.then((tx) => tx.wait(network.config.confirmations));

await tokenA
.connect(ownerWallet)
.mint(userWallet.address, 1e9)
.then((tx) => tx.wait(network.config.confirmations));
});

describe('general message passing', () => {
Expand All @@ -181,7 +196,9 @@ describe('GeneralMessagePassing', () => {
const sourceChainTokenA = mintableCappedERC20Factory
.attach(await sourceChainGateway.tokenAddresses(symbolA))
.connect(userWallet);
await sourceChainTokenA.approve(sourceChainSwapCaller.address, swapAmount + gasFeeAmount);
await sourceChainTokenA
.approve(sourceChainSwapCaller.address, swapAmount + gasFeeAmount)
.then((tx) => tx.wait(network.config.confirmations));

await expect(
sourceChainSwapCaller
Expand Down Expand Up @@ -242,6 +259,7 @@ describe('GeneralMessagePassing', () => {

const approveExecute = await destinationChainGateway.execute(
await getSignedWeightedExecuteInput(approveWithMintData, [operatorWallet], [1], 1, [operatorWallet]),
getGasOptions(),
);

await expect(approveExecute)
Expand All @@ -265,6 +283,7 @@ describe('GeneralMessagePassing', () => {
payload,
symbolA,
swapAmount,
getGasOptions(),
);

await expect(swap)
Expand Down
Loading