From 209f088d262072a21cc52d27b7484a567a0e0b75 Mon Sep 17 00:00:00 2001 From: Hareesh Nagaraj Date: Mon, 1 Aug 2022 18:27:31 +0000 Subject: [PATCH 1/3] New test case --- eth-contracts/test/audiusToken.test.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/eth-contracts/test/audiusToken.test.js b/eth-contracts/test/audiusToken.test.js index a11d831b431..51391569aee 100644 --- a/eth-contracts/test/audiusToken.test.js +++ b/eth-contracts/test/audiusToken.test.js @@ -3,7 +3,7 @@ import * as _signatures from '../utils/signatures.js' const tokenRegKey = web3.utils.utf8ToHex('Token') -contract('AudiusToken', async (accounts) => { +contract.only('AudiusToken', async (accounts) => { let registry, token, governance // expected initial token values @@ -96,7 +96,7 @@ contract('AudiusToken', async (accounts) => { assert.equal(await token.balanceOf(tokenOwnerAddress), INITIAL_SUPPLY - amount) assert.equal(await token.balanceOf(account), amount) assert.equal(await token.totalSupply(), INITIAL_SUPPLY) - + // Decrease total supply by burning from account await token.approve(tokenOwnerAddress, amount, { from: account }) await token.burnFrom(account, amount, { from: tokenOwnerAddress }) @@ -231,6 +231,18 @@ contract('AudiusToken', async (accounts) => { ) }) + it.only('Confirm token reinitialization', async () => { + console.log('Verifying reinitialization') + const fakeGovernance = accounts[12] + const tokenInitData = _lib.encodeCall( + 'initialize', + ['address', 'address'], + [proxyDeployerAddress, fakeGovernance] + ) + await token.initialize(proxyDeployerAddress, fakeGovernance) + // await token.initialize(proxyDeployerAddress, fakeGovernance) + }) + describe('EIP-2612', async function () { it('Confirm typehashes match for permit function', async () => { const chainId = 1 // in ganache, the chain ID the token initializes with is always 1 From eab6a6307ed20e2b1b54d19f71461853cb70ea70 Mon Sep 17 00:00:00 2001 From: Hareesh Nagaraj Date: Tue, 2 Aug 2022 18:33:01 +0000 Subject: [PATCH 2/3] Verification tests --- eth-contracts/test/audiusToken.test.js | 15 +++++---------- eth-contracts/test/delegateManagerV2.test.js | 7 +++++++ eth-contracts/test/governance.test.js | 7 +++++++ eth-contracts/test/staking.test.js | 7 +++++++ 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/eth-contracts/test/audiusToken.test.js b/eth-contracts/test/audiusToken.test.js index 51391569aee..edf39f242a3 100644 --- a/eth-contracts/test/audiusToken.test.js +++ b/eth-contracts/test/audiusToken.test.js @@ -3,7 +3,7 @@ import * as _signatures from '../utils/signatures.js' const tokenRegKey = web3.utils.utf8ToHex('Token') -contract.only('AudiusToken', async (accounts) => { +contract('AudiusToken', async (accounts) => { let registry, token, governance // expected initial token values @@ -231,16 +231,11 @@ contract.only('AudiusToken', async (accounts) => { ) }) - it.only('Confirm token reinitialization', async () => { - console.log('Verifying reinitialization') - const fakeGovernance = accounts[12] - const tokenInitData = _lib.encodeCall( - 'initialize', - ['address', 'address'], - [proxyDeployerAddress, fakeGovernance] + it('Confirm token reinitialization fails', async () => { + await _lib.assertRevert( + token.initialize(proxyDeployerAddress, accounts[13]), + 'Contract instance has already been initialized' ) - await token.initialize(proxyDeployerAddress, fakeGovernance) - // await token.initialize(proxyDeployerAddress, fakeGovernance) }) describe('EIP-2612', async function () { diff --git a/eth-contracts/test/delegateManagerV2.test.js b/eth-contracts/test/delegateManagerV2.test.js index 52aeffa7817..dd8ddcaffc1 100644 --- a/eth-contracts/test/delegateManagerV2.test.js +++ b/eth-contracts/test/delegateManagerV2.test.js @@ -521,6 +521,13 @@ contract('DelegateManagerV2', async (accounts) => { assert.isTrue((info.deployerCut).eq(_lib.toBN(updatedCut)), 'Expect updated cut') }) + it('Confirm DelegateManagerV2 fails reinitialization', async () => { + await _lib.assertRevert( + delegateManager.initialize(token.address, governance.address, UNDELEGATE_LOCKUP_DURATION), + 'Contract instance has already been initialized' + ) + }) + it('Initial state + claim', async () => { // Validate basic claim w/SP path let spStake = (await serviceProviderFactory.getServiceProviderDetails(stakerAccount)).deployerStake diff --git a/eth-contracts/test/governance.test.js b/eth-contracts/test/governance.test.js index 0df631eacc2..59a3f0be9e4 100644 --- a/eth-contracts/test/governance.test.js +++ b/eth-contracts/test/governance.test.js @@ -313,6 +313,13 @@ contract('Governance.sol', async (accounts) => { ) }) + it('Confirm governance fails reinitialization', async () => { + await _lib.assertRevert( + governance.initialize(registry.address, 0, 0, 0, 10, accounts[14]), + 'Contract instance has already been initialized' + ) + }) + it('Initialize require statements', async function () { const governance0 = await Governance.new({ from: proxyDeployerAddress }) const newMaxInProgressProposals = 100 diff --git a/eth-contracts/test/staking.test.js b/eth-contracts/test/staking.test.js index 807e862374b..8164d7bd8ef 100644 --- a/eth-contracts/test/staking.test.js +++ b/eth-contracts/test/staking.test.js @@ -110,6 +110,13 @@ contract('Staking test', async (accounts) => { stakingAddress = staking.address }) + it.only('Confirm staking fails reinitialization', async () => { + await _lib.assertRevert( + staking.initialize(token.address, accounts[14]), + 'Contract instance has already been initialized' + ) + }) + it('has correct initial state', async () => { assert.equal(await staking.token({ from: accounts[13]}), token.address, 'Token is wrong') assert.equal((await staking.totalStaked()).valueOf(), 0, 'Initial total staked amount should be zero') From a06824d9a8e017315ea0f2dcf3c3f5fd44094e29 Mon Sep 17 00:00:00 2001 From: Hareesh Nagaraj Date: Tue, 2 Aug 2022 18:34:50 +0000 Subject: [PATCH 3/3] RM only --- eth-contracts/test/staking.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth-contracts/test/staking.test.js b/eth-contracts/test/staking.test.js index 8164d7bd8ef..510905b8b10 100644 --- a/eth-contracts/test/staking.test.js +++ b/eth-contracts/test/staking.test.js @@ -110,7 +110,7 @@ contract('Staking test', async (accounts) => { stakingAddress = staking.address }) - it.only('Confirm staking fails reinitialization', async () => { + it('Confirm staking fails reinitialization', async () => { await _lib.assertRevert( staking.initialize(token.address, accounts[14]), 'Contract instance has already been initialized'