@@ -19,14 +19,16 @@ describe('MessageHashUtils', function () {
1919 const message = ethers . randomBytes ( 32 ) ;
2020 const expectedHash = ethers . hashMessage ( message ) ;
2121
22- expect ( await this . mock . getFunction ( '$toEthSignedMessageHash(bytes32)' ) ( message ) ) . to . equal ( expectedHash ) ;
22+ await expect ( this . mock . getFunction ( '$toEthSignedMessageHash(bytes32)' ) ( message ) ) . to . eventually . equal (
23+ expectedHash ,
24+ ) ;
2325 } ) ;
2426
2527 it ( 'prefixes dynamic length data correctly' , async function ( ) {
2628 const message = ethers . randomBytes ( 128 ) ;
2729 const expectedHash = ethers . hashMessage ( message ) ;
2830
29- expect ( await this . mock . getFunction ( '$toEthSignedMessageHash(bytes)' ) ( message ) ) . to . equal ( expectedHash ) ;
31+ await expect ( this . mock . getFunction ( '$toEthSignedMessageHash(bytes)' ) ( message ) ) . to . eventually . equal ( expectedHash ) ;
3032 } ) ;
3133
3234 it ( 'version match for bytes32' , async function ( ) {
@@ -39,15 +41,42 @@ describe('MessageHashUtils', function () {
3941 } ) ;
4042
4143 describe ( 'toDataWithIntendedValidatorHash' , function ( ) {
42- it ( 'returns the digest correctly' , async function ( ) {
44+ it ( 'returns the digest of `bytes32 messageHash` correctly' , async function ( ) {
45+ const verifier = ethers . Wallet . createRandom ( ) . address ;
46+ const message = ethers . randomBytes ( 32 ) ;
47+ const expectedHash = ethers . solidityPackedKeccak256 (
48+ [ 'string' , 'address' , 'bytes32' ] ,
49+ [ '\x19\x00' , verifier , message ] ,
50+ ) ;
51+
52+ await expect (
53+ this . mock . getFunction ( '$toDataWithIntendedValidatorHash(address,bytes32)' ) ( verifier , message ) ,
54+ ) . to . eventually . equal ( expectedHash ) ;
55+ } ) ;
56+
57+ it ( 'returns the digest of `bytes memory message` correctly' , async function ( ) {
4358 const verifier = ethers . Wallet . createRandom ( ) . address ;
4459 const message = ethers . randomBytes ( 128 ) ;
4560 const expectedHash = ethers . solidityPackedKeccak256 (
4661 [ 'string' , 'address' , 'bytes' ] ,
4762 [ '\x19\x00' , verifier , message ] ,
4863 ) ;
4964
50- expect ( await this . mock . $toDataWithIntendedValidatorHash ( verifier , message ) ) . to . equal ( expectedHash ) ;
65+ await expect (
66+ this . mock . getFunction ( '$toDataWithIntendedValidatorHash(address,bytes)' ) ( verifier , message ) ,
67+ ) . to . eventually . equal ( expectedHash ) ;
68+ } ) ;
69+
70+ it ( 'version match for bytes32' , async function ( ) {
71+ const verifier = ethers . Wallet . createRandom ( ) . address ;
72+ const message = ethers . randomBytes ( 32 ) ;
73+ const fixed = await this . mock . getFunction ( '$toDataWithIntendedValidatorHash(address,bytes)' ) ( verifier , message ) ;
74+ const dynamic = await this . mock . getFunction ( '$toDataWithIntendedValidatorHash(address,bytes32)' ) (
75+ verifier ,
76+ message ,
77+ ) ;
78+
79+ expect ( fixed ) . to . equal ( dynamic ) ;
5180 } ) ;
5281 } ) ;
5382
@@ -62,7 +91,7 @@ describe('MessageHashUtils', function () {
6291 const structhash = ethers . randomBytes ( 32 ) ;
6392 const expectedHash = hashTypedData ( domain , structhash ) ;
6493
65- expect ( await this . mock . $toTypedDataHash ( domainSeparator ( domain ) , structhash ) ) . to . equal ( expectedHash ) ;
94+ await expect ( this . mock . $toTypedDataHash ( domainSeparator ( domain ) , structhash ) ) . to . eventually . equal ( expectedHash ) ;
6695 } ) ;
6796 } ) ;
6897} ) ;
0 commit comments