Fix .gitignore: stop tracking ignored files

This commit is contained in:
5t4l1n
2025-07-27 10:39:02 +05:30
parent b42747e9a3
commit 3a87ef0576
625 changed files with 88566 additions and 63 deletions
@@ -0,0 +1,145 @@
const { BN } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const BitMap = artifacts.require('$BitMaps');
contract('BitMap', function () {
const keyA = new BN('7891');
const keyB = new BN('451');
const keyC = new BN('9592328');
beforeEach(async function () {
this.bitmap = await BitMap.new();
});
it('starts empty', async function () {
expect(await this.bitmap.$get(0, keyA)).to.equal(false);
expect(await this.bitmap.$get(0, keyB)).to.equal(false);
expect(await this.bitmap.$get(0, keyC)).to.equal(false);
});
describe('setTo', function () {
it('set a key to true', async function () {
await this.bitmap.$setTo(0, keyA, true);
expect(await this.bitmap.$get(0, keyA)).to.equal(true);
expect(await this.bitmap.$get(0, keyB)).to.equal(false);
expect(await this.bitmap.$get(0, keyC)).to.equal(false);
});
it('set a key to false', async function () {
await this.bitmap.$setTo(0, keyA, true);
await this.bitmap.$setTo(0, keyA, false);
expect(await this.bitmap.$get(0, keyA)).to.equal(false);
expect(await this.bitmap.$get(0, keyB)).to.equal(false);
expect(await this.bitmap.$get(0, keyC)).to.equal(false);
});
it('set several consecutive keys', async function () {
await this.bitmap.$setTo(0, keyA.addn(0), true);
await this.bitmap.$setTo(0, keyA.addn(1), true);
await this.bitmap.$setTo(0, keyA.addn(2), true);
await this.bitmap.$setTo(0, keyA.addn(3), true);
await this.bitmap.$setTo(0, keyA.addn(4), true);
await this.bitmap.$setTo(0, keyA.addn(2), false);
await this.bitmap.$setTo(0, keyA.addn(4), false);
expect(await this.bitmap.$get(0, keyA.addn(0))).to.equal(true);
expect(await this.bitmap.$get(0, keyA.addn(1))).to.equal(true);
expect(await this.bitmap.$get(0, keyA.addn(2))).to.equal(false);
expect(await this.bitmap.$get(0, keyA.addn(3))).to.equal(true);
expect(await this.bitmap.$get(0, keyA.addn(4))).to.equal(false);
});
});
describe('set', function () {
it('adds a key', async function () {
await this.bitmap.$set(0, keyA);
expect(await this.bitmap.$get(0, keyA)).to.equal(true);
expect(await this.bitmap.$get(0, keyB)).to.equal(false);
expect(await this.bitmap.$get(0, keyC)).to.equal(false);
});
it('adds several keys', async function () {
await this.bitmap.$set(0, keyA);
await this.bitmap.$set(0, keyB);
expect(await this.bitmap.$get(0, keyA)).to.equal(true);
expect(await this.bitmap.$get(0, keyB)).to.equal(true);
expect(await this.bitmap.$get(0, keyC)).to.equal(false);
});
it('adds several consecutive keys', async function () {
await this.bitmap.$set(0, keyA.addn(0));
await this.bitmap.$set(0, keyA.addn(1));
await this.bitmap.$set(0, keyA.addn(3));
expect(await this.bitmap.$get(0, keyA.addn(0))).to.equal(true);
expect(await this.bitmap.$get(0, keyA.addn(1))).to.equal(true);
expect(await this.bitmap.$get(0, keyA.addn(2))).to.equal(false);
expect(await this.bitmap.$get(0, keyA.addn(3))).to.equal(true);
expect(await this.bitmap.$get(0, keyA.addn(4))).to.equal(false);
});
});
describe('unset', function () {
it('removes added keys', async function () {
await this.bitmap.$set(0, keyA);
await this.bitmap.$set(0, keyB);
await this.bitmap.$unset(0, keyA);
expect(await this.bitmap.$get(0, keyA)).to.equal(false);
expect(await this.bitmap.$get(0, keyB)).to.equal(true);
expect(await this.bitmap.$get(0, keyC)).to.equal(false);
});
it('removes consecutive added keys', async function () {
await this.bitmap.$set(0, keyA.addn(0));
await this.bitmap.$set(0, keyA.addn(1));
await this.bitmap.$set(0, keyA.addn(3));
await this.bitmap.$unset(0, keyA.addn(1));
expect(await this.bitmap.$get(0, keyA.addn(0))).to.equal(true);
expect(await this.bitmap.$get(0, keyA.addn(1))).to.equal(false);
expect(await this.bitmap.$get(0, keyA.addn(2))).to.equal(false);
expect(await this.bitmap.$get(0, keyA.addn(3))).to.equal(true);
expect(await this.bitmap.$get(0, keyA.addn(4))).to.equal(false);
});
it('adds and removes multiple keys', async function () {
// []
await this.bitmap.$set(0, keyA);
await this.bitmap.$set(0, keyC);
// [A, C]
await this.bitmap.$unset(0, keyA);
await this.bitmap.$unset(0, keyB);
// [C]
await this.bitmap.$set(0, keyB);
// [C, B]
await this.bitmap.$set(0, keyA);
await this.bitmap.$unset(0, keyC);
// [A, B]
await this.bitmap.$set(0, keyA);
await this.bitmap.$set(0, keyB);
// [A, B]
await this.bitmap.$set(0, keyC);
await this.bitmap.$unset(0, keyA);
// [B, C]
await this.bitmap.$set(0, keyA);
await this.bitmap.$unset(0, keyB);
// [A, C]
expect(await this.bitmap.$get(0, keyA)).to.equal(true);
expect(await this.bitmap.$get(0, keyB)).to.equal(false);
expect(await this.bitmap.$get(0, keyC)).to.equal(true);
});
});
});
@@ -0,0 +1,99 @@
const { expectEvent } = require('@openzeppelin/test-helpers');
const { expectRevertCustomError } = require('../../helpers/customError');
const DoubleEndedQueue = artifacts.require('$DoubleEndedQueue');
/** Rebuild the content of the deque as a JS array. */
const getContent = deque =>
deque.$length(0).then(bn =>
Promise.all(
Array(bn.toNumber())
.fill()
.map((_, i) => deque.$at(0, i)),
),
);
contract('DoubleEndedQueue', function () {
const bytesA = '0xdeadbeef'.padEnd(66, '0');
const bytesB = '0x0123456789'.padEnd(66, '0');
const bytesC = '0x42424242'.padEnd(66, '0');
const bytesD = '0x171717'.padEnd(66, '0');
beforeEach(async function () {
this.deque = await DoubleEndedQueue.new();
});
describe('when empty', function () {
it('getters', async function () {
expect(await this.deque.$empty(0)).to.be.equal(true);
expect(await getContent(this.deque)).to.have.ordered.members([]);
});
it('reverts on accesses', async function () {
await expectRevertCustomError(this.deque.$popBack(0), 'Empty()');
await expectRevertCustomError(this.deque.$popFront(0), 'Empty()');
await expectRevertCustomError(this.deque.$back(0), 'Empty()');
await expectRevertCustomError(this.deque.$front(0), 'Empty()');
});
});
describe('when not empty', function () {
beforeEach(async function () {
await this.deque.$pushBack(0, bytesB);
await this.deque.$pushFront(0, bytesA);
await this.deque.$pushBack(0, bytesC);
this.content = [bytesA, bytesB, bytesC];
});
it('getters', async function () {
expect(await this.deque.$empty(0)).to.be.equal(false);
expect(await this.deque.$length(0)).to.be.bignumber.equal(this.content.length.toString());
expect(await this.deque.$front(0)).to.be.equal(this.content[0]);
expect(await this.deque.$back(0)).to.be.equal(this.content[this.content.length - 1]);
expect(await getContent(this.deque)).to.have.ordered.members(this.content);
});
it('out of bounds access', async function () {
await expectRevertCustomError(this.deque.$at(0, this.content.length), 'OutOfBounds()');
});
describe('push', function () {
it('front', async function () {
await this.deque.$pushFront(0, bytesD);
this.content.unshift(bytesD); // add element at the beginning
expect(await getContent(this.deque)).to.have.ordered.members(this.content);
});
it('back', async function () {
await this.deque.$pushBack(0, bytesD);
this.content.push(bytesD); // add element at the end
expect(await getContent(this.deque)).to.have.ordered.members(this.content);
});
});
describe('pop', function () {
it('front', async function () {
const value = this.content.shift(); // remove first element
expectEvent(await this.deque.$popFront(0), 'return$popFront', { value });
expect(await getContent(this.deque)).to.have.ordered.members(this.content);
});
it('back', async function () {
const value = this.content.pop(); // remove last element
expectEvent(await this.deque.$popBack(0), 'return$popBack', { value });
expect(await getContent(this.deque)).to.have.ordered.members(this.content);
});
});
it('clear', async function () {
await this.deque.$clear(0);
expect(await this.deque.$empty(0)).to.be.equal(true);
expect(await getContent(this.deque)).to.have.ordered.members([]);
});
});
});
@@ -0,0 +1,185 @@
const { expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const zip = require('lodash.zip');
function shouldBehaveLikeMap(keys, values, zeroValue, methods, events) {
const [keyA, keyB, keyC] = keys;
const [valueA, valueB, valueC] = values;
async function expectMembersMatch(map, keys, values) {
expect(keys.length).to.equal(values.length);
await Promise.all(keys.map(async key => expect(await methods.contains(map, key)).to.equal(true)));
expect(await methods.length(map)).to.bignumber.equal(keys.length.toString());
expect((await Promise.all(keys.map(key => methods.get(map, key)))).map(k => k.toString())).to.have.same.members(
values.map(value => value.toString()),
);
// To compare key-value pairs, we zip keys and values, and convert BNs to
// strings to workaround Chai limitations when dealing with nested arrays
expect(
await Promise.all(
[...Array(keys.length).keys()].map(async index => {
const entry = await methods.at(map, index);
return [entry[0].toString(), entry[1].toString()];
}),
),
).to.have.same.deep.members(
zip(
keys.map(k => k.toString()),
values.map(v => v.toString()),
),
);
// This also checks that both arrays have the same length
expect((await methods.keys(map)).map(k => k.toString())).to.have.same.members(keys.map(key => key.toString()));
}
it('starts empty', async function () {
expect(await methods.contains(this.map, keyA)).to.equal(false);
await expectMembersMatch(this.map, [], []);
});
describe('set', function () {
it('adds a key', async function () {
const receipt = await methods.set(this.map, keyA, valueA);
expectEvent(receipt, events.setReturn, { ret0: true });
await expectMembersMatch(this.map, [keyA], [valueA]);
});
it('adds several keys', async function () {
await methods.set(this.map, keyA, valueA);
await methods.set(this.map, keyB, valueB);
await expectMembersMatch(this.map, [keyA, keyB], [valueA, valueB]);
expect(await methods.contains(this.map, keyC)).to.equal(false);
});
it('returns false when adding keys already in the set', async function () {
await methods.set(this.map, keyA, valueA);
const receipt = await methods.set(this.map, keyA, valueA);
expectEvent(receipt, events.setReturn, { ret0: false });
await expectMembersMatch(this.map, [keyA], [valueA]);
});
it('updates values for keys already in the set', async function () {
await methods.set(this.map, keyA, valueA);
await methods.set(this.map, keyA, valueB);
await expectMembersMatch(this.map, [keyA], [valueB]);
});
});
describe('remove', function () {
it('removes added keys', async function () {
await methods.set(this.map, keyA, valueA);
const receipt = await methods.remove(this.map, keyA);
expectEvent(receipt, events.removeReturn, { ret0: true });
expect(await methods.contains(this.map, keyA)).to.equal(false);
await expectMembersMatch(this.map, [], []);
});
it('returns false when removing keys not in the set', async function () {
const receipt = await methods.remove(this.map, keyA);
expectEvent(receipt, events.removeReturn, { ret0: false });
expect(await methods.contains(this.map, keyA)).to.equal(false);
});
it('adds and removes multiple keys', async function () {
// []
await methods.set(this.map, keyA, valueA);
await methods.set(this.map, keyC, valueC);
// [A, C]
await methods.remove(this.map, keyA);
await methods.remove(this.map, keyB);
// [C]
await methods.set(this.map, keyB, valueB);
// [C, B]
await methods.set(this.map, keyA, valueA);
await methods.remove(this.map, keyC);
// [A, B]
await methods.set(this.map, keyA, valueA);
await methods.set(this.map, keyB, valueB);
// [A, B]
await methods.set(this.map, keyC, valueC);
await methods.remove(this.map, keyA);
// [B, C]
await methods.set(this.map, keyA, valueA);
await methods.remove(this.map, keyB);
// [A, C]
await expectMembersMatch(this.map, [keyA, keyC], [valueA, valueC]);
expect(await methods.contains(this.map, keyA)).to.equal(true);
expect(await methods.contains(this.map, keyB)).to.equal(false);
expect(await methods.contains(this.map, keyC)).to.equal(true);
});
});
describe('read', function () {
beforeEach(async function () {
await methods.set(this.map, keyA, valueA);
});
describe('get', function () {
it('existing value', async function () {
expect(await methods.get(this.map, keyA).then(r => r.toString())).to.be.equal(valueA.toString());
});
it('missing value', async function () {
await expectRevert(methods.get(this.map, keyB), 'EnumerableMap: nonexistent key');
});
});
describe('get with message', function () {
it('existing value', async function () {
expect(await methods.getWithMessage(this.map, keyA, 'custom error string').then(r => r.toString())).to.be.equal(
valueA.toString(),
);
});
it('missing value', async function () {
await expectRevert(methods.getWithMessage(this.map, keyB, 'custom error string'), 'custom error string');
});
});
describe('tryGet', function () {
it('existing value', async function () {
const result = await methods.tryGet(this.map, keyA);
expect(result['0']).to.be.equal(true);
expect(result['1'].toString()).to.be.equal(valueA.toString());
});
it('missing value', async function () {
const result = await methods.tryGet(this.map, keyB);
expect(result['0']).to.be.equal(false);
expect(result['1'].toString()).to.be.equal(zeroValue.toString());
});
});
});
}
module.exports = {
shouldBehaveLikeMap,
};
@@ -0,0 +1,154 @@
const { BN, constants } = require('@openzeppelin/test-helpers');
const { mapValues } = require('../../helpers/map-values');
const EnumerableMap = artifacts.require('$EnumerableMap');
const { shouldBehaveLikeMap } = require('./EnumerableMap.behavior');
const getMethods = ms => {
return mapValues(
ms,
m =>
(self, ...args) =>
self.methods[m](0, ...args),
);
};
// Get the name of the library. In the transpiled code it will be EnumerableMapUpgradeable.
const library = EnumerableMap._json.contractName.replace(/^\$/, '');
contract('EnumerableMap', function (accounts) {
const [accountA, accountB, accountC] = accounts;
const keyA = new BN('7891');
const keyB = new BN('451');
const keyC = new BN('9592328');
const bytesA = '0xdeadbeef'.padEnd(66, '0');
const bytesB = '0x0123456789'.padEnd(66, '0');
const bytesC = '0x42424242'.padEnd(66, '0');
beforeEach(async function () {
this.map = await EnumerableMap.new();
});
// AddressToUintMap
describe('AddressToUintMap', function () {
shouldBehaveLikeMap(
[accountA, accountB, accountC],
[keyA, keyB, keyC],
new BN('0'),
getMethods({
set: '$set(uint256,address,uint256)',
get: '$get(uint256,address)',
getWithMessage: '$get(uint256,address,string)',
tryGet: '$tryGet(uint256,address)',
remove: '$remove(uint256,address)',
length: `$length_${library}_AddressToUintMap(uint256)`,
at: `$at_${library}_AddressToUintMap(uint256,uint256)`,
contains: '$contains(uint256,address)',
keys: `$keys_${library}_AddressToUintMap(uint256)`,
}),
{
setReturn: `return$set_${library}_AddressToUintMap_address_uint256`,
removeReturn: `return$remove_${library}_AddressToUintMap_address`,
},
);
});
// UintToAddressMap
describe('UintToAddressMap', function () {
shouldBehaveLikeMap(
[keyA, keyB, keyC],
[accountA, accountB, accountC],
constants.ZERO_ADDRESS,
getMethods({
set: '$set(uint256,uint256,address)',
get: `$get_${library}_UintToAddressMap(uint256,uint256)`,
getWithMessage: `$get_${library}_UintToAddressMap(uint256,uint256,string)`,
tryGet: `$tryGet_${library}_UintToAddressMap(uint256,uint256)`,
remove: `$remove_${library}_UintToAddressMap(uint256,uint256)`,
length: `$length_${library}_UintToAddressMap(uint256)`,
at: `$at_${library}_UintToAddressMap(uint256,uint256)`,
contains: `$contains_${library}_UintToAddressMap(uint256,uint256)`,
keys: `$keys_${library}_UintToAddressMap(uint256)`,
}),
{
setReturn: `return$set_${library}_UintToAddressMap_uint256_address`,
removeReturn: `return$remove_${library}_UintToAddressMap_uint256`,
},
);
});
// Bytes32ToBytes32Map
describe('Bytes32ToBytes32Map', function () {
shouldBehaveLikeMap(
[keyA, keyB, keyC].map(k => '0x' + k.toString(16).padEnd(64, '0')),
[bytesA, bytesB, bytesC],
constants.ZERO_BYTES32,
getMethods({
set: '$set(uint256,bytes32,bytes32)',
get: `$get_${library}_Bytes32ToBytes32Map(uint256,bytes32)`,
getWithMessage: `$get_${library}_Bytes32ToBytes32Map(uint256,bytes32,string)`,
tryGet: `$tryGet_${library}_Bytes32ToBytes32Map(uint256,bytes32)`,
remove: `$remove_${library}_Bytes32ToBytes32Map(uint256,bytes32)`,
length: `$length_${library}_Bytes32ToBytes32Map(uint256)`,
at: `$at_${library}_Bytes32ToBytes32Map(uint256,uint256)`,
contains: `$contains_${library}_Bytes32ToBytes32Map(uint256,bytes32)`,
keys: `$keys_${library}_Bytes32ToBytes32Map(uint256)`,
}),
{
setReturn: `return$set_${library}_Bytes32ToBytes32Map_bytes32_bytes32`,
removeReturn: `return$remove_${library}_Bytes32ToBytes32Map_bytes32`,
},
);
});
// UintToUintMap
describe('UintToUintMap', function () {
shouldBehaveLikeMap(
[keyA, keyB, keyC],
[keyA, keyB, keyC].map(k => k.add(new BN('1332'))),
new BN('0'),
getMethods({
set: '$set(uint256,uint256,uint256)',
get: `$get_${library}_UintToUintMap(uint256,uint256)`,
getWithMessage: `$get_${library}_UintToUintMap(uint256,uint256,string)`,
tryGet: `$tryGet_${library}_UintToUintMap(uint256,uint256)`,
remove: `$remove_${library}_UintToUintMap(uint256,uint256)`,
length: `$length_${library}_UintToUintMap(uint256)`,
at: `$at_${library}_UintToUintMap(uint256,uint256)`,
contains: `$contains_${library}_UintToUintMap(uint256,uint256)`,
keys: `$keys_${library}_UintToUintMap(uint256)`,
}),
{
setReturn: `return$set_${library}_UintToUintMap_uint256_uint256`,
removeReturn: `return$remove_${library}_UintToUintMap_uint256`,
},
);
});
// Bytes32ToUintMap
describe('Bytes32ToUintMap', function () {
shouldBehaveLikeMap(
[bytesA, bytesB, bytesC],
[keyA, keyB, keyC],
new BN('0'),
getMethods({
set: '$set(uint256,bytes32,uint256)',
get: `$get_${library}_Bytes32ToUintMap(uint256,bytes32)`,
getWithMessage: `$get_${library}_Bytes32ToUintMap(uint256,bytes32,string)`,
tryGet: `$tryGet_${library}_Bytes32ToUintMap(uint256,bytes32)`,
remove: `$remove_${library}_Bytes32ToUintMap(uint256,bytes32)`,
length: `$length_${library}_Bytes32ToUintMap(uint256)`,
at: `$at_${library}_Bytes32ToUintMap(uint256,uint256)`,
contains: `$contains_${library}_Bytes32ToUintMap(uint256,bytes32)`,
keys: `$keys_${library}_Bytes32ToUintMap(uint256)`,
}),
{
setReturn: `return$set_${library}_Bytes32ToUintMap_bytes32_uint256`,
removeReturn: `return$remove_${library}_Bytes32ToUintMap_bytes32`,
},
);
});
});
@@ -0,0 +1,129 @@
const { expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
function shouldBehaveLikeSet(values, methods, events) {
const [valueA, valueB, valueC] = values;
async function expectMembersMatch(set, values) {
const contains = await Promise.all(values.map(value => methods.contains(set, value)));
expect(contains.every(Boolean)).to.be.equal(true);
const length = await methods.length(set);
expect(length).to.bignumber.equal(values.length.toString());
// To compare values we convert to strings to workaround Chai
// limitations when dealing with nested arrays (required for BNs)
const indexedValues = await Promise.all(
Array(values.length)
.fill()
.map((_, index) => methods.at(set, index)),
);
expect(indexedValues.map(v => v.toString())).to.have.same.members(values.map(v => v.toString()));
const returnedValues = await methods.values(set);
expect(returnedValues.map(v => v.toString())).to.have.same.members(values.map(v => v.toString()));
}
it('starts empty', async function () {
expect(await methods.contains(this.set, valueA)).to.equal(false);
await expectMembersMatch(this.set, []);
});
describe('add', function () {
it('adds a value', async function () {
const receipt = await methods.add(this.set, valueA);
expectEvent(receipt, events.addReturn, { ret0: true });
await expectMembersMatch(this.set, [valueA]);
});
it('adds several values', async function () {
await methods.add(this.set, valueA);
await methods.add(this.set, valueB);
await expectMembersMatch(this.set, [valueA, valueB]);
expect(await methods.contains(this.set, valueC)).to.equal(false);
});
it('returns false when adding values already in the set', async function () {
await methods.add(this.set, valueA);
const receipt = await methods.add(this.set, valueA);
expectEvent(receipt, events.addReturn, { ret0: false });
await expectMembersMatch(this.set, [valueA]);
});
});
describe('at', function () {
it('reverts when retrieving non-existent elements', async function () {
await expectRevert.unspecified(methods.at(this.set, 0));
});
});
describe('remove', function () {
it('removes added values', async function () {
await methods.add(this.set, valueA);
const receipt = await methods.remove(this.set, valueA);
expectEvent(receipt, events.removeReturn, { ret0: true });
expect(await methods.contains(this.set, valueA)).to.equal(false);
await expectMembersMatch(this.set, []);
});
it('returns false when removing values not in the set', async function () {
const receipt = await methods.remove(this.set, valueA);
expectEvent(receipt, events.removeReturn, { ret0: false });
expect(await methods.contains(this.set, valueA)).to.equal(false);
});
it('adds and removes multiple values', async function () {
// []
await methods.add(this.set, valueA);
await methods.add(this.set, valueC);
// [A, C]
await methods.remove(this.set, valueA);
await methods.remove(this.set, valueB);
// [C]
await methods.add(this.set, valueB);
// [C, B]
await methods.add(this.set, valueA);
await methods.remove(this.set, valueC);
// [A, B]
await methods.add(this.set, valueA);
await methods.add(this.set, valueB);
// [A, B]
await methods.add(this.set, valueC);
await methods.remove(this.set, valueA);
// [B, C]
await methods.add(this.set, valueA);
await methods.remove(this.set, valueB);
// [A, C]
await expectMembersMatch(this.set, [valueA, valueC]);
expect(await methods.contains(this.set, valueB)).to.equal(false);
});
});
}
module.exports = {
shouldBehaveLikeSet,
};
@@ -0,0 +1,79 @@
const EnumerableSet = artifacts.require('$EnumerableSet');
const { mapValues } = require('../../helpers/map-values');
const { shouldBehaveLikeSet } = require('./EnumerableSet.behavior');
const getMethods = ms => {
return mapValues(
ms,
m =>
(self, ...args) =>
self.methods[m](0, ...args),
);
};
// Get the name of the library. In the transpiled code it will be EnumerableSetUpgradeable.
const library = EnumerableSet._json.contractName.replace(/^\$/, '');
contract('EnumerableSet', function (accounts) {
beforeEach(async function () {
this.set = await EnumerableSet.new();
});
// Bytes32Set
describe('EnumerableBytes32Set', function () {
shouldBehaveLikeSet(
['0xdeadbeef', '0x0123456789', '0x42424242'].map(e => e.padEnd(66, '0')),
getMethods({
add: '$add(uint256,bytes32)',
remove: '$remove(uint256,bytes32)',
contains: '$contains(uint256,bytes32)',
length: `$length_${library}_Bytes32Set(uint256)`,
at: `$at_${library}_Bytes32Set(uint256,uint256)`,
values: `$values_${library}_Bytes32Set(uint256)`,
}),
{
addReturn: `return$add_${library}_Bytes32Set_bytes32`,
removeReturn: `return$remove_${library}_Bytes32Set_bytes32`,
},
);
});
// AddressSet
describe('EnumerableAddressSet', function () {
shouldBehaveLikeSet(
accounts,
getMethods({
add: '$add(uint256,address)',
remove: '$remove(uint256,address)',
contains: '$contains(uint256,address)',
length: `$length_${library}_AddressSet(uint256)`,
at: `$at_${library}_AddressSet(uint256,uint256)`,
values: `$values_${library}_AddressSet(uint256)`,
}),
{
addReturn: `return$add_${library}_AddressSet_address`,
removeReturn: `return$remove_${library}_AddressSet_address`,
},
);
});
// UintSet
describe('EnumerableUintSet', function () {
shouldBehaveLikeSet(
[1234, 5678, 9101112].map(e => web3.utils.toBN(e)),
getMethods({
add: '$add(uint256,uint256)',
remove: '$remove(uint256,uint256)',
contains: '$contains(uint256,uint256)',
length: `$length_${library}_UintSet(uint256)`,
at: `$at_${library}_UintSet(uint256,uint256)`,
values: `$values_${library}_UintSet(uint256)`,
}),
{
addReturn: `return$add_${library}_UintSet_uint256`,
removeReturn: `return$remove_${library}_UintSet_uint256`,
},
);
});
});