Openzeppelin-contracts: WhitelistedCrowdsale always reverts on send()

Created on 5 Jun 2018  路  4Comments  路  Source: OpenZeppelin/openzeppelin-contracts

馃帀 Description

The WhitelistedCrowdsale contract reverts when calling it using send() instead of buyTokens().

Behaviour confirmed via npm test using ganache-cli.

  • [x] 馃悰 This is a bug report.

馃捇 Environment

馃摑 Details

I did check the comments in the code and the medium posts, and found nothing about this behaviour even though it looks like this is a known issue as the tests are written in a way that uses send() only for tests that are expected to revert.

(See : https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/test/crowdsale/WhitelistedCrowdsale.test.js )

馃敘 Code To Reproduce Issue

  1. Clone this repository at commit a0c03ee
  2. Insert this line before line 27 of test/crowdsale/WhitelistedCrowdsale.test.js
await this.crowdsale.send(value, { from: authorized }).should.be.fulfilled;
//Line 28 should be as follow : 
await this.crowdsale.buyTokens(authorized, { value: value, from: authorized }).should.be.fulfilled;
  1. run npm test
  2. Enjoy the AssertionError: expected promise to be fulfilled but it was rejected with 'Error: VM Exception while processing transaction: revert'

All 4 comments

found the issue! truffle-contract's send() function is bad software and doesn't accept an options hash like every other method in the library, so the sender of that transaction is always the default account, which is not authorized and therefore fails the whitelist check.

sending a normal transaction is the move. I'll have a PR for this in a few minutes.

Thank you for your very detailed bug report!! <3

That was fast ! Thanks to you I can move on :+1:

Was this page helpful?
0 / 5 - 0 ratings