The WhitelistedCrowdsale contract reverts when calling it using send() instead of buyTokens().
Behaviour confirmed via npm test using ganache-cli.
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 )
test/crowdsale/WhitelistedCrowdsale.test.jsawait 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;
npm testAssertionError: expected promise to be fulfilled but it was rejected with 'Error: VM Exception while processing transaction: revert'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:
Most helpful comment
https://github.com/trufflesuite/truffle-contract/blob/develop/contract.js#L321