Files
openzeppelin-contracts/test/ReentrancyGuard.test.js
Nicolás Venturo ac91af9a6a Replace all asserts with chai.should (#1183)
* Moving towards chai.should.

* Fixed failing tests.

* Fixed linter errors.

* Revert package-lock.json changes.

* Fixed failing tests.

* s/eq/equal

* Addressed review comment
2018-08-10 19:03:04 -03:00

37 lines
1.1 KiB
JavaScript

const { expectThrow } = require('./helpers/expectThrow');
const ReentrancyMock = artifacts.require('ReentrancyMock');
const ReentrancyAttack = artifacts.require('ReentrancyAttack');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('ReentrancyGuard', function () {
let reentrancyMock;
beforeEach(async function () {
reentrancyMock = await ReentrancyMock.new();
const initialCounter = await reentrancyMock.counter();
initialCounter.should.be.bignumber.equal(0);
});
it('should not allow remote callback', async function () {
const attacker = await ReentrancyAttack.new();
await expectThrow(reentrancyMock.countAndCall(attacker.address));
});
// The following are more side-effects than intended behavior:
// I put them here as documentation, and to monitor any changes
// in the side-effects.
it('should not allow local recursion', async function () {
await expectThrow(reentrancyMock.countLocalRecursive(10));
});
it('should not allow indirect local recursion', async function () {
await expectThrow(reentrancyMock.countThisRecursive(10));
});
});