EnumerableSet.test.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const { BN } = require('@openzeppelin/test-helpers');
  2. const EnumerableBytes32SetMock = artifacts.require('EnumerableBytes32SetMock');
  3. const EnumerableAddressSetMock = artifacts.require('EnumerableAddressSetMock');
  4. const EnumerableUintSetMock = artifacts.require('EnumerableUintSetMock');
  5. const { shouldBehaveLikeSet } = require('./EnumerableSet.behavior');
  6. contract('EnumerableSet', function (accounts) {
  7. // Bytes32Set
  8. describe('EnumerableBytes32Set', function () {
  9. const bytesA = '0xdeadbeef'.padEnd(66, '0');
  10. const bytesB = '0x0123456789'.padEnd(66, '0');
  11. const bytesC = '0x42424242'.padEnd(66, '0');
  12. beforeEach(async function () {
  13. this.set = await EnumerableBytes32SetMock.new();
  14. });
  15. shouldBehaveLikeSet(bytesA, bytesB, bytesC);
  16. });
  17. // AddressSet
  18. describe('EnumerableAddressSet', function () {
  19. const [accountA, accountB, accountC] = accounts;
  20. beforeEach(async function () {
  21. this.set = await EnumerableAddressSetMock.new();
  22. });
  23. shouldBehaveLikeSet(accountA, accountB, accountC);
  24. });
  25. // UintSet
  26. describe('EnumerableUintSet', function () {
  27. const uintA = new BN('1234');
  28. const uintB = new BN('5678');
  29. const uintC = new BN('9101112');
  30. beforeEach(async function () {
  31. this.set = await EnumerableUintSetMock.new();
  32. });
  33. shouldBehaveLikeSet(uintA, uintB, uintC);
  34. });
  35. });