Created test utils directory

(cherry picked from commit 269981ee6a)
This commit is contained in:
Nicolás Venturo
2018-10-02 10:37:44 -03:00
committed by Leo Arias
parent 0678f67289
commit 2f3f0d3c8a
2 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,20 @@
const AddressImpl = artifacts.require('AddressImpl');
const SimpleToken = artifacts.require('SimpleToken');
require('chai')
.should();
contract('Address', function ([_, anyone]) {
beforeEach(async function () {
this.mock = await AddressImpl.new();
});
it('should return false for account address', async function () {
(await this.mock.isContract(anyone)).should.equal(false);
});
it('should return true for contract address', async function () {
const contract = await SimpleToken.new();
(await this.mock.isContract(contract.address)).should.equal(true);
});
});

View File

@ -0,0 +1,36 @@
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));
});
});