diff --git a/test/standardizedToken.js b/test/standardizedToken.js deleted file mode 100644 index 798d3c76..00000000 --- a/test/standardizedToken.js +++ /dev/null @@ -1,95 +0,0 @@ -'use strict'; - -const chai = require('chai'); -const { ethers } = require('hardhat'); -const { - Contract, - utils: { keccak256, toUtf8Bytes }, -} = ethers; -const { expect } = chai; -const { getRandomBytes32, expectRevert, getGasOptions } = require('./utils'); -const { deployContract } = require('../scripts/deploy'); - -const StandardizedToken = require('../artifacts/contracts/token-implementations/StandardizedToken.sol/StandardizedToken.json'); -const StandardizedTokenProxy = require('../artifacts/contracts/proxies/StandardizedTokenProxy.sol/StandardizedTokenProxy.json'); - -describe('StandardizedToken', () => { - let standardizedToken, standardizedTokenDeployer; - - const name = 'tokenName'; - const symbol = 'tokenSymbol'; - const decimals = 18; - const mintAmount = 123; - - let token; - let tokenProxy; - - let owner; - - before(async () => { - const wallets = await ethers.getSigners(); - owner = wallets[0]; - - standardizedToken = await deployContract(owner, 'StandardizedToken'); - standardizedTokenDeployer = await deployContract(owner, 'StandardizedTokenDeployer', [standardizedToken.address]); - - const salt = getRandomBytes32(); - - const tokenAddress = await standardizedTokenDeployer.deployedAddress(salt); - - token = new Contract(tokenAddress, StandardizedToken.abi, owner); - tokenProxy = new Contract(tokenAddress, StandardizedTokenProxy.abi, owner); - - await standardizedTokenDeployer - .deployStandardizedToken(salt, owner.address, owner.address, name, symbol, decimals, mintAmount, owner.address) - .then((tx) => tx.wait()); - }); - - describe('Standardized Token Proxy', () => { - it('should revert if standardized token implementation is invalid', async () => { - const invalidStandardizedToken = await deployContract(owner, 'InvalidStandardizedToken'); - standardizedTokenDeployer = await deployContract(owner, 'StandardizedTokenDeployer', [invalidStandardizedToken.address]); - - const salt = getRandomBytes32(); - - await expect( - standardizedTokenDeployer.deployStandardizedToken( - salt, - owner.address, - owner.address, - name, - symbol, - decimals, - mintAmount, - owner.address, - getGasOptions(), - ), - ).to.be.reverted; - }); - - it('should revert if standardized token setup fails', async () => { - const params = '0x1234'; - await expectRevert( - (gasOptions) => deployContract(owner, 'StandardizedTokenProxy', [standardizedToken.address, params, gasOptions]), - tokenProxy, - 'SetupFailed', - ); - }); - - it('should return the correct contract ID', async () => { - const contractID = await token.contractId(); - const hash = keccak256(toUtf8Bytes('standardized-token')); - expect(contractID).to.equal(hash); - }); - }); - - describe('Standardized Token', () => { - it('revert on setup if not called by the proxy', async () => { - const implementationAddress = await tokenProxy.implementation(); - const implementation = new Contract(implementationAddress, StandardizedToken.abi, owner); - - const params = '0x'; - await expectRevert((gasOptions) => implementation.setup(params, gasOptions), token, 'NotProxy'); - }); - }); -}); diff --git a/test/tokenManager.js b/test/tokenManager.js deleted file mode 100644 index 264d69e6..00000000 --- a/test/tokenManager.js +++ /dev/null @@ -1,119 +0,0 @@ -'use strict'; - -const chai = require('chai'); -const { ethers } = require('hardhat'); -const { - utils: { toUtf8Bytes, defaultAbiCoder }, - constants: { AddressZero }, -} = ethers; -const { expect } = chai; -const { expectRevert } = require('./utils'); -const { deployContract } = require('../scripts/deploy'); - -describe('Token Manager', () => { - let owner, user, token, service, liquidityPool; - let tokenManagerLockUnlock, tokenManagerMintBurn, tokenManagerLiquidityPool, tokenManagerLockUnlockFeeOnTransfer; - - before(async () => { - [owner, user, token, service, liquidityPool] = await ethers.getSigners(); - - tokenManagerLockUnlock = await deployContract(owner, `TokenManagerLockUnlock`, [service.address]); - tokenManagerMintBurn = await deployContract(owner, `TokenManagerMintBurn`, [service.address]); - tokenManagerLiquidityPool = await deployContract(owner, `TokenManagerLiquidityPool`, [service.address]); - tokenManagerLockUnlockFeeOnTransfer = await deployContract(owner, `TokenManagerLockUnlockFee`, [service.address]); - }); - - it('Should revert on token manager deployment with invalid service address', async () => { - await expectRevert( - (gasOptions) => deployContract(owner, `TokenManagerLockUnlock`, [AddressZero, gasOptions]), - tokenManagerLockUnlock, - 'TokenLinkerZeroAddress', - ); - }); - - it('Should revert on setup if not called by the proxy', async () => { - const params = '0x'; - await expectRevert((gasOptions) => tokenManagerLockUnlock.setup(params, gasOptions), tokenManagerLockUnlock, 'NotProxy'); - }); - - it('Should revert on transmitInterchainTransfer if not called by the token', async () => { - const sender = owner.address; - const destinationChain = 'Dest Chain'; - const destinationAddress = toUtf8Bytes(user.address); - const amount = 10; - const metadata = '0x00000000'; - - await expectRevert( - (gasOptions) => - tokenManagerLockUnlock.transmitInterchainTransfer( - sender, - destinationChain, - destinationAddress, - amount, - metadata, - gasOptions, - ), - tokenManagerLockUnlock, - 'NotToken', - ); - }); - - it('Should revert on giveToken if not called by the service', async () => { - const destinationAddress = user.address; - const amount = 10; - - await expectRevert( - (gasOptions) => tokenManagerLockUnlock.giveToken(destinationAddress, amount, gasOptions), - tokenManagerLockUnlock, - 'NotService', - ); - }); - - it('Should revert on takeToken if not called by the service', async () => { - const sourceAddress = user.address; - const amount = 10; - - await expectRevert( - (gasOptions) => tokenManagerLockUnlock.takeToken(sourceAddress, amount, gasOptions), - tokenManagerLockUnlock, - 'NotService', - ); - }); - - it('Should revert on setFlowLimit if not called by the operator', async () => { - const flowLimit = 100; - - await expectRevert( - (gasOptions) => tokenManagerLockUnlock.setFlowLimit(flowLimit, gasOptions), - tokenManagerLockUnlock, - 'NotOperator', - ); - }); - - it('Should return the correct parameters for lock/unlock token manager', async () => { - const expectedParams = defaultAbiCoder.encode(['bytes', 'address'], [toUtf8Bytes(owner.address), token.address]); - const params = await tokenManagerLockUnlock.getParams(toUtf8Bytes(owner.address), token.address); - expect(expectedParams).to.eq(params); - }); - - it('Should return the correct parameters for mint/burn token manager', async () => { - const expectedParams = defaultAbiCoder.encode(['bytes', 'address'], [toUtf8Bytes(owner.address), token.address]); - const params = await tokenManagerMintBurn.getParams(toUtf8Bytes(owner.address), token.address); - expect(expectedParams).to.eq(params); - }); - - it('Should return the correct parameters for liquidity pool token manager', async () => { - const expectedParams = defaultAbiCoder.encode( - ['bytes', 'address', 'address'], - [toUtf8Bytes(owner.address), token.address, liquidityPool.address], - ); - const params = await tokenManagerLiquidityPool.getParams(toUtf8Bytes(owner.address), token.address, liquidityPool.address); - expect(expectedParams).to.eq(params); - }); - - it('Should return the correct parameters for fee on transfer token manager', async () => { - const expectedParams = defaultAbiCoder.encode(['bytes', 'address'], [toUtf8Bytes(owner.address), token.address]); - const params = await tokenManagerLockUnlockFeeOnTransfer.getParams(toUtf8Bytes(owner.address), token.address); - expect(expectedParams).to.eq(params); - }); -});