From 9326241bef64c78c90986cb3d11888220442ec67 Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Sun, 17 Nov 2024 02:21:23 +0700 Subject: [PATCH 1/6] test(its-factory): add upgrade test --- contracts/InterchainTokenFactory.sol | 2 +- test/InterchainTokenFactory.js | 37 +++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) 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..a266ef2a 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.only('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); From c742f5e539b84eb2738be053a883b7e9af4ade3c Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Sun, 17 Nov 2024 04:49:00 +0700 Subject: [PATCH 2/6] remove only --- test/InterchainTokenFactory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/InterchainTokenFactory.js b/test/InterchainTokenFactory.js index a266ef2a..335b2fd6 100644 --- a/test/InterchainTokenFactory.js +++ b/test/InterchainTokenFactory.js @@ -51,7 +51,7 @@ describe('InterchainTokenFactory', () => { }); }); - describe.only('Upgrade', async () => { + describe('Upgrade', async () => { it('Should revert on upgrade from non-owner account', async () => { await expectRevert( (gasOptions) => tokenFactory.connect(otherWallet).upgrade(AddressZero, HashZero, '0x', gasOptions), From 1aad375d1b80b9865ea537ea009ccb35c86b518a Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Sun, 17 Nov 2024 14:58:05 +0700 Subject: [PATCH 3/6] fix coverage action --- .github/workflows/codecov.yaml | 2 +- codecov.yml | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 codecov.yml diff --git a/.github/workflows/codecov.yaml b/.github/workflows/codecov.yaml index 75cbd67d..8e837327 100644 --- a/.github/workflows/codecov.yaml +++ b/.github/workflows/codecov.yaml @@ -41,5 +41,5 @@ jobs: uses: codecov/codecov-action@v3 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..c4525eb0 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,10 @@ +coverage: + status: + project: + default: + target: auto + threshold: 0.25% + patch: + default: + target: auto + threshold: 1% From 4fbbb560a45dd9bcd6ebb31a59d70e8c5a26accd Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Sun, 17 Nov 2024 15:12:22 +0700 Subject: [PATCH 4/6] remove token --- .github/workflows/codecov.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/codecov.yaml b/.github/workflows/codecov.yaml index 8e837327..aeb5a9d3 100644 --- a/.github/workflows/codecov.yaml +++ b/.github/workflows/codecov.yaml @@ -40,6 +40,5 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: - token: ${{ secrets.CODECOV_TOKEN }} files: coverage/lcov.info fail_ci_if_error: true From 914b6be4c0a0ead1e9798141b43388536353e02b Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Sun, 17 Nov 2024 15:14:00 +0700 Subject: [PATCH 5/6] add token back --- .github/workflows/codecov.yaml | 1 + codecov.yml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codecov.yaml b/.github/workflows/codecov.yaml index aeb5a9d3..8e837327 100644 --- a/.github/workflows/codecov.yaml +++ b/.github/workflows/codecov.yaml @@ -40,5 +40,6 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: + token: ${{ secrets.CODECOV_TOKEN }} files: coverage/lcov.info fail_ci_if_error: true diff --git a/codecov.yml b/codecov.yml index c4525eb0..c41479ba 100644 --- a/codecov.yml +++ b/codecov.yml @@ -3,8 +3,8 @@ coverage: project: default: target: auto - threshold: 0.25% + threshold: 0% patch: default: target: auto - threshold: 1% + threshold: 0% From a3a80bc03789f2ed247ba501384e67b1f70bce1a Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Sun, 17 Nov 2024 15:17:10 +0700 Subject: [PATCH 6/6] bump coverage action --- .github/workflows/codecov.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yaml b/.github/workflows/codecov.yaml index 8e837327..e5a7dd9a 100644 --- a/.github/workflows/codecov.yaml +++ b/.github/workflows/codecov.yaml @@ -38,7 +38,7 @@ 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: coverage/lcov.info