Files
openzeppelin-contracts/test/utils/ReentrancyGuard.test.js
Balaji Pachai 3682c6575c Added message string for require() (#1704)
* Error handling in ERC20 and ERC721

* Added message string for require.

* Fixed solhint errors.

* Updated PR as per issue #1709

* changes as per #1709 and openzeppelin forum.

* Changes in require statement

* Changes in require statement

* build pipeline fix

* Changes as per @nventuro's comment.

* Update revert reason strings.

* Fianal update of revert reason strings.

* WIP: Updating reason strings in test cases

* WIP: Added changes to ERC20 and ERC721

* Fixes linting errors in *.tes.js files

* Achieved 100% code coverage

* Updated the test cases with shouldFail.reverting.withMessage()

* Fix package-lock.

* address review comments

* fix linter issues

* fix remaining revert reasons
2019-04-24 11:17:08 -03:00

34 lines
1.2 KiB
JavaScript

const { shouldFail } = require('openzeppelin-test-helpers');
const ReentrancyMock = artifacts.require('ReentrancyMock');
const ReentrancyAttack = artifacts.require('ReentrancyAttack');
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 shouldFail.reverting.withMessage(
this.reentrancyMock.countAndCall(attacker.address), 'ReentrancyGuard: reentrant call');
});
// 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 shouldFail.reverting.withMessage(
this.reentrancyMock.countLocalRecursive(10), 'ReentrancyGuard: reentrant call'
);
});
it('should not allow indirect local recursion', async function () {
await shouldFail.reverting.withMessage(
this.reentrancyMock.countThisRecursive(10), 'ReentrancyMock: failed call'
);
});
});