Revert on useless operations.

This commit is contained in:
Alberto Cuesta Cañada
2020-01-23 20:43:57 +00:00
parent dfdf794e3c
commit 41cb935930
2 changed files with 22 additions and 9 deletions

View File

@ -1,5 +1,5 @@
const { contract } = require('@openzeppelin/test-environment');
const { expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const EnumerableSetMock = contract.fromArtifact('EnumerableSetMock');
@ -31,12 +31,27 @@ describe('EnumerableSet', function () {
expect(await this.set.testContains(c)).to.equal(false);
});
it('can\'t add same value twice.', async function () {
await this.set.testAdd(a);
await expectRevert(
this.set.testAdd(a),
'EnumerableSet: value already in set',
);
});
it('removes values.', async function () {
await this.set.testAdd(a);
await this.set.testRemove(a);
expect(await this.set.testContains(a)).to.equal(false);
});
it('can\'t remove values that are not in the set.', async function () {
await expectRevert(
this.set.testRemove(a),
'EnumerableSet: value not in set',
);
});
it('enumerates values as an empty array', async function () {
expect(await this.set.testEnumerate()).to.eql([]);
});