diff --git a/.github/workflows/codecov.yaml b/.github/workflows/codecov.yaml index 75cbd67d..e5a7dd9a 100644 --- a/.github/workflows/codecov.yaml +++ b/.github/workflows/codecov.yaml @@ -38,8 +38,8 @@ jobs: run: npm run coverage - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} - files: lcov.info + files: coverage/lcov.info fail_ci_if_error: true diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..c41479ba --- /dev/null +++ b/codecov.yml @@ -0,0 +1,10 @@ +coverage: + status: + project: + default: + target: auto + threshold: 0% + patch: + default: + target: auto + threshold: 0% diff --git a/contracts/InterchainTokenFactory.sol b/contracts/InterchainTokenFactory.sol index 206d7754..19c7a548 100644 --- a/contracts/InterchainTokenFactory.sol +++ b/contracts/InterchainTokenFactory.sol @@ -55,7 +55,7 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M chainNameHash = interchainTokenService.chainNameHash(); } - function _setup(bytes calldata data) internal override {} + function _setup(bytes calldata /* data */) internal pure override {} /** * @notice Getter for the contract id. diff --git a/test/InterchainTokenFactory.js b/test/InterchainTokenFactory.js index 508142f6..335b2fd6 100644 --- a/test/InterchainTokenFactory.js +++ b/test/InterchainTokenFactory.js @@ -6,7 +6,7 @@ const { ethers } = require('hardhat'); const { getContractAt, Wallet, - constants: { AddressZero }, + constants: { AddressZero, HashZero }, utils: { defaultAbiCoder, keccak256, toUtf8Bytes, arrayify }, } = ethers; const { deployAll, deployContract } = require('../scripts/deploy'); @@ -19,6 +19,7 @@ const { OPERATOR_ROLE, FLOW_LIMITER_ROLE, } = require('./constants'); +const { getBytecodeHash } = require('@axelar-network/axelar-chains-config'); describe('InterchainTokenFactory', () => { let wallet, otherWallet; @@ -50,6 +51,40 @@ describe('InterchainTokenFactory', () => { }); }); + describe('Upgrade', async () => { + it('Should revert on upgrade from non-owner account', async () => { + await expectRevert( + (gasOptions) => tokenFactory.connect(otherWallet).upgrade(AddressZero, HashZero, '0x', gasOptions), + tokenFactory, + 'NotOwner', + ); + }); + + it('Should upgrade the implementation', async () => { + const newImplementation = await deployContract(wallet, 'InterchainTokenFactory', [service.address]); + const newImplementationCodeHash = await getBytecodeHash(newImplementation); + const setupParams = '0x'; + + await expect(tokenFactory.upgrade(newImplementation.address, newImplementationCodeHash, setupParams)) + .to.emit(tokenFactory, 'Upgraded') + .withArgs(newImplementation.address); + + expect(await tokenFactory.implementation()).to.eq(newImplementation.address); + }); + + it('Should upgrade the implementation with setup data', async () => { + const newImplementation = await deployContract(wallet, 'InterchainTokenFactory', [service.address]); + const newImplementationCodeHash = await getBytecodeHash(newImplementation); + const setupParams = '0x1234'; + + await expect(tokenFactory.upgrade(newImplementation.address, newImplementationCodeHash, setupParams)) + .to.emit(tokenFactory, 'Upgraded') + .withArgs(newImplementation.address); + + expect(await tokenFactory.implementation()).to.eq(newImplementation.address); + }); + }); + describe('Canonical Interchain Token Factory', async () => { let token, tokenId, tokenManagerAddress; const tokenCap = BigInt(1e18);