mirror of
https://github.com/tornadocash/tornado-governance
synced 2024-02-02 14:53:55 +01:00
fix tests
This commit is contained in:
parent
47cd937085
commit
69a58510bb
@ -72,10 +72,12 @@ contract('Governance', (accounts) => {
|
|||||||
let domain
|
let domain
|
||||||
let votingDelay
|
let votingDelay
|
||||||
let votingPeriod
|
let votingPeriod
|
||||||
|
let executionExpiration
|
||||||
let executionDelay
|
let executionDelay
|
||||||
|
let extendTime
|
||||||
let proposalStartTime
|
let proposalStartTime
|
||||||
let proposalEndTime
|
let proposalEndTime
|
||||||
let delay
|
let lockingPeriod
|
||||||
let balanceProposer
|
let balanceProposer
|
||||||
const cap = toBN(tornConfig.torn.cap)
|
const cap = toBN(tornConfig.torn.cap)
|
||||||
const tenThousandTorn = toBN(10).pow(toBN(18)).mul(toBN(10000))
|
const tenThousandTorn = toBN(10).pow(toBN(18)).mul(toBN(10000))
|
||||||
@ -100,12 +102,14 @@ contract('Governance', (accounts) => {
|
|||||||
await torn.transfer(proposer, balanceProposer, { from: miningPublicKey })
|
await torn.transfer(proposer, balanceProposer, { from: miningPublicKey })
|
||||||
await torn.setChainId(chainId)
|
await torn.setChainId(chainId)
|
||||||
await governance.setTimestamp(timestamp)
|
await governance.setTimestamp(timestamp)
|
||||||
delay = duration.days(2)
|
|
||||||
votingDelay = await governance.VOTING_DELAY()
|
votingDelay = await governance.VOTING_DELAY()
|
||||||
votingPeriod = await governance.VOTING_PERIOD()
|
votingPeriod = await governance.VOTING_PERIOD()
|
||||||
|
executionExpiration = await governance.EXECUTION_EXPIRATION()
|
||||||
executionDelay = await governance.EXECUTION_DELAY()
|
executionDelay = await governance.EXECUTION_DELAY()
|
||||||
|
extendTime = await governance.VOTE_EXTEND_TIME()
|
||||||
proposalStartTime = new BN(timestamp).add(votingDelay)
|
proposalStartTime = new BN(timestamp).add(votingDelay)
|
||||||
proposalEndTime = votingPeriod.add(toBN(proposalStartTime))
|
proposalEndTime = votingPeriod.add(toBN(proposalStartTime))
|
||||||
|
lockingPeriod = Number(extendTime) + Number(executionExpiration) + Number(executionDelay)
|
||||||
domain = {
|
domain = {
|
||||||
name: await torn.name(),
|
name: await torn.name(),
|
||||||
version: '1',
|
version: '1',
|
||||||
@ -167,7 +171,7 @@ contract('Governance', (accounts) => {
|
|||||||
state.should.be.eq.BN(ProposalState.Active)
|
state.should.be.eq.BN(ProposalState.Active)
|
||||||
|
|
||||||
const accountLock = await governance.canWithdrawAfter(proposer)
|
const accountLock = await governance.canWithdrawAfter(proposer)
|
||||||
accountLock.should.be.eq.BN(proposalEndTime.add(toBN(delay)))
|
accountLock.should.be.eq.BN(proposalEndTime.add(toBN(lockingPeriod)))
|
||||||
})
|
})
|
||||||
it('fails if target is not a contract', async () => {
|
it('fails if target is not a contract', async () => {
|
||||||
await governance
|
await governance
|
||||||
@ -190,7 +194,7 @@ contract('Governance', (accounts) => {
|
|||||||
})
|
})
|
||||||
it('fails if proposer does not have voting power', async () => {
|
it('fails if proposer does not have voting power', async () => {
|
||||||
const voterBob = accounts[5]
|
const voterBob = accounts[5]
|
||||||
const tenThousandTorn = toBN(10).pow(toBN(18)).mul(toBN(9999))
|
const tenThousandTorn = toBN(10).pow(toBN(18)).mul(toBN(999))
|
||||||
await torn.transfer(voterBob, tenThousandTorn, { from: miningPublicKey })
|
await torn.transfer(voterBob, tenThousandTorn, { from: miningPublicKey })
|
||||||
|
|
||||||
await torn.approve(governance.address, tenThousandTorn, { from: voterBob })
|
await torn.approve(governance.address, tenThousandTorn, { from: voterBob })
|
||||||
@ -380,7 +384,7 @@ contract('Governance', (accounts) => {
|
|||||||
await governance.castVote(id, true, { from: voterAlice })
|
await governance.castVote(id, true, { from: voterAlice })
|
||||||
|
|
||||||
const lockAfter = await governance.canWithdrawAfter(voterAlice)
|
const lockAfter = await governance.canWithdrawAfter(voterAlice)
|
||||||
lockAfter.should.be.eq.BN(proposalEndTime.add(executionDelay))
|
lockAfter.should.be.eq.BN(proposalEndTime.add(toBN(lockingPeriod)))
|
||||||
})
|
})
|
||||||
it('does not reduce lock time', async () => {
|
it('does not reduce lock time', async () => {
|
||||||
const voterAlice = accounts[7]
|
const voterAlice = accounts[7]
|
||||||
@ -429,9 +433,8 @@ contract('Governance', (accounts) => {
|
|||||||
let state = await governance.state(id)
|
let state = await governance.state(id)
|
||||||
state.should.be.eq.BN(ProposalState.Active)
|
state.should.be.eq.BN(ProposalState.Active)
|
||||||
await governance.castVote(id, true, { from: proposer })
|
await governance.castVote(id, true, { from: proposer })
|
||||||
await governance.setTimestamp(proposalEndTime.add(toBN(1)))
|
|
||||||
|
|
||||||
await governance.setTimestamp(proposalEndTime.add(toBN(delay).add(toBN(duration.days(1)))))
|
await governance.setTimestamp(proposalEndTime.add(toBN(executionDelay).add(toBN(duration.days(1)))))
|
||||||
|
|
||||||
const receipt = await governance.execute(id)
|
const receipt = await governance.execute(id)
|
||||||
const debugLog = receipt.receipt.rawLogs[0]
|
const debugLog = receipt.receipt.rawLogs[0]
|
||||||
@ -550,7 +553,7 @@ contract('Governance', (accounts) => {
|
|||||||
})
|
})
|
||||||
it('unlock if there proposals expired', async () => {
|
it('unlock if there proposals expired', async () => {
|
||||||
await governance.propose(dummy.address, 'dummy', { from: proposer })
|
await governance.propose(dummy.address, 'dummy', { from: proposer })
|
||||||
await governance.setTimestamp(proposalEndTime.add(toBN(delay + duration.minutes(1))))
|
await governance.setTimestamp(proposalEndTime.add(toBN(lockingPeriod + duration.minutes(1))))
|
||||||
await governance.unlock(balanceProposer, { from: proposer })
|
await governance.unlock(balanceProposer, { from: proposer })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -668,12 +671,11 @@ contract('Governance', (accounts) => {
|
|||||||
let state = await governance.state(id)
|
let state = await governance.state(id)
|
||||||
state.should.be.eq.BN(ProposalState.Active)
|
state.should.be.eq.BN(ProposalState.Active)
|
||||||
await governance.castVote(id, true, { from: proposer })
|
await governance.castVote(id, true, { from: proposer })
|
||||||
await governance.setTimestamp(proposalEndTime.add(toBN(1)))
|
|
||||||
|
|
||||||
await governance.setTimestamp(proposalEndTime.add(toBN(delay).add(toBN(duration.days(1)))))
|
await governance.setTimestamp(proposalEndTime.add(toBN(executionDelay).add(toBN(duration.days(1)))))
|
||||||
|
|
||||||
const EXECUTION_DELAY_BEFORE = await governance.EXECUTION_DELAY()
|
const EXECUTION_DELAY_BEFORE = await governance.EXECUTION_DELAY()
|
||||||
EXECUTION_DELAY_BEFORE.should.be.eq.BN(delay)
|
EXECUTION_DELAY_BEFORE.should.be.eq.BN(duration.days(2))
|
||||||
const receipt = await governance.execute(id)
|
const receipt = await governance.execute(id)
|
||||||
const EXECUTION_DELAY_AFTER = await governance.EXECUTION_DELAY()
|
const EXECUTION_DELAY_AFTER = await governance.EXECUTION_DELAY()
|
||||||
EXECUTION_DELAY_AFTER.should.be.eq.BN(duration.days(3))
|
EXECUTION_DELAY_AFTER.should.be.eq.BN(duration.days(3))
|
||||||
@ -690,9 +692,8 @@ contract('Governance', (accounts) => {
|
|||||||
let state = await governance.state(id)
|
let state = await governance.state(id)
|
||||||
state.should.be.eq.BN(ProposalState.Active)
|
state.should.be.eq.BN(ProposalState.Active)
|
||||||
await governance.castVote(id, true, { from: proposer })
|
await governance.castVote(id, true, { from: proposer })
|
||||||
await governance.setTimestamp(proposalEndTime.add(toBN(1)))
|
|
||||||
|
|
||||||
await governance.setTimestamp(proposalEndTime.add(toBN(delay).add(toBN(duration.days(1)))))
|
await governance.setTimestamp(proposalEndTime.add(toBN(executionDelay).add(toBN(duration.days(1)))))
|
||||||
|
|
||||||
const newGovernance = await NewImplementation.at(governance.address)
|
const newGovernance = await NewImplementation.at(governance.address)
|
||||||
const receipt = await governance.execute(id)
|
const receipt = await governance.execute(id)
|
||||||
|
@ -5007,9 +5007,9 @@ toidentifier@1.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553"
|
resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553"
|
||||||
integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==
|
integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==
|
||||||
|
|
||||||
"torn-token@git+https://github.com/tornadocash/torn-token.git#d7b86c01538cd26afae73885f66269a98c02aa3f":
|
"torn-token@git+https://github.com/tornadocash/torn-token.git#ed68304596f73bf746321e1cd2454979688ef1dd":
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "git+https://github.com/tornadocash/torn-token.git#d7b86c01538cd26afae73885f66269a98c02aa3f"
|
resolved "git+https://github.com/tornadocash/torn-token.git#ed68304596f73bf746321e1cd2454979688ef1dd"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@openzeppelin/contracts" "^3.1.0"
|
"@openzeppelin/contracts" "^3.1.0"
|
||||||
dotenv "^8.2.0"
|
dotenv "^8.2.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user