@@ -28,39 +28,55 @@ describe('Bytes', function () {
28
28
29
29
describe ( 'indexOf' , function ( ) {
30
30
it ( 'first' , async function ( ) {
31
- expect ( await this . mock . $indexOf ( lorem , ethers . toBeHex ( present ) ) ) . to . equal ( lorem . indexOf ( present ) ) ;
31
+ await expect ( this . mock . $indexOf ( lorem , ethers . toBeHex ( present ) ) ) . to . eventually . equal ( lorem . indexOf ( present ) ) ;
32
32
} ) ;
33
33
34
34
it ( 'from index' , async function ( ) {
35
35
for ( const start in Array ( lorem . length + 10 ) . fill ( ) ) {
36
36
const index = lorem . indexOf ( present , start ) ;
37
37
const result = index === - 1 ? ethers . MaxUint256 : index ;
38
- expect ( await this . mock . $indexOf ( lorem , ethers . toBeHex ( present ) , ethers . Typed . uint256 ( start ) ) ) . to . equal ( result ) ;
38
+ await expect (
39
+ this . mock . $indexOf ( lorem , ethers . toBeHex ( present ) , ethers . Typed . uint256 ( start ) ) ,
40
+ ) . to . eventually . equal ( result ) ;
39
41
}
40
42
} ) ;
41
43
42
44
it ( 'absent' , async function ( ) {
43
- expect ( await this . mock . $indexOf ( lorem , ethers . toBeHex ( absent ) ) ) . to . equal ( ethers . MaxUint256 ) ;
45
+ await expect ( this . mock . $indexOf ( lorem , ethers . toBeHex ( absent ) ) ) . to . eventually . equal ( ethers . MaxUint256 ) ;
46
+ } ) ;
47
+
48
+ it ( 'empty buffer' , async function ( ) {
49
+ await expect ( this . mock . $indexOf ( '0x' , '0x00' ) ) . to . eventually . equal ( ethers . MaxUint256 ) ;
50
+ await expect ( this . mock . $indexOf ( '0x' , '0x00' , ethers . Typed . uint256 ( 17 ) ) ) . to . eventually . equal ( ethers . MaxUint256 ) ;
44
51
} ) ;
45
52
} ) ;
46
53
47
54
describe ( 'lastIndexOf' , function ( ) {
48
55
it ( 'first' , async function ( ) {
49
- expect ( await this . mock . $lastIndexOf ( lorem , ethers . toBeHex ( present ) ) ) . to . equal ( lorem . lastIndexOf ( present ) ) ;
56
+ await expect ( this . mock . $lastIndexOf ( lorem , ethers . toBeHex ( present ) ) ) . to . eventually . equal (
57
+ lorem . lastIndexOf ( present ) ,
58
+ ) ;
50
59
} ) ;
51
60
52
61
it ( 'from index' , async function ( ) {
53
62
for ( const start in Array ( lorem . length + 10 ) . fill ( ) ) {
54
63
const index = lorem . lastIndexOf ( present , start ) ;
55
64
const result = index === - 1 ? ethers . MaxUint256 : index ;
56
- expect ( await this . mock . $lastIndexOf ( lorem , ethers . toBeHex ( present ) , ethers . Typed . uint256 ( start ) ) ) . to . equal (
57
- result ,
58
- ) ;
65
+ await expect (
66
+ this . mock . $lastIndexOf ( lorem , ethers . toBeHex ( present ) , ethers . Typed . uint256 ( start ) ) ,
67
+ ) . to . eventually . equal ( result ) ;
59
68
}
60
69
} ) ;
61
70
62
71
it ( 'absent' , async function ( ) {
63
- expect ( await this . mock . $lastIndexOf ( lorem , ethers . toBeHex ( absent ) ) ) . to . equal ( ethers . MaxUint256 ) ;
72
+ await expect ( this . mock . $lastIndexOf ( lorem , ethers . toBeHex ( absent ) ) ) . to . eventually . equal ( ethers . MaxUint256 ) ;
73
+ } ) ;
74
+
75
+ it ( 'empty buffer' , async function ( ) {
76
+ await expect ( this . mock . $lastIndexOf ( '0x' , '0x00' ) ) . to . eventually . equal ( ethers . MaxUint256 ) ;
77
+ await expect ( this . mock . $lastIndexOf ( '0x' , '0x00' , ethers . Typed . uint256 ( 17 ) ) ) . to . eventually . equal (
78
+ ethers . MaxUint256 ,
79
+ ) ;
64
80
} ) ;
65
81
} ) ;
66
82
@@ -73,8 +89,8 @@ describe('Bytes', function () {
73
89
} ) ) {
74
90
it ( descr , async function ( ) {
75
91
const result = ethers . hexlify ( lorem . slice ( start ) ) ;
76
- expect ( await this . mock . $slice ( lorem , start ) ) . to . equal ( result ) ;
77
- expect ( await this . mock . $splice ( lorem , start ) ) . to . equal ( result ) ;
92
+ await expect ( this . mock . $slice ( lorem , start ) ) . to . eventually . equal ( result ) ;
93
+ await expect ( this . mock . $splice ( lorem , start ) ) . to . eventually . equal ( result ) ;
78
94
} ) ;
79
95
}
80
96
} ) ;
@@ -89,8 +105,8 @@ describe('Bytes', function () {
89
105
} ) ) {
90
106
it ( descr , async function ( ) {
91
107
const result = ethers . hexlify ( lorem . slice ( start , end ) ) ;
92
- expect ( await this . mock . $slice ( lorem , start , ethers . Typed . uint256 ( end ) ) ) . to . equal ( result ) ;
93
- expect ( await this . mock . $splice ( lorem , start , ethers . Typed . uint256 ( end ) ) ) . to . equal ( result ) ;
108
+ await expect ( this . mock . $slice ( lorem , start , ethers . Typed . uint256 ( end ) ) ) . to . eventually . equal ( result ) ;
109
+ await expect ( this . mock . $splice ( lorem , start , ethers . Typed . uint256 ( end ) ) ) . to . eventually . equal ( result ) ;
94
110
} ) ;
95
111
}
96
112
} ) ;
0 commit comments