Files
openzeppelin-contracts/test/utils/ReentrancyGuard.test.js
Aniket b41b125c15 this is used in tests (#1380)
* signing prefix added

* Minor improvement

* Tests changed

* Successfully tested

* Minor improvements

* Minor improvements

* Revert "Dangling commas are now required. (#1359)"

This reverts commit a6889776f4.

* updates

* fixes #1200

* suggested change
2018-10-04 09:57:37 -03:00

34 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 () {
beforeEach(async function () {
this.reentrancyMock = await ReentrancyMock.new();
(await this.reentrancyMock.counter()).should.be.bignumber.equal(0);
});
it('should not allow remote callback', async function () {
const attacker = await ReentrancyAttack.new();
await expectThrow(this.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(this.reentrancyMock.countLocalRecursive(10));
});
it('should not allow indirect local recursion', async function () {
await expectThrow(this.reentrancyMock.countThisRecursive(10));
});
});