@@ -19,14 +19,16 @@ describe('MessageHashUtils', function () {
19
19
const message = ethers . randomBytes ( 32 ) ;
20
20
const expectedHash = ethers . hashMessage ( message ) ;
21
21
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
+ ) ;
23
25
} ) ;
24
26
25
27
it ( 'prefixes dynamic length data correctly' , async function ( ) {
26
28
const message = ethers . randomBytes ( 128 ) ;
27
29
const expectedHash = ethers . hashMessage ( message ) ;
28
30
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 ) ;
30
32
} ) ;
31
33
32
34
it ( 'version match for bytes32' , async function ( ) {
@@ -39,15 +41,42 @@ describe('MessageHashUtils', function () {
39
41
} ) ;
40
42
41
43
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 ( ) {
43
58
const verifier = ethers . Wallet . createRandom ( ) . address ;
44
59
const message = ethers . randomBytes ( 128 ) ;
45
60
const expectedHash = ethers . solidityPackedKeccak256 (
46
61
[ 'string' , 'address' , 'bytes' ] ,
47
62
[ '\x19\x00' , verifier , message ] ,
48
63
) ;
49
64
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 ) ;
51
80
} ) ;
52
81
} ) ;
53
82
@@ -62,7 +91,7 @@ describe('MessageHashUtils', function () {
62
91
const structhash = ethers . randomBytes ( 32 ) ;
63
92
const expectedHash = hashTypedData ( domain , structhash ) ;
64
93
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 ) ;
66
95
} ) ;
67
96
} ) ;
68
97
} ) ;
0 commit comments