From e1aed89eb38fda34bf04f4fcf66898b5ec32b581 Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Mon, 13 Nov 2023 20:18:04 -0500 Subject: [PATCH] refactor: rename test contracts --- contracts/test/InvalidInterchainToken.sol | 91 ------------------- ...enTest.sol => TestBaseInterchainToken.sol} | 2 +- ...kenTest.sol => TestFeeOnTransferToken.sol} | 2 +- ...ntsTest.sol => TestHardCodedConstants.sol} | 13 +-- ...eTest.sol => TestInterchainExecutable.sol} | 2 +- ...est.sol => TestInterchainTokenService.sol} | 2 +- ...ol => TestInvalidInterchainExecutable.sol} | 2 +- ...enManagerTest.sol => TestTokenManager.sol} | 2 +- ...roxyTest.sol => TestTokenManagerProxy.sol} | 2 +- contracts/test/utils/NakedProxy.sol | 33 ------- ...ibutableTest.sol => TestDistributable.sol} | 2 +- .../{FlowLimitTest.sol => TestFlowLimit.sol} | 10 +- ...twork.sol => TestFlowLimitLiveNetwork.sol} | 2 +- ...{OperatableTest.sol => TestOperatable.sol} | 2 +- .../TokenManagerLiquidityPool.sol | 4 +- .../token-manager/TokenManagerLockUnlock.sol | 2 +- docs/index.md | 14 +-- test/InterchainTokenFactory.js | 2 +- test/TokenManager.js | 32 +++---- test/TokenService.js | 38 ++++---- test/TokenServiceUpgradeFlow.js | 2 +- test/UtilsTest.js | 8 +- 22 files changed, 72 insertions(+), 197 deletions(-) delete mode 100644 contracts/test/InvalidInterchainToken.sol rename contracts/test/{BaseInterchainTokenTest.sol => TestBaseInterchainToken.sol} (97%) rename contracts/test/{FeeOnTransferTokenTest.sol => TestFeeOnTransferToken.sol} (97%) rename contracts/test/{HardCodedConstantsTest.sol => TestHardCodedConstants.sol} (62%) rename contracts/test/{InterchainExecutableTest.sol => TestInterchainExecutable.sol} (94%) rename contracts/test/{InterchainTokenServiceTest.sol => TestInterchainTokenService.sol} (92%) rename contracts/test/{InvalidInterchainExecutableTest.sol => TestInvalidInterchainExecutable.sol} (97%) rename contracts/test/{TokenManagerTest.sol => TestTokenManager.sol} (85%) rename contracts/test/{TokenManagerProxyTest.sol => TestTokenManagerProxy.sol} (89%) delete mode 100644 contracts/test/utils/NakedProxy.sol rename contracts/test/utils/{DistributableTest.sol => TestDistributable.sol} (90%) rename contracts/test/utils/{FlowLimitTest.sol => TestFlowLimit.sol} (69%) rename contracts/test/utils/{FlowLimitTestLiveNetwork.sol => TestFlowLimitLiveNetwork.sol} (98%) rename contracts/test/utils/{OperatableTest.sol => TestOperatable.sol} (91%) diff --git a/contracts/test/InvalidInterchainToken.sol b/contracts/test/InvalidInterchainToken.sol deleted file mode 100644 index 9380e3c4..00000000 --- a/contracts/test/InvalidInterchainToken.sol +++ /dev/null @@ -1,91 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.0; - -import { AddressBytes } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/AddressBytes.sol'; -import { Implementation } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/upgradable/Implementation.sol'; - -import { IERC20MintableBurnable } from '../interfaces/IERC20MintableBurnable.sol'; - -import { BaseInterchainToken } from '../interchain-token/BaseInterchainToken.sol'; -import { ERC20Permit } from '../interchain-token/ERC20Permit.sol'; -import { Distributable } from '../utils/Distributable.sol'; - -contract InvalidInterchainToken is IERC20MintableBurnable, BaseInterchainToken, ERC20Permit, Implementation, Distributable { - using AddressBytes for bytes; - - string public name; - string public symbol; - uint8 public decimals; - address internal tokenManager_; - - bytes32 private constant CONTRACT_ID = keccak256('invalid-interchain-token'); - - /** - * @notice Getter for the contract id. - */ - function contractId() external pure returns (bytes32) { - return CONTRACT_ID; - } - - /** - * @notice Returns the token manager for this token - * @return address The token manager contract - */ - function tokenManager() public view override returns (address) { - return tokenManager_; - } - - /** - * @notice Setup function to initialize contract parameters - * @param params The setup parameters in bytes - * The setup params include tokenManager, distributor, tokenName, symbol, decimals, mintAmount and mintTo - */ - function setup(bytes calldata params) external override onlyProxy { - { - address distributor_; - address tokenManagerAddress; - string memory tokenName; - (tokenManagerAddress, distributor_, tokenName, symbol, decimals) = abi.decode( - params, - (address, address, string, string, uint8) - ); - - tokenManager_ = tokenManagerAddress; - name = tokenName; - - _addDistributor(distributor_); - _addDistributor(tokenManagerAddress); - _setNameHash(tokenName); - } - { - uint256 mintAmount; - address mintTo; - (, , , , , mintAmount, mintTo) = abi.decode(params, (address, address, string, string, uint8, uint256, address)); - - if (mintAmount > 0 && mintTo != address(0)) { - _mint(mintTo, mintAmount); - } - } - } - - /** - * @notice Function to mint new tokens - * Can only be called by the distributor address. - * @param account The address that will receive the minted tokens - * @param amount The amount of tokens to mint - */ - function mint(address account, uint256 amount) external onlyRole(uint8(Roles.DISTRIBUTOR)) { - _mint(account, amount); - } - - /** - * @notice Function to burn tokens - * Can only be called by the distributor address. - * @param account The address that will have its tokens burnt - * @param amount The amount of tokens to burn - */ - function burn(address account, uint256 amount) external onlyRole(uint8(Roles.DISTRIBUTOR)) { - _burn(account, amount); - } -} diff --git a/contracts/test/BaseInterchainTokenTest.sol b/contracts/test/TestBaseInterchainToken.sol similarity index 97% rename from contracts/test/BaseInterchainTokenTest.sol rename to contracts/test/TestBaseInterchainToken.sol index 54d69f02..6eefa073 100644 --- a/contracts/test/BaseInterchainTokenTest.sol +++ b/contracts/test/TestBaseInterchainToken.sol @@ -6,7 +6,7 @@ import { BaseInterchainToken } from '../interchain-token/BaseInterchainToken.sol import { Distributable } from '../utils/Distributable.sol'; import { IERC20MintableBurnable } from '../interfaces/IERC20MintableBurnable.sol'; -contract BaseInterchainTokenTest is BaseInterchainToken, Distributable, IERC20MintableBurnable { +contract TestBaseInterchainToken is BaseInterchainToken, Distributable, IERC20MintableBurnable { address public tokenManager_; bool internal tokenManagerRequiresApproval_ = true; string public name; diff --git a/contracts/test/FeeOnTransferTokenTest.sol b/contracts/test/TestFeeOnTransferToken.sol similarity index 97% rename from contracts/test/FeeOnTransferTokenTest.sol rename to contracts/test/TestFeeOnTransferToken.sol index 7983eaab..e22a8b6e 100644 --- a/contracts/test/FeeOnTransferTokenTest.sol +++ b/contracts/test/TestFeeOnTransferToken.sol @@ -6,7 +6,7 @@ import { BaseInterchainToken } from '../interchain-token/BaseInterchainToken.sol import { Distributable } from '../utils/Distributable.sol'; import { IERC20MintableBurnable } from '../interfaces/IERC20MintableBurnable.sol'; -contract FeeOnTransferTokenTest is BaseInterchainToken, Distributable, IERC20MintableBurnable { +contract TestFeeOnTransferToken is BaseInterchainToken, Distributable, IERC20MintableBurnable { address public tokenManager_; bool internal tokenManagerRequiresApproval_ = true; diff --git a/contracts/test/HardCodedConstantsTest.sol b/contracts/test/TestHardCodedConstants.sol similarity index 62% rename from contracts/test/HardCodedConstantsTest.sol rename to contracts/test/TestHardCodedConstants.sol index eb80c612..47c59bb7 100644 --- a/contracts/test/HardCodedConstantsTest.sol +++ b/contracts/test/TestHardCodedConstants.sol @@ -4,24 +4,15 @@ pragma solidity ^0.8.0; import { TokenManagerLiquidityPool } from '../token-manager/TokenManagerLiquidityPool.sol'; -import { FlowLimit } from '../utils/FlowLimit.sol'; import { InterchainToken } from '../interchain-token/InterchainToken.sol'; error Invalid(); -contract TestTokenManager is TokenManagerLiquidityPool { +contract TestTokenManagerLiquidityPool is TokenManagerLiquidityPool { string public placeholder; constructor(address interchainTokenService_) TokenManagerLiquidityPool(interchainTokenService_) { - if (LIQUIDITY_POOL_SLOT != uint256(keccak256('liquidity-pool-slot')) - 1) revert Invalid(); - } -} - -contract TestFlowLimit is FlowLimit { - string public placeholder; - - constructor() { - if (FLOW_LIMIT_SLOT != uint256(keccak256('flow-limit')) - 1) revert Invalid(); + if (LIQUIDITY_POOL_SLOT != bytes32(uint256(keccak256('liquidity-pool')) - 1)) revert Invalid(); } } diff --git a/contracts/test/InterchainExecutableTest.sol b/contracts/test/TestInterchainExecutable.sol similarity index 94% rename from contracts/test/InterchainExecutableTest.sol rename to contracts/test/TestInterchainExecutable.sol index 9902700c..7fcba147 100644 --- a/contracts/test/InterchainExecutableTest.sol +++ b/contracts/test/TestInterchainExecutable.sol @@ -5,7 +5,7 @@ pragma solidity ^0.8.0; import { InterchainTokenExpressExecutable } from '../executable/InterchainTokenExpressExecutable.sol'; import { IERC20 } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IERC20.sol'; -contract InterchainExecutableTest is InterchainTokenExpressExecutable { +contract TestInterchainExecutable is InterchainTokenExpressExecutable { event MessageReceived(string sourceChain, bytes sourceAddress, address receiver, string message, bytes32 tokenId, uint256 amount); constructor(address interchainTokenService_) InterchainTokenExpressExecutable(interchainTokenService_) {} diff --git a/contracts/test/InterchainTokenServiceTest.sol b/contracts/test/TestInterchainTokenService.sol similarity index 92% rename from contracts/test/InterchainTokenServiceTest.sol rename to contracts/test/TestInterchainTokenService.sol index 112c5c0a..3f5274d0 100644 --- a/contracts/test/InterchainTokenServiceTest.sol +++ b/contracts/test/TestInterchainTokenService.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import { InterchainTokenService } from '../InterchainTokenService.sol'; -contract InterchainTokenServiceTest is InterchainTokenService { +contract TestInterchainTokenService is InterchainTokenService { constructor( address tokenManagerDeployer_, address interchainTokenDeployer_, diff --git a/contracts/test/InvalidInterchainExecutableTest.sol b/contracts/test/TestInvalidInterchainExecutable.sol similarity index 97% rename from contracts/test/InvalidInterchainExecutableTest.sol rename to contracts/test/TestInvalidInterchainExecutable.sol index 9e3298a2..7dfbb402 100644 --- a/contracts/test/InvalidInterchainExecutableTest.sol +++ b/contracts/test/TestInvalidInterchainExecutable.sol @@ -7,7 +7,7 @@ import { InterchainTokenExecutable } from '../executable/InterchainTokenExecutab import { InterchainTokenExpressExecutable } from '../executable/InterchainTokenExpressExecutable.sol'; import { IERC20 } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IERC20.sol'; -contract InvalidInterchainExecutableTest is InterchainTokenExpressExecutable { +contract TestInvalidInterchainExecutable is InterchainTokenExpressExecutable { bytes32 internal constant EXECUTE_FAILURE = keccak256('its-express-execute-failure'); bytes32 internal constant EXPRESS_EXECUTE_FAILURE = keccak256('its-express-execute-failure'); diff --git a/contracts/test/TokenManagerTest.sol b/contracts/test/TestTokenManager.sol similarity index 85% rename from contracts/test/TokenManagerTest.sol rename to contracts/test/TestTokenManager.sol index b715e62a..f8892a1c 100644 --- a/contracts/test/TokenManagerTest.sol +++ b/contracts/test/TestTokenManager.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import { TokenManagerLockUnlock } from '../token-manager/TokenManagerLockUnlock.sol'; -contract TokenManagerTest is TokenManagerLockUnlock { +contract TestTokenManager is TokenManagerLockUnlock { constructor(address service) TokenManagerLockUnlock(service) {} function addOperator(address operator) external { diff --git a/contracts/test/TokenManagerProxyTest.sol b/contracts/test/TestTokenManagerProxy.sol similarity index 89% rename from contracts/test/TokenManagerProxyTest.sol rename to contracts/test/TestTokenManagerProxy.sol index 3d776668..e5c2ea54 100644 --- a/contracts/test/TokenManagerProxyTest.sol +++ b/contracts/test/TestTokenManagerProxy.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import { TokenManagerProxy } from '../proxies/TokenManagerProxy.sol'; -contract TokenManagerProxyTest is TokenManagerProxy { +contract TestTokenManagerProxy is TokenManagerProxy { constructor( address interchainTokenService_, uint256 implementationType_, diff --git a/contracts/test/utils/NakedProxy.sol b/contracts/test/utils/NakedProxy.sol deleted file mode 100644 index 0c75fdaa..00000000 --- a/contracts/test/utils/NakedProxy.sol +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.0; - -contract NakedProxy { - address public immutable implementation; - - constructor(address implementation_) { - implementation = implementation_; - } - - // solhint-disable-next-line no-complex-fallback - fallback() external payable virtual { - address implementation_ = implementation; - - assembly { - calldatacopy(0, 0, calldatasize()) - - let result := delegatecall(gas(), implementation_, 0, calldatasize(), 0, 0) - returndatacopy(0, 0, returndatasize()) - - switch result - case 0 { - revert(0, returndatasize()) - } - default { - return(0, returndatasize()) - } - } - } - - receive() external payable virtual {} -} diff --git a/contracts/test/utils/DistributableTest.sol b/contracts/test/utils/TestDistributable.sol similarity index 90% rename from contracts/test/utils/DistributableTest.sol rename to contracts/test/utils/TestDistributable.sol index 5a654166..22d607ad 100644 --- a/contracts/test/utils/DistributableTest.sol +++ b/contracts/test/utils/TestDistributable.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import { Distributable } from '../../utils/Distributable.sol'; -contract DistributableTest is Distributable { +contract TestDistributable is Distributable { uint256 public nonce; constructor(address distributor) { diff --git a/contracts/test/utils/FlowLimitTest.sol b/contracts/test/utils/TestFlowLimit.sol similarity index 69% rename from contracts/test/utils/FlowLimitTest.sol rename to contracts/test/utils/TestFlowLimit.sol index 57b5af2a..3e1bc8db 100644 --- a/contracts/test/utils/FlowLimitTest.sol +++ b/contracts/test/utils/TestFlowLimit.sol @@ -4,9 +4,17 @@ pragma solidity ^0.8.0; import { FlowLimit } from '../../utils/FlowLimit.sol'; -contract FlowLimitTest is FlowLimit { +contract TestFlowLimit is FlowLimit { + error Invalid(); + bytes32 public constant TOKEN_ID = 0x0; + string public placeholder; + + constructor() { + if (FLOW_LIMIT_SLOT != uint256(keccak256('flow-limit')) - 1) revert Invalid(); + } + function setFlowLimit(uint256 flowLimit) external { _setFlowLimit(flowLimit, TOKEN_ID); } diff --git a/contracts/test/utils/FlowLimitTestLiveNetwork.sol b/contracts/test/utils/TestFlowLimitLiveNetwork.sol similarity index 98% rename from contracts/test/utils/FlowLimitTestLiveNetwork.sol rename to contracts/test/utils/TestFlowLimitLiveNetwork.sol index 4d366015..e38334bf 100644 --- a/contracts/test/utils/FlowLimitTestLiveNetwork.sol +++ b/contracts/test/utils/TestFlowLimitLiveNetwork.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import { IFlowLimit } from '../../interfaces/IFlowLimit.sol'; -contract FlowLimitTestLiveNetwork is IFlowLimit { +contract TestFlowLimitLiveNetwork is IFlowLimit { uint256 internal constant FLOW_LIMIT_SLOT = 0x201b7a0b7c19aaddc4ce9579b7df8d2db123805861bc7763627f13e04d8af42f; uint256 internal constant PREFIX_FLOW_OUT_AMOUNT = uint256(keccak256('flow-out-amount')); uint256 internal constant PREFIX_FLOW_IN_AMOUNT = uint256(keccak256('flow-in-amount')); diff --git a/contracts/test/utils/OperatableTest.sol b/contracts/test/utils/TestOperatable.sol similarity index 91% rename from contracts/test/utils/OperatableTest.sol rename to contracts/test/utils/TestOperatable.sol index d2455a74..5781711b 100644 --- a/contracts/test/utils/OperatableTest.sol +++ b/contracts/test/utils/TestOperatable.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import { Operatable } from '../../utils/Operatable.sol'; -contract OperatableTest is Operatable { +contract TestOperatable is Operatable { uint256 public nonce; constructor(address operator) { diff --git a/contracts/token-manager/TokenManagerLiquidityPool.sol b/contracts/token-manager/TokenManagerLiquidityPool.sol index a9b45eec..81f26e08 100644 --- a/contracts/token-manager/TokenManagerLiquidityPool.sol +++ b/contracts/token-manager/TokenManagerLiquidityPool.sol @@ -22,8 +22,8 @@ contract TokenManagerLiquidityPool is TokenManager, ReentrancyGuard, ITokenManag error NotSupported(); - // uint256(keccak256('liquidity-pool-slot')) - 1 - uint256 internal constant LIQUIDITY_POOL_SLOT = 0x8e02741a3381812d092c5689c9fc701c5185c1742fdf7954c4c4472be4cc4807; + // bytes32(uint256(keccak256('liquidity-pool')) - 1); + bytes32 internal constant LIQUIDITY_POOL_SLOT = 0x6b96d20becbf90996c525d678f980ffe6dec77fdb9e37d175b3726d4dcebc2c1; /** * @dev Constructs an instance of TokenManagerLiquidityPool. Calls the constructor diff --git a/contracts/token-manager/TokenManagerLockUnlock.sol b/contracts/token-manager/TokenManagerLockUnlock.sol index c655dea6..30f50fab 100644 --- a/contracts/token-manager/TokenManagerLockUnlock.sol +++ b/contracts/token-manager/TokenManagerLockUnlock.sol @@ -5,7 +5,7 @@ pragma solidity ^0.8.0; import { IERC20 } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IERC20.sol'; import { SafeTokenTransfer, SafeTokenTransferFrom, SafeTokenCall } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/SafeTransfer.sol'; -import { ITokenManagerLockUnlock } from '..//interfaces/ITokenManagerLockUnlock.sol'; +import { ITokenManagerLockUnlock } from '../interfaces/ITokenManagerLockUnlock.sol'; import { TokenManager } from './TokenManager.sol'; /** diff --git a/docs/index.md b/docs/index.md index e43d387f..1806eb3e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3310,7 +3310,7 @@ _Returns the implementation address from the interchain token service for the pr | ---- | ---- | ----------- | | implementation_ | address | The address of the implementation | -## FeeOnTransferTokenTest +## TestFeeOnTransferToken ### tokenManager_ @@ -3475,7 +3475,7 @@ string NAME constructor() public ``` -## InterchainExecutableTest +## TestInterchainExecutable ### MessageReceived @@ -3501,7 +3501,7 @@ string lastMessage function _executeWithInterchainToken(string sourceChain, bytes sourceAddress, bytes data, bytes32 tokenId, address token, uint256 amount) internal ``` -## BaseInterchainTokenTest +## TestBaseInterchainToken ### tokenManager_ @@ -3585,7 +3585,7 @@ function burn(address account, uint256 amount) external function setTokenManager(address tokenManagerAddress) external ``` -## DistributableTest +## TestDistributable ### nonce @@ -3611,7 +3611,7 @@ function testDistributable() external function distributorRole() external pure returns (uint8) ``` -## FlowLimitTest +## TestFlowLimit ### TOKEN_ID @@ -3637,7 +3637,7 @@ function addFlowIn(uint256 flowInAmount) external function addFlowOut(uint256 flowOutAmount) external ``` -## FlowLimitTestLiveNetwork +## TestFlowLimitLiveNetwork ### FLOW_LIMIT_SLOT @@ -3791,7 +3791,7 @@ fallback() external payable virtual receive() external payable virtual ``` -## OperatableTest +## TestOperatable ### nonce diff --git a/test/InterchainTokenFactory.js b/test/InterchainTokenFactory.js index 0ff2ec3e..0d877eb8 100644 --- a/test/InterchainTokenFactory.js +++ b/test/InterchainTokenFactory.js @@ -53,7 +53,7 @@ describe('InterchainTokenFactory', () => { const tokenCap = BigInt(1e18); async function deployToken() { - token = await deployContract(wallet, 'BaseInterchainTokenTest', [name, symbol, decimals, wallet.address]); + token = await deployContract(wallet, 'TestBaseInterchainToken', [name, symbol, decimals, wallet.address]); tokenId = await tokenFactory.canonicalInterchainTokenId(token.address); tokenManagerAddress = await service.tokenManagerAddress(tokenId); await (await token.mint(wallet.address, tokenCap)).wait(); diff --git a/test/TokenManager.js b/test/TokenManager.js index 8939bcc5..583f8aed 100644 --- a/test/TokenManager.js +++ b/test/TokenManager.js @@ -14,38 +14,38 @@ const { deployContract, deployAll } = require('../scripts/deploy'); describe('Token Manager', () => { const FLOW_LIMITER_ROLE = 2; let owner, user, token, service; - let tokenManagerTest, tokenManagerLockUnlock, tokenManagerMintBurn, tokenManagerLockUnlockFeeOnTransfer; + let TestTokenManager, tokenManagerLockUnlock, tokenManagerMintBurn, tokenManagerLockUnlockFeeOnTransfer; before(async () => { [owner, user, token, service] = await ethers.getSigners(); - tokenManagerTest = await deployContract(owner, `TokenManagerTest`, [service.address]); + TestTokenManager = await deployContract(owner, `TestTokenManager`, [service.address]); tokenManagerLockUnlock = await deployContract(owner, `TokenManagerLockUnlock`, [service.address]); tokenManagerMintBurn = await deployContract(owner, `TokenManagerMintBurn`, [service.address]); tokenManagerLockUnlockFeeOnTransfer = await deployContract(owner, `TokenManagerLockUnlockFee`, [service.address]); }); it('Should calculate hardcoded constants correctly', async () => { - await expect(deployContract(owner, `TestTokenManager`, [service.address])).to.not.be.reverted; + await expect(deployContract(owner, `TestTokenManagerLiquidityPool`, [service.address])).to.not.be.reverted; }); it('Should revert on token manager deployment with invalid service address', async () => { await expectRevert( - (gasOptions) => deployContract(owner, `TokenManagerTest`, [AddressZero, gasOptions]), - tokenManagerTest, + (gasOptions) => deployContract(owner, `TestTokenManager`, [AddressZero, gasOptions]), + TestTokenManager, 'TokenLinkerZeroAddress', ); }); it('Should return the correct contract id', async () => { const expectedContractid = keccak256(toUtf8Bytes('token-manager')); - const contractId = await tokenManagerTest.contractId(); + const contractId = await TestTokenManager.contractId(); expect(contractId).to.eq(expectedContractid); }); it('Should revert on setup if not called by the proxy', async () => { const params = '0x'; - await expectRevert((gasOptions) => tokenManagerTest.setup(params, gasOptions), tokenManagerTest, 'NotProxy'); + await expectRevert((gasOptions) => TestTokenManager.setup(params, gasOptions), TestTokenManager, 'NotProxy'); }); it('Should revert on transmitInterchainTransfer if not called by the token', async () => { @@ -78,8 +78,8 @@ describe('Token Manager', () => { const amount = 10; await expectRevert( - (gasOptions) => tokenManagerTest.giveToken(destinationAddress, amount, gasOptions), - tokenManagerTest, + (gasOptions) => TestTokenManager.giveToken(destinationAddress, amount, gasOptions), + TestTokenManager, 'NotService', [owner.address], ); @@ -89,7 +89,7 @@ describe('Token Manager', () => { const sourceAddress = user.address; const amount = 10; - await expectRevert((gasOptions) => tokenManagerTest.takeToken(sourceAddress, amount, gasOptions), tokenManagerTest, 'NotService', [ + await expectRevert((gasOptions) => TestTokenManager.takeToken(sourceAddress, amount, gasOptions), TestTokenManager, 'NotService', [ owner.address, ]); }); @@ -97,24 +97,24 @@ describe('Token Manager', () => { it('Should revert on setFlowLimit if not called by the operator', async () => { const flowLimit = 100; - await expectRevert((gasOptions) => tokenManagerTest.setFlowLimit(flowLimit, gasOptions), tokenManagerTest, 'MissingRole', [ + await expectRevert((gasOptions) => TestTokenManager.setFlowLimit(flowLimit, gasOptions), TestTokenManager, 'MissingRole', [ owner.address, FLOW_LIMITER_ROLE, ]); }); it('Should revert on addFlowLimiter if flow limiter address is invalid', async () => { - await tokenManagerTest.addOperator(owner.address).then((tx) => tx.wait()); + await TestTokenManager.addOperator(owner.address).then((tx) => tx.wait()); - await expectRevert((gasOptions) => tokenManagerTest.addFlowLimiter(AddressZero, gasOptions), tokenManagerTest, 'ZeroAddress', []); + await expectRevert((gasOptions) => TestTokenManager.addFlowLimiter(AddressZero, gasOptions), TestTokenManager, 'ZeroAddress', []); }); it('Should revert on removeFlowLimiter if flow limiter address is invalid', async () => { - await tokenManagerTest.addOperator(owner.address).then((tx) => tx.wait()); + await TestTokenManager.addOperator(owner.address).then((tx) => tx.wait()); await expectRevert( - (gasOptions) => tokenManagerTest.removeFlowLimiter(AddressZero, gasOptions), - tokenManagerTest, + (gasOptions) => TestTokenManager.removeFlowLimiter(AddressZero, gasOptions), + TestTokenManager, 'ZeroAddress', [], ); diff --git a/test/TokenService.js b/test/TokenService.js index d7798ee0..b81074a9 100644 --- a/test/TokenService.js +++ b/test/TokenService.js @@ -56,7 +56,7 @@ describe('Interchain Token Service', () => { const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManager = await getContractAt('TokenManager', await service.tokenManagerAddress(tokenId), wallet); - const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + const token = await deployContract(wallet, 'TestBaseInterchainToken', [ tokenName, tokenSymbol, tokenDecimals, @@ -85,7 +85,7 @@ describe('Interchain Token Service', () => { const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManager = await getContractAt('TokenManager', await service.tokenManagerAddress(tokenId), wallet); - const token = await deployContract(wallet, 'FeeOnTransferTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManager.address]); + const token = await deployContract(wallet, 'TestFeeOnTransferToken', [tokenName, tokenSymbol, tokenDecimals, tokenManager.address]); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); @@ -107,7 +107,7 @@ describe('Interchain Token Service', () => { const salt = getRandomBytes32(); const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + const token = await deployContract(wallet, 'TestBaseInterchainToken', [ tokenName, tokenSymbol, tokenDecimals, @@ -137,7 +137,7 @@ describe('Interchain Token Service', () => { otherWallet = wallets[1]; [service, gateway, gasService] = await deployAll(wallet, 'Test', [sourceChain, destinationChain]); - testToken = await deployContract(wallet, 'BaseInterchainTokenTest', ['Test Token', 'TST', 18, wallet.address]); + testToken = await deployContract(wallet, 'TestBaseInterchainToken', ['Test Token', 'TST', 18, wallet.address]); }); describe('Interchain Token Service Deployment', () => { @@ -170,7 +170,7 @@ describe('Interchain Token Service', () => { }); it('Should test setup revert cases', async () => { - const serviceTest = await deployContract(wallet, 'InterchainTokenServiceTest', [ + const serviceTest = await deployContract(wallet, 'TestInterchainTokenService', [ tokenManagerDeployer.address, interchainTokenDeployer.address, gateway.address, @@ -448,7 +448,7 @@ describe('Interchain Token Service', () => { const salt = getRandomBytes32(); const tokenId = await service.interchainTokenId(wallet.address, salt); const validParams = defaultAbiCoder.encode(['bytes', 'address'], ['0x', interchainToken.address]); - const tokenManagerProxy = await deployContract(wallet, `TokenManagerProxyTest`, [ + const tokenManagerProxy = await deployContract(wallet, `TestTokenManagerProxy`, [ service.address, MINT_BURN, tokenId, @@ -793,7 +793,7 @@ describe('Interchain Token Service', () => { const salt = getRandomBytes32(); const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + const token = await deployContract(wallet, 'TestBaseInterchainToken', [ tokenName, tokenSymbol, tokenDecimals, @@ -821,7 +821,7 @@ describe('Interchain Token Service', () => { const salt = getRandomBytes32(); const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + const token = await deployContract(wallet, 'TestBaseInterchainToken', [ tokenName, tokenSymbol, tokenDecimals, @@ -849,7 +849,7 @@ describe('Interchain Token Service', () => { const salt = getRandomBytes32(); const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + const token = await deployContract(wallet, 'TestBaseInterchainToken', [ tokenName, tokenSymbol, tokenDecimals, @@ -879,7 +879,7 @@ describe('Interchain Token Service', () => { const salt = getRandomBytes32(); const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'FeeOnTransferTokenTest', [ + const token = await deployContract(wallet, 'TestFeeOnTransferToken', [ tokenName, tokenSymbol, tokenDecimals, @@ -909,7 +909,7 @@ describe('Interchain Token Service', () => { const salt = getRandomBytes32(); const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + const token = await deployContract(wallet, 'TestBaseInterchainToken', [ tokenName, tokenSymbol, tokenDecimals, @@ -940,7 +940,7 @@ describe('Interchain Token Service', () => { const salt = getRandomBytes32(); const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + const token = await deployContract(wallet, 'TestBaseInterchainToken', [ tokenName, tokenSymbol, tokenDecimals, @@ -1116,7 +1116,7 @@ describe('Interchain Token Service', () => { const tokenDecimals = 13; const tokenId = getRandomBytes32(); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + const token = await deployContract(wallet, 'TestBaseInterchainToken', [ tokenName, tokenSymbol, tokenDecimals, @@ -1145,7 +1145,7 @@ describe('Interchain Token Service', () => { const tokenDecimals = 13; const tokenId = getRandomBytes32(); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + const token = await deployContract(wallet, 'TestBaseInterchainToken', [ tokenName, tokenSymbol, tokenDecimals, @@ -1512,8 +1512,8 @@ describe('Interchain Token Service', () => { before(async () => { sourceAddress = service.address; - executable = await deployContract(wallet, 'InterchainExecutableTest', [service.address]); - invalidExecutable = await deployContract(wallet, 'InvalidInterchainExecutableTest', [service.address]); + executable = await deployContract(wallet, 'TestInterchainExecutable', [service.address]); + invalidExecutable = await deployContract(wallet, 'TestInvalidInterchainExecutable', [service.address]); destAddress = executable.address; }); @@ -1769,8 +1769,8 @@ describe('Interchain Token Service', () => { [token, , tokenId] = await deployFunctions.lockUnlock(tokenName, tokenSymbol, tokenDecimals, amount * 2, true); await (await token.approve(service.address, amount * 2)).wait(); data = defaultAbiCoder.encode(['address', 'string'], [destinationAddress, message]); - executable = await deployContract(wallet, 'InterchainExecutableTest', [service.address]); - invalidExecutable = await deployContract(wallet, 'InvalidInterchainExecutableTest', [service.address]); + executable = await deployContract(wallet, 'TestInterchainExecutable', [service.address]); + invalidExecutable = await deployContract(wallet, 'TestInvalidInterchainExecutable', [service.address]); }); it('Should revert on executeWithInterchainToken when not called by the service', async () => { @@ -1980,7 +1980,7 @@ describe('Interchain Token Service', () => { before(async () => { sourceAddress = service.address; - executable = await deployContract(wallet, 'InterchainExecutableTest', [service.address]); + executable = await deployContract(wallet, 'TestInterchainExecutable', [service.address]); destAddress = executable.address; }); diff --git a/test/TokenServiceUpgradeFlow.js b/test/TokenServiceUpgradeFlow.js index a8dd2ac2..3502e80c 100644 --- a/test/TokenServiceUpgradeFlow.js +++ b/test/TokenServiceUpgradeFlow.js @@ -48,7 +48,7 @@ describe('Interchain Token Service Upgrade Flow', () => { const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManager = await getContractAt('TokenManager', await service.tokenManagerAddress(tokenId), wallet); - const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + const token = await deployContract(wallet, 'TestBaseInterchainToken', [ tokenName, tokenSymbol, tokenDecimals, diff --git a/test/UtilsTest.js b/test/UtilsTest.js index 68eeb416..1a94dd3f 100644 --- a/test/UtilsTest.js +++ b/test/UtilsTest.js @@ -25,7 +25,7 @@ describe('Operatable', () => { let operatorRole; before(async () => { - test = await deployContract(ownerWallet, 'OperatableTest', [ownerWallet.address]); + test = await deployContract(ownerWallet, 'TestOperatable', [ownerWallet.address]); operatorRole = await test.operatorRole(); }); @@ -99,7 +99,7 @@ describe('Distributable', () => { let distributorRole; before(async () => { - test = await deployContract(ownerWallet, 'DistributableTest', [ownerWallet.address]); + test = await deployContract(ownerWallet, 'TestDistributable', [ownerWallet.address]); distributorRole = await test.distributorRole(); }); @@ -172,8 +172,8 @@ describe('FlowLimit', async () => { before(async () => { test = isHardhat - ? await deployContract(ownerWallet, 'FlowLimitTest') - : await deployContract(ownerWallet, 'FlowLimitTestLiveNetwork'); + ? await deployContract(ownerWallet, 'TestFlowLimit') + : await deployContract(ownerWallet, 'TestFlowLimitLiveNetwork'); tokenId = await test.TOKEN_ID(); });