Skip to content

Commit

Permalink
test: refactored code
Browse files Browse the repository at this point in the history
  • Loading branch information
ahramy committed Aug 17, 2024
1 parent e951f2d commit f137a9b
Show file tree
Hide file tree
Showing 9 changed files with 266 additions and 233 deletions.
2 changes: 1 addition & 1 deletion contracts/test/utils/TestGatewayCaller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ pragma solidity ^0.8.0;

contract TestGatewayCaller {
function delegatecall(bytes memory) external pure returns (bool, bytes memory) {
return (false, '');
revert();

Check warning on line 7 in contracts/test/utils/TestGatewayCaller.sol

View workflow job for this annotation

GitHub Actions / lint

Provide an error message for revert

Check warning on line 7 in contracts/test/utils/TestGatewayCaller.sol

View workflow job for this annotation

GitHub Actions / lint

Use Custom Errors instead of revert statements
}
}
16 changes: 7 additions & 9 deletions scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,27 +138,25 @@ async function deployAll(
};
}

async function deployAllWithTestGatewayCaller(
async function deployWithTestGatewayCaller(
wallet,
chainName,
evmChains = [],
gateway,
gasService,
tokenManagerDeployer,
interchainTokenDeployer,
tokenHandler,
deploymentKey = 'InterchainTokenService',
factoryDeploymentKey = deploymentKey + 'Factory',
) {
const create3Deployer = await new ethers.ContractFactory(Create3Deployer.abi, Create3Deployer.bytecode, wallet)
.deploy()
.then((d) => d.deployed());
const gateway = await deployMockGateway(wallet);
const gasService = await deployGasService(wallet);

const interchainTokenServiceAddress = await getCreate3Address(create3Deployer.address, wallet, deploymentKey);
const tokenManagerDeployer = await deployContract(wallet, 'TokenManagerDeployer', []);
const interchainToken = await deployContract(wallet, 'InterchainToken', [interchainTokenServiceAddress]);
const interchainTokenDeployer = await deployContract(wallet, 'InterchainTokenDeployer', [interchainToken.address]);
const tokenManager = await deployContract(wallet, 'TokenManager', [interchainTokenServiceAddress]);
const tokenHandler = await deployContract(wallet, 'TokenHandler', [gateway.address]);
const gatewayCaller = await deployContract(wallet, 'TestGatewayCaller');

const interchainTokenFactoryAddress = await getCreate3Address(create3Deployer.address, wallet, factoryDeploymentKey);

const service = await deployInterchainTokenService(
Expand Down Expand Up @@ -186,5 +184,5 @@ module.exports = {
deployGasService,
deployInterchainTokenService,
deployAll,
deployAllWithTestGatewayCaller,
deployWithTestGatewayCaller,
};
6 changes: 4 additions & 2 deletions test/AddressDerivation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ 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 {
MINT_BURN,
MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN,
} = require('./constants');

if (isHardhat) {
describe('Token Address Derivation [ @skip-on-coverage ]', () => {
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 f137a9b

Please sign in to comment.