/
Tested.test.js
32 lines (29 loc) · 1.19 KB
/
Tested.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const { expectRevert } = require('openzeppelin-test-helpers');
const { expect } = require('chai');
const Tested = artifacts.require('Tested');
contract('Tested', function (accounts) {
context('expectRevert', async function () {
beforeEach(async function () {
this.contract = await Tested.new();
})
context('with ganache-core < 2.2.0', async function () {
it('accepts reverts without regard to the specified reason', async function () {
// This is the revert reason at Tested.sol:5
const expectedMessage = 'lorem ipsum';
// Asserting that locally installed ganache-core is v2.1.0.
const nodeInfo = await web3.eth.getNodeInfo();
expect(nodeInfo).to.include('2.1.0');
try {
await this.contract.failWithRevertReason();
}
catch (error) {
// Asserting that older ganache does NOT return reason message.
expect(error.message).to.not.include(expectedMessage);
}
// With that said, following revert should be accepted without regard to the specified
// reason message.
await expectRevert(this.contract.failWithRevertReason(), expectedMessage);
})
})
})
});