API improvements for EnumerableSet (#2151)
* Add revert reason to EnumerableSet.get. * Rename EnumerableSet values to keys * Rename get to at * Add changelog entry * Rename keys to values * Add leading underscore to struct members
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
const { accounts, contract } = require('@openzeppelin/test-environment');
|
||||
const { expectEvent } = require('@openzeppelin/test-helpers');
|
||||
const { expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
|
||||
const { expect } = require('chai');
|
||||
|
||||
const EnumerableSetMock = contract.fromArtifact('EnumerableSetMock');
|
||||
@ -21,7 +21,7 @@ describe('EnumerableSet', function () {
|
||||
expect(await set.length()).to.bignumber.equal(members.length.toString());
|
||||
|
||||
expect(await Promise.all([...Array(members.length).keys()].map(index =>
|
||||
set.get(index)
|
||||
set.at(index)
|
||||
))).to.have.same.members(members);
|
||||
}
|
||||
|
||||
@ -55,6 +55,10 @@ describe('EnumerableSet', function () {
|
||||
await expectMembersMatch(this.set, [accountA]);
|
||||
});
|
||||
|
||||
it('reverts when retrieving non-existent elements', async function () {
|
||||
await expectRevert(this.set.at(0), 'EnumerableSet: index out of bounds');
|
||||
});
|
||||
|
||||
it('removes added values', async function () {
|
||||
await this.set.add(accountA);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user