@@ -28,39 +28,55 @@ describe('Bytes', function () {
2828
2929 describe ( 'indexOf' , function ( ) {
3030 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 ) ) ;
3232 } ) ;
3333
3434 it ( 'from index' , async function ( ) {
3535 for ( const start in Array ( lorem . length + 10 ) . fill ( ) ) {
3636 const index = lorem . indexOf ( present , start ) ;
3737 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 ) ;
3941 }
4042 } ) ;
4143
4244 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 ) ;
4451 } ) ;
4552 } ) ;
4653
4754 describe ( 'lastIndexOf' , function ( ) {
4855 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+ ) ;
5059 } ) ;
5160
5261 it ( 'from index' , async function ( ) {
5362 for ( const start in Array ( lorem . length + 10 ) . fill ( ) ) {
5463 const index = lorem . lastIndexOf ( present , start ) ;
5564 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 ) ;
5968 }
6069 } ) ;
6170
6271 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+ ) ;
6480 } ) ;
6581 } ) ;
6682
@@ -73,8 +89,8 @@ describe('Bytes', function () {
7389 } ) ) {
7490 it ( descr , async function ( ) {
7591 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 ) ;
7894 } ) ;
7995 }
8096 } ) ;
@@ -89,8 +105,8 @@ describe('Bytes', function () {
89105 } ) ) {
90106 it ( descr , async function ( ) {
91107 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 ) ;
94110 } ) ;
95111 }
96112 } ) ;
0 commit comments