@@ -69,12 +69,28 @@ describe('EnumerableSet', async () => {
6969 describe ( '#indexOf(bytes32)' , ( ) => {
7070 it ( 'returns index of the value' , async ( ) => {
7171 await instance [ 'add(bytes32)' ] ( zeroBytes32 ) ;
72- await instance [ 'add(bytes32)' ] ( oneBytes32 ) ;
7372 await instance [ 'add(bytes32)' ] ( twoBytes32 ) ;
73+ await instance [ 'add(bytes32)' ] ( oneBytes32 ) ;
7474
7575 expect ( await instance [ 'indexOf(bytes32)' ] ( zeroBytes32 ) ) . to . equal ( 0 ) ;
76- expect ( await instance [ 'indexOf(bytes32)' ] ( oneBytes32 ) ) . to . equal ( 1 ) ;
77- expect ( await instance [ 'indexOf(bytes32)' ] ( twoBytes32 ) ) . to . equal ( 2 ) ;
76+ expect ( await instance [ 'indexOf(bytes32)' ] ( oneBytes32 ) ) . to . equal ( 2 ) ;
77+ expect ( await instance [ 'indexOf(bytes32)' ] ( twoBytes32 ) ) . to . equal ( 1 ) ;
78+
79+ await instance [ 'remove(bytes32)' ] ( zeroBytes32 ) ;
80+ await instance [ 'remove(bytes32)' ] ( oneBytes32 ) ;
81+ await instance [ 'remove(bytes32)' ] ( twoBytes32 ) ;
82+
83+ expect ( await instance [ 'indexOf(bytes32)' ] ( twoBytes32 ) ) . to . be . equal (
84+ ethers . constants . MaxUint256 ,
85+ ) ;
86+
87+ expect ( await instance [ 'indexOf(bytes32)' ] ( oneBytes32 ) ) . to . be . equal (
88+ ethers . constants . MaxUint256 ,
89+ ) ;
90+
91+ expect ( await instance [ 'indexOf(bytes32)' ] ( zeroBytes32 ) ) . to . be . equal (
92+ ethers . constants . MaxUint256 ,
93+ ) ;
7894 } ) ;
7995
8096 it ( 'returns max uint256 if value does not exist' , async ( ) => {
@@ -159,43 +175,19 @@ describe('EnumerableSet', async () => {
159175 expect ( await instance . callStatic [ 'remove(bytes32)' ] ( zeroBytes32 ) ) . to
160176 . be . false ;
161177 } ) ;
178+ } ) ;
162179
163- it ( 'removes value from index mapping and array' , async ( ) => {
180+ describe ( '#toArray()' , ( ) => {
181+ it ( 'returns the set as an array' , async ( ) => {
164182 await instance [ 'add(bytes32)' ] ( zeroBytes32 ) ;
165- await instance [ 'add(bytes32)' ] ( oneBytes32 ) ;
166183 await instance [ 'add(bytes32)' ] ( twoBytes32 ) ;
184+ await instance [ 'add(bytes32)' ] ( oneBytes32 ) ;
167185
168- await instance [ 'remove(bytes32)' ] ( twoBytes32 ) ;
169- expect ( await instance [ 'length()' ] ( ) ) . to . be . equal ( 2 ) ;
170- expect ( await instance [ 'indexOf(bytes32)' ] ( twoBytes32 ) ) . to . be . equal (
171- ethers . constants . MaxUint256 ,
172- ) ;
173-
174- await instance [ 'remove(bytes32)' ] ( oneBytes32 ) ;
175- expect ( await instance [ 'length()' ] ( ) ) . to . be . equal ( 1 ) ;
176- expect ( await instance [ 'indexOf(bytes32)' ] ( oneBytes32 ) ) . to . be . equal (
177- ethers . constants . MaxUint256 ,
178- ) ;
179-
180- await instance [ 'remove(bytes32)' ] ( zeroBytes32 ) ;
181- expect ( await instance [ 'length()' ] ( ) ) . to . be . equal ( 0 ) ;
182- expect ( await instance [ 'indexOf(bytes32)' ] ( zeroBytes32 ) ) . to . be . equal (
183- ethers . constants . MaxUint256 ,
184- ) ;
185- } ) ;
186-
187- describe ( '#toArray()' , ( ) => {
188- it ( 'returns the set as an array' , async ( ) => {
189- await instance [ 'add(bytes32)' ] ( zeroBytes32 ) ;
190- await instance [ 'add(bytes32)' ] ( twoBytes32 ) ;
191- await instance [ 'add(bytes32)' ] ( oneBytes32 ) ;
192-
193- expect ( await instance [ 'toArray()' ] ( ) ) . to . deep . equal ( [
194- zeroBytes32 ,
195- twoBytes32 ,
196- oneBytes32 ,
197- ] ) ;
198- } ) ;
186+ expect ( await instance [ 'toArray()' ] ( ) ) . to . deep . equal ( [
187+ zeroBytes32 ,
188+ twoBytes32 ,
189+ oneBytes32 ,
190+ ] ) ;
199191 } ) ;
200192 } ) ;
201193 } ) ;
@@ -263,6 +255,22 @@ describe('EnumerableSet', async () => {
263255 expect ( await instance [ 'indexOf(address)' ] ( zeroAddress ) ) . to . equal ( 0 ) ;
264256 expect ( await instance [ 'indexOf(address)' ] ( oneAddress ) ) . to . equal ( 2 ) ;
265257 expect ( await instance [ 'indexOf(address)' ] ( twoAddress ) ) . to . equal ( 1 ) ;
258+
259+ await instance [ 'remove(address)' ] ( zeroAddress ) ;
260+ await instance [ 'remove(address)' ] ( oneAddress ) ;
261+ await instance [ 'remove(address)' ] ( twoAddress ) ;
262+
263+ expect ( await instance [ 'indexOf(address)' ] ( twoAddress ) ) . to . be . equal (
264+ ethers . constants . MaxUint256 ,
265+ ) ;
266+
267+ expect ( await instance [ 'indexOf(address)' ] ( oneAddress ) ) . to . be . equal (
268+ ethers . constants . MaxUint256 ,
269+ ) ;
270+
271+ expect ( await instance [ 'indexOf(address)' ] ( zeroAddress ) ) . to . be . equal (
272+ ethers . constants . MaxUint256 ,
273+ ) ;
266274 } ) ;
267275
268276 it ( 'returns max address if value does not exist' , async ( ) => {
@@ -347,30 +355,6 @@ describe('EnumerableSet', async () => {
347355 expect ( await instance . callStatic [ 'remove(address)' ] ( zeroAddress ) ) . to
348356 . be . false ;
349357 } ) ;
350-
351- it ( 'removes value from index mapping and array' , async ( ) => {
352- await instance [ 'add(address)' ] ( zeroAddress ) ;
353- await instance [ 'add(address)' ] ( oneAddress ) ;
354- await instance [ 'add(address)' ] ( twoAddress ) ;
355-
356- await instance [ 'remove(address)' ] ( twoAddress ) ;
357- expect ( await instance [ 'length()' ] ( ) ) . to . be . equal ( 2 ) ;
358- expect ( await instance [ 'indexOf(address)' ] ( twoAddress ) ) . to . be . equal (
359- ethers . constants . MaxUint256 ,
360- ) ;
361-
362- await instance [ 'remove(address)' ] ( oneAddress ) ;
363- expect ( await instance [ 'length()' ] ( ) ) . to . be . equal ( 1 ) ;
364- expect ( await instance [ 'indexOf(address)' ] ( oneAddress ) ) . to . be . equal (
365- ethers . constants . MaxUint256 ,
366- ) ;
367-
368- await instance [ 'remove(address)' ] ( zeroAddress ) ;
369- expect ( await instance [ 'length()' ] ( ) ) . to . be . equal ( 0 ) ;
370- expect ( await instance [ 'indexOf(address)' ] ( zeroAddress ) ) . to . be . equal (
371- ethers . constants . MaxUint256 ,
372- ) ;
373- } ) ;
374358 } ) ;
375359
376360 describe ( '#toArray()' , ( ) => {
@@ -451,6 +435,22 @@ describe('EnumerableSet', async () => {
451435 expect ( await instance [ 'indexOf(uint256)' ] ( zero ) ) . to . equal ( 0 ) ;
452436 expect ( await instance [ 'indexOf(uint256)' ] ( one ) ) . to . equal ( 2 ) ;
453437 expect ( await instance [ 'indexOf(uint256)' ] ( two ) ) . to . equal ( 1 ) ;
438+
439+ await instance [ 'remove(uint256)' ] ( zero ) ;
440+ await instance [ 'remove(uint256)' ] ( one ) ;
441+ await instance [ 'remove(uint256)' ] ( two ) ;
442+
443+ expect ( await instance [ 'indexOf(uint256)' ] ( two ) ) . to . be . equal (
444+ ethers . constants . MaxUint256 ,
445+ ) ;
446+
447+ expect ( await instance [ 'indexOf(uint256)' ] ( one ) ) . to . be . equal (
448+ ethers . constants . MaxUint256 ,
449+ ) ;
450+
451+ expect ( await instance [ 'indexOf(uint256)' ] ( zero ) ) . to . be . equal (
452+ ethers . constants . MaxUint256 ,
453+ ) ;
454454 } ) ;
455455
456456 it ( 'returns max uint256 if value does not exist' , async ( ) => {
@@ -525,30 +525,6 @@ describe('EnumerableSet', async () => {
525525 expect ( await instance . callStatic [ 'remove(uint256)' ] ( zero ) ) . to . be
526526 . false ;
527527 } ) ;
528-
529- it ( 'removes value from index mapping and array' , async ( ) => {
530- await instance [ 'add(uint256)' ] ( zero ) ;
531- await instance [ 'add(uint256)' ] ( one ) ;
532- await instance [ 'add(uint256)' ] ( two ) ;
533-
534- await instance [ 'remove(uint256)' ] ( two ) ;
535- expect ( await instance [ 'length()' ] ( ) ) . to . be . equal ( 2 ) ;
536- expect ( await instance [ 'indexOf(uint256)' ] ( two ) ) . to . be . equal (
537- ethers . constants . MaxUint256 ,
538- ) ;
539-
540- await instance [ 'remove(uint256)' ] ( one ) ;
541- expect ( await instance [ 'length()' ] ( ) ) . to . be . equal ( 1 ) ;
542- expect ( await instance [ 'indexOf(uint256)' ] ( one ) ) . to . be . equal (
543- ethers . constants . MaxUint256 ,
544- ) ;
545-
546- await instance [ 'remove(uint256)' ] ( zero ) ;
547- expect ( await instance [ 'length()' ] ( ) ) . to . be . equal ( 0 ) ;
548- expect ( await instance [ 'indexOf(uint256)' ] ( zero ) ) . to . be . equal (
549- ethers . constants . MaxUint256 ,
550- ) ;
551- } ) ;
552528 } ) ;
553529
554530 describe ( '#toArray()' , ( ) => {
0 commit comments