Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C-739] Re-initialize contract test cases #3615

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion eth-contracts/test/audiusToken.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down Expand Up @@ -231,6 +231,13 @@ contract('AudiusToken', async (accounts) => {
)
})

it('Confirm token reinitialization fails', async () => {
await _lib.assertRevert(
token.initialize(proxyDeployerAddress, accounts[13]),
'Contract instance has already been initialized'
)
})

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
Expand Down
7 changes: 7 additions & 0 deletions eth-contracts/test/delegateManagerV2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions eth-contracts/test/governance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions eth-contracts/test/staking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ contract('Staking test', async (accounts) => {
stakingAddress = staking.address
})

it('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')
Expand Down