示例#1
0
 it('fails changing required support to 100% or more', async () => {
     await assertRevert(async () => {
         await voting.changeSupportRequiredPct(pct16(101))
     })
     return assertRevert(async () => {
         await voting.changeSupportRequiredPct(pct16(100))
     })
 })
示例#2
0
 it('fails if min support is 100% or more', async() => {
     const minimumAcceptanceQuorum = pct16(20)
     await assertRevert(async() => {
         await voting.initialize(token.address, pct16(101), minimumAcceptanceQuorum, votingTime)
     })
     return assertRevert(async() => {
         await voting.initialize(token.address, pct16(100), minimumAcceptanceQuorum, votingTime)
     })
 })
示例#3
0
 it('fails when assigning invalid vesting schedule', async () => {
     return assertRevert(async () => {
         const tokens = 10
         // vesting < cliff
         await tokenManager.assignVested(holder, tokens, 10, 20, 10, true)
     })
 })
示例#4
0
        it('cannot assign more tokens than owned', async () => {
            await tokenManager.issue(50)

            return assertRevert(async () => {
                await tokenManager.assign(holder, 51)
            })
        })
示例#5
0
 it('cannot initialize base app', async () => {
     const newTokenManager = await TokenManager.new()
     assert.isTrue(await newTokenManager.isPetrified())
     return assertRevert(async () => {
         await newTokenManager.initialize(token.address, true, 0)
     })
 })
示例#6
0
            it('can approve non-vested tokens but transferFrom fails', async () => {
                await token.approve(accounts[2], 10, { from: holder })

                return assertRevert(async () => {
                    await token.transferFrom(holder, accounts[2], 10, { from: accounts[2] })
                })
            })
示例#7
0
 it('fails if min acceptance quorum is greater than min support', () => {
     const neededSupport = pct16(20)
     const minimumAcceptanceQuorum = pct16(50)
     return assertRevert(async() => {
         await voting.initialize(token.address, neededSupport, minimumAcceptanceQuorum, votingTime)
     })
 })
示例#8
0
        it('holders cannot transfer non-transferable tokens', async () => {
            await tokenManager.mint(holder, 2000)

            return assertRevert(async () => {
                await token.transfer(accounts[2], 10, { from: holder })
            })
        })
示例#9
0
 it('cannot execute vote if not enough quorum met', async () => {
     await voting.vote(voteId, true, true, { from: holder20 })
     await timeTravel(votingTime + 1)
     return assertRevert(async () => {
         await voting.executeVote(voteId)
     })
 })
示例#10
0
 it('cannot initialize base app', async () => {
     const newVoting = await Voting.new()
     assert.isTrue(await newVoting.isPetrified())
     return assertRevert(async () => {
         await newVoting.initialize(token.address, neededSupport, minimumAcceptanceQuorum, votingTime)
     })
 })
示例#11
0
 it('cannot initialize base app', async () => {
   const newSurvey = await getContract('Survey').new()
   assert.isTrue(await newSurvey.isPetrified())
   return assertRevert(async () => {
     await newSurvey.initialize(token.address, minimumAcceptanceParticipationPct, surveyTime)
   })
 })
示例#12
0
        it('cannot assign more than limit', async () => {
            await tokenManager.issue(limit + 2)

            return assertRevert(async () => {
                await tokenManager.assign(holder, limit + 1)
            })
        })
示例#13
0
      it('fails if voting on non-existing option', async () => {
        await survey.voteOption(surveyId, optionsCount, { from: holder31 })

        return assertRevert(async () => {
          await survey.voteOption(surveyId, optionsCount + 1, { from: holder31 })
        })
      })
示例#14
0
 it('cannot execute vote if not support met', async () => {
     await voting.vote(voteId, false, true, { from: holder29 })
     await voting.vote(voteId, false, true, { from: holder20 })
     await timeTravel(votingTime + 1)
     return assertRevert(async () => {
         await voting.executeVote(voteId)
     })
 })
示例#15
0
 it('execution throws if any action on script throws', async () => {
     const action = { to: executionTarget.address, calldata: executionTarget.contract.execute.getData() }
     let script = encodeCallScript([action])
     script = script.slice(0, -2) // remove one byte from calldata for it to fail
     return assertRevert(async () => {
         await voting.newVote(script, '', { from: holder51 })
     })
 })
示例#16
0
            it('cannot revoke non-revokable vestings', async () => {
                await tokenManager.issue(1)
                await tokenManager.assignVested(holder, 1, now + start, now + cliff, now + vesting, false)

                return assertRevert(async () => {
                    await tokenManager.revokeVesting(holder, 1)
                })
            })
示例#17
0
        it("cannot call onTransfer() from outside of the token's context", async () => {
            const amount = 10
            await tokenManager.mint(holder, amount)

            // Make sure this callback fails when called out-of-context
            await assertRevert(() => tokenManager.onTransfer(holder, accounts[2], 10))

            // Make sure the same transfer through the token's context doesn't revert
            await token.transfer(accounts[2], amount, { from: holder })
        })
示例#18
0
  it('forwards actions to employee', async () => {
    const executionTarget = await ExecutionTarget.new();
    const action = { to: executionTarget.address, calldata: executionTarget.contract.execute.getData() };
    const script = encodeCallScript([action]);

    await payroll.forward(script, { from: employee1 });
    assert.equal((await executionTarget.counter()).toString(), 1, 'should have received execution call');

    // can not forward call
    return assertRevert(async () => {
      await payroll.forward(script, { from: unused_account });
    });
  });
示例#19
0
 it('cannot have more than 50 vestings', async () => {
     let i = 49 // already have 1
     await tokenManager.issue(50)
     while (i > 0) {
         await tokenManager.assignVested(holder, 1, now + start, now + cliff, now + vesting, false)
         i--
     }
     await timetravel(vesting)
     await token.transfer(accounts[3], 1) // can transfer
     return assertRevert(async () => {
         await tokenManager.assignVested(holder, 1, now + start, now + cliff, now + vesting, false)
     })
 })
示例#20
0
        it('forwards actions only to token holders', async () => {
            const executionTarget = await ExecutionTarget.new()
            await tokenManager.mint(holder, 100)

            const action = { to: executionTarget.address, calldata: executionTarget.contract.execute.getData() }
            const script = encodeCallScript([action])

            await tokenManager.forward(script, { from: holder })
            assert.equal(await executionTarget.counter(), 1, 'should have received execution call')

            return assertRevert(async () => {
                await tokenManager.forward(script, { from: accounts[8] })
            })
        })
示例#21
0
  it('fails to pay if rates are obsolete', async () => {
    // add employee
    const startDate = parseInt(await payroll.getTimestampPublic.call(), 10) - 2628005 // now minus 1/12 year
    const receipt = await payroll.addEmployee(employee, salary, "Kakaroto", 'Saiyajin', startDate)
    const employeeId = getEvent(receipt, 'AddEmployee', 'employeeId')

    const usdTokenAllocation = 50
    const erc20Token1Allocation = 20
    const ethAllocation = 100 - usdTokenAllocation - erc20Token1Allocation
    // determine allocation
    await payroll.determineAllocation([ETH, usdToken.address, erc20Token1.address], [ethAllocation, usdTokenAllocation, erc20Token1Allocation], {from: employee})
    await getTimePassed(payroll, employeeId)
    // set old date in price feed
    const oldTime = parseInt(await payroll.getTimestampPublic(), 10) - rateExpiryTime - 1
    await priceFeed.mockSetTimestamp(oldTime)
    // call payday
    return assertRevert(async () => {
      await payroll.payday({from: employee})
    })
  })
示例#22
0
 it('cannot change minimum acceptance participation to more than 100', async () => {
   return assertRevert(async () => {
     const receipt = await survey.changeMinAcceptParticipationPct(pct16(101))
   })
 })
示例#23
0
 it('fails on reinitialization', async () => {
   return assertRevert(async () => {
     await survey.initialize(token.address, minimumAcceptanceParticipationPct, surveyTime)
   })
 })
示例#24
0
 it('fails voting with more than 1 token because of wrong votingPower', async () => {
   const surveyId = createdSurveyId(await survey.newSurvey('metadata', 10))
   return assertRevert(async () => {
     await survey.voteOption(surveyId, 10, { from: holder19 })
   })
 })
示例#25
0
 it('fails creating a survey before initialization', async () => {
   return assertRevert(async () => {
     await survey.newSurvey('metadata', 10)
   })
 })
示例#26
0
 it('fails creating a survey if token has no holder', async () => {
   return assertRevert(async () => {
     await survey.newSurvey('metadata', 10)
   })
 })
示例#27
0
 it('fails if min participation is greater than 100', () => {
   const badMinimumAcceptanceParticipationPct = pct16(101)
   return assertRevert(async() => {
     await survey.initialize(token.address, badMinimumAcceptanceParticipationPct, surveyTime)
   })
 })
示例#28
0
 it('fails if multi option vote has a zero stake option', async () => {
   return assertRevert(async () => {
     await survey.voteOptions(surveyId, [1,2], [10, 0], { from: holder31 })
   })
 })
示例#29
0
 it('fails if multi option vote has NO VOTE option', async () => {
   return assertRevert(async () => {
     await survey.voteOptions(surveyId, [ABSTAIN_VOTE, 2], [10, 21], { from: holder31 })
   })
 })
示例#30
0
 it('fails if multi option vote has unordered options', async () => {
   return assertRevert(async () => {
     await survey.voteOptions(surveyId, [2,1], [10, 21], { from: holder31 })
   })
 })