Example #1
0
 async function purchaseShouldFail (crowdsale, beneficiary, value) {
   await shouldFail.reverting.withMessage(crowdsale.buyTokens(beneficiary, { from: beneficiary, value }),
     'WhitelistCrowdsale: beneficiary doesn\'t have the Whitelisted role'
   );
   await shouldFail.reverting.withMessage(crowdsale.sendTransaction({ from: beneficiary, value }),
     'WhitelistCrowdsale: beneficiary doesn\'t have the Whitelisted role'
   );
 }
Example #2
0
 it('reverts', async function () {
   const invalidReceiver = await ERC721ReceiverMock.new('0x42', false);
   await shouldFail.reverting.withMessage(
     this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }),
     'ERC721: transfer to non ERC721Receiver implementer'
   );
 });
Example #3
0
 it('burns the given token ID and adjusts the balance of the owner', async function () {
   await shouldFail.reverting.withMessage(
     this.token.ownerOf(tokenId),
     'ERC721: owner query for nonexistent token'
   );
   (await this.token.balanceOf(owner)).should.be.bignumber.equal('1');
 });
Example #4
0
 it('reverts', async function () {
   const invalidReceiver = await ERC721ReceiverMock.new(RECEIVER_MAGIC_VALUE, true);
   await shouldFail.reverting.withMessage(
     this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }),
     'ERC721ReceiverMock: reverting'
   );
 });
Example #5
0
 it('reverts when attempting to set as implementer in the registry', async function () {
   await shouldFail.reverting.withMessage(
     this.registry.setInterfaceImplementer(
       implementee, this.interfaceA, this.implementer.address, { from: implementee }
     ),
     'Does not implement the interface'
   );
 });
Example #6
0
  it('reverts if the end time is in the past', async function () {
    const now = await time.latest();

    this.start = now.sub(this.duration).sub(time.duration.minutes(1));
    await shouldFail.reverting.withMessage(
      TokenVesting.new(beneficiary, this.start, this.cliffDuration, this.duration, true, { from: owner }),
      'TokenVesting: final time is before current time'
    );
  });
Example #7
0
    it('should fail to be revoked by owner if revocable not set', async function () {
      const vesting = await TokenVesting.new(
        beneficiary, this.start, this.cliffDuration, this.duration, false, { from: owner }
      );

      await shouldFail.reverting.withMessage(vesting.revoke(this.token.address, { from: owner }),
        'TokenVesting: cannot revoke'
      );
    });
Example #8
0
  it('reverts with a duration shorter than the cliff', async function () {
    const cliffDuration = this.duration;
    const duration = this.cliffDuration;

    cliffDuration.should.be.bignumber.that.is.at.least(duration);

    await shouldFail.reverting.withMessage(
      TokenVesting.new(beneficiary, this.start, cliffDuration, duration, true, { from: owner }),
      'TokenVesting: cliff is longer than duration'
    );
  });
Example #9
0
 it('reverts', async function () {
   await shouldFail.reverting.withMessage(
     transferFun.call(
       this,
       owner,
       this.receiver.address,
       unknownTokenId,
       { from: owner },
     ),
     'ERC721: operator query for nonexistent token'
   );
 });
Example #10
0
 it('reverts', async function () {
   await shouldFail.reverting.withMessage(
     transferFunction.call(this, owner, other, tokenId, { from: other }),
     'ERC721: transfer caller is not owner nor approved'
   );
 });
Example #11
0
 it('reverts', async function () {
   await shouldFail.reverting.withMessage(
     transferFunction.call(this, other, other, tokenId, { from: owner }),
     'ERC721: transfer of token that is not own'
   );
 });
Example #12
0
    it('reverts on divison by zero', async function () {
      const a = new BN('5678');
      const b = new BN('0');

      await shouldFail.reverting.withMessage(this.safeMath.div(a, b), 'SafeMath: division by zero');
    });
Example #13
0
    it('reverts if subtraction result would be negative', async function () {
      const a = new BN('1234');
      const b = new BN('5678');

      await shouldFail.reverting.withMessage(this.safeMath.sub(a, b), 'SafeMath: subtraction overflow');
    });
Example #14
0
 it('reverts with a null duration', async function () {
   // cliffDuration should also be 0, since the duration must be larger than the cliff
   await shouldFail.reverting.withMessage(
     TokenVesting.new(beneficiary, this.start, 0, 0, true, { from: owner }), 'TokenVesting: duration is 0'
   );
 });
Example #15
0
 it('throws', async function () {
   await shouldFail.reverting.withMessage(
     this.token.balanceOf(ZERO_ADDRESS), 'ERC721: balance query for the zero address'
   );
 });
Example #16
0
 it('reverts when removing roles from the zero account', async function () {
   await shouldFail.reverting.withMessage(this.roles.remove(ZERO_ADDRESS), 'Roles: account is the zero address');
 });
Example #17
0
 it('reverts when removing unassigned roles', async function () {
   await shouldFail.reverting.withMessage(this.roles.remove(other), 'Roles: account does not have role');
 });
Example #18
0
 it('reverts when adding roles to an already assigned account', async function () {
   await this.roles.add(authorized);
   await shouldFail.reverting.withMessage(this.roles.add(authorized), 'Roles: account already has role');
 });
Example #19
0
 it('cannot be released before cliff', async function () {
   await shouldFail.reverting.withMessage(this.vesting.release(this.token.address),
     'TokenVesting: no tokens are due'
   );
 });
Example #20
0
 it('reverts', async function () {
   await shouldFail.reverting.withMessage(
     transferFunction.call(this, owner, ZERO_ADDRESS, tokenId, { from: owner }),
     'ERC721: transfer to the zero address'
   );
 });
Example #21
0
 it('reverts', async function () {
   await this.token.approve(approved, tokenId, { from: owner });
   await shouldFail.reverting.withMessage(this.token.approve(anotherApproved, tokenId, { from: approved }),
     'ERC721: approve caller is not owner nor approved for all');
 });
Example #22
0
 it('reverts', async function () {
   await shouldFail.reverting.withMessage(this.token.setApprovalForAll(owner, true, { from: owner }),
     'ERC721: approve to caller');
 });
Example #23
0
 it('does not allow beneficiaries to withdraw tokens before crowdsale ends', async function () {
   await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor),
     'PostDeliveryCrowdsale: not closed'
   );
 });
Example #24
0
 it('reverts with a null beneficiary', async function () {
   await shouldFail.reverting.withMessage(
     TokenVesting.new(ZERO_ADDRESS, this.start, this.cliffDuration, this.duration, true, { from: owner }),
     'TokenVesting: beneficiary is the zero address'
   );
 });
Example #25
0
 it('reverts', async function () {
   await shouldFail.reverting.withMessage(
     this.token.approve(owner, tokenId, { from: owner }), 'ERC721: approval to current owner'
   );
 });
Example #26
0
 it('rejects multiple withdrawals', async function () {
   await this.crowdsale.withdrawTokens(investor);
   await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor),
     'PostDeliveryCrowdsale: beneficiary is not due any tokens'
   );
 });
Example #27
0
 it('reverts', async function () {
   await shouldFail.reverting.withMessage(this.token.approve(approved, unknownTokenId, { from: operator }),
     'ERC721: owner query for nonexistent token');
 });
Example #28
0
    it('reverts with a 0 divisor', async function () {
      const a = new BN('5678');
      const b = new BN('0');

      await shouldFail.reverting.withMessage(this.safeMath.mod(a, b), 'SafeMath: modulo by zero');
    });
Example #29
0
 it('reverts', async function () {
   await shouldFail.reverting.withMessage(
     this.token.ownerOf(tokenId), 'ERC721: owner query for nonexistent token'
   );
 });
Example #30
0
 async function testFailsCommutative (fn, lhs, rhs, reason) {
   await shouldFail.reverting.withMessage(fn(lhs, rhs), reason);
   await shouldFail.reverting.withMessage(fn(rhs, lhs), reason);
 }