Skip to content

Commit

Permalink
test: updated test coverage for InterchainTokenService.sol (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahramy authored Aug 22, 2024
1 parent 498a02b commit 7df851d
Show file tree
Hide file tree
Showing 8 changed files with 446 additions and 189 deletions.
11 changes: 11 additions & 0 deletions contracts/test/utils/TestGatewayCaller.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

contract TestGatewayCaller {
error DelegatecallFailed();

function delegatecall(bytes memory) external pure returns (bool, bytes memory) {
revert DelegatecallFailed();
}
}
17 changes: 8 additions & 9 deletions test/AddressDerivation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ const { approveContractCall } = require('../scripts/utils');
const { getRandomBytes32, getSaltFromKey, isHardhat, getContractJSON } = require('./utils');
const { create3DeployContract } = require('@axelar-network/axelar-gmp-sdk-solidity');
const Token = getContractJSON('TestInterchainTokenStandard');
const MINT_BURN = 0;
const MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN = 1;
const { NATIVE_INTERCHAIN_TOKEN, MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN } = require('./constants');

if (isHardhat) {
describe('Token Address Derivation [ @skip-on-coverage ]', () => {
Expand Down Expand Up @@ -61,7 +60,7 @@ if (isHardhat) {
.to.emit(service, 'InterchainTokenDeployed')
.withArgs(tokenId, expectedTokenAddress, wallet.address, tokenName, tokenSymbol, tokenDecimals)
.to.emit(service, 'TokenManagerDeployed')
.withArgs(tokenId, expectedTokenManagerAddress, MINT_BURN, params);
.withArgs(tokenId, expectedTokenManagerAddress, NATIVE_INTERCHAIN_TOKEN, params);
});

it('Should derive the correct token address for remote interchain token deployment', async () => {
Expand All @@ -84,7 +83,7 @@ if (isHardhat) {
.to.emit(service, 'InterchainTokenDeployed')
.withArgs(tokenId, expectedTokenAddress, minter, tokenName, tokenSymbol, tokenDecimals)
.and.to.emit(service, 'TokenManagerDeployed')
.withArgs(tokenId, expectedTokenManagerAddress, MINT_BURN, params);
.withArgs(tokenId, expectedTokenManagerAddress, NATIVE_INTERCHAIN_TOKEN, params);
});

it('Should derive the correct token address for remote interchain token deployment with empty minter and operator', async () => {
Expand All @@ -107,7 +106,7 @@ if (isHardhat) {
.to.emit(service, 'InterchainTokenDeployed')
.withArgs(tokenId, expectedTokenAddress, AddressZero, tokenName, tokenSymbol, tokenDecimals)
.and.to.emit(service, 'TokenManagerDeployed')
.withArgs(tokenId, expectedTokenManagerAddress, MINT_BURN, params);
.withArgs(tokenId, expectedTokenManagerAddress, NATIVE_INTERCHAIN_TOKEN, params);
});
});

Expand All @@ -127,7 +126,7 @@ if (isHardhat) {
.to.emit(service, 'InterchainTokenDeployed')
.withArgs(tokenId, expectedTokenAddress, tokenFactory.address, tokenName, tokenSymbol, tokenDecimals)
.to.emit(service, 'TokenManagerDeployed')
.withArgs(tokenId, expectedTokenManagerAddress, MINT_BURN, params);
.withArgs(tokenId, expectedTokenManagerAddress, NATIVE_INTERCHAIN_TOKEN, params);
});

it('Should derive the correct token address for remote interchain token deployment', async () => {
Expand All @@ -151,7 +150,7 @@ if (isHardhat) {
.to.emit(service, 'InterchainTokenDeployed')
.withArgs(tokenId, expectedTokenAddress, minter, tokenName, tokenSymbol, tokenDecimals)
.and.to.emit(service, 'TokenManagerDeployed')
.withArgs(tokenId, expectedTokenManagerAddress, MINT_BURN, params);
.withArgs(tokenId, expectedTokenManagerAddress, NATIVE_INTERCHAIN_TOKEN, params);
});

it('Should derive the correct token address for remote interchain token deployment with empty minter and operator', async () => {
Expand All @@ -175,7 +174,7 @@ if (isHardhat) {
.to.emit(service, 'InterchainTokenDeployed')
.withArgs(tokenId, expectedTokenAddress, minter, tokenName, tokenSymbol, tokenDecimals)
.and.to.emit(service, 'TokenManagerDeployed')
.withArgs(tokenId, expectedTokenManagerAddress, MINT_BURN, params);
.withArgs(tokenId, expectedTokenManagerAddress, NATIVE_INTERCHAIN_TOKEN, params);
});

it('Should derive the correct token address for remote canonical token deployment', async () => {
Expand All @@ -198,7 +197,7 @@ if (isHardhat) {
.to.emit(service, 'InterchainTokenDeployed')
.withArgs(tokenId, expectedTokenAddress, minter, tokenName, tokenSymbol, tokenDecimals)
.and.to.emit(service, 'TokenManagerDeployed')
.withArgs(tokenId, expectedTokenManagerAddress, MINT_BURN, params);
.withArgs(tokenId, expectedTokenManagerAddress, NATIVE_INTERCHAIN_TOKEN, params);
});
});
});
Expand Down
19 changes: 9 additions & 10 deletions test/InterchainTokenFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ const {
} = ethers;
const { deployAll, deployContract } = require('../scripts/deploy');
const { getRandomBytes32, expectRevert } = require('./utils');

const MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN = 1;

const LOCK_UNLOCK = 2;
const GATEWAY = 5;
const NATIVE_INTERCHAIN_TOKEN = 0;

const MINTER_ROLE = 0;
const OPERATOR_ROLE = 1;
const FLOW_LIMITER_ROLE = 2;
const {
MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN,
NATIVE_INTERCHAIN_TOKEN,
LOCK_UNLOCK,
GATEWAY,
MINTER_ROLE,
OPERATOR_ROLE,
FLOW_LIMITER_ROLE,
} = require('./constants');

describe('InterchainTokenFactory', () => {
let wallet, otherWallet;
Expand Down
Loading

0 comments on commit 7df851d

Please sign in to comment.