@@ -44,6 +44,7 @@ describe('ECDSA', function () {
44
44
45
45
// Recover the signer address from the generated message and signature.
46
46
expect ( await this . mock . $recover ( ethers . hashMessage ( TEST_MESSAGE ) , signature ) ) . to . equal ( this . signer ) ;
47
+ expect ( await this . mock . $recoverCalldata ( ethers . hashMessage ( TEST_MESSAGE ) , signature ) ) . to . equal ( this . signer ) ;
47
48
} ) ;
48
49
49
50
it ( 'returns signer address with correct signature for arbitrary length message' , async function ( ) {
@@ -52,11 +53,13 @@ describe('ECDSA', function () {
52
53
53
54
// Recover the signer address from the generated message and signature.
54
55
expect ( await this . mock . $recover ( ethers . hashMessage ( NON_HASH_MESSAGE ) , signature ) ) . to . equal ( this . signer ) ;
56
+ expect ( await this . mock . $recoverCalldata ( ethers . hashMessage ( NON_HASH_MESSAGE ) , signature ) ) . to . equal ( this . signer ) ;
55
57
} ) ;
56
58
57
59
it ( 'returns a different address' , async function ( ) {
58
60
const signature = await this . signer . signMessage ( TEST_MESSAGE ) ;
59
61
expect ( await this . mock . $recover ( WRONG_MESSAGE , signature ) ) . to . not . be . equal ( this . signer ) ;
62
+ expect ( await this . mock . $recoverCalldata ( WRONG_MESSAGE , signature ) ) . to . not . be . equal ( this . signer ) ;
60
63
} ) ;
61
64
62
65
it ( 'reverts with invalid signature' , async function ( ) {
@@ -66,6 +69,10 @@ describe('ECDSA', function () {
66
69
this . mock ,
67
70
'ECDSAInvalidSignature' ,
68
71
) ;
72
+ await expect ( this . mock . $recoverCalldata ( TEST_MESSAGE , signature ) ) . to . be . revertedWithCustomError (
73
+ this . mock ,
74
+ 'ECDSAInvalidSignature' ,
75
+ ) ;
69
76
} ) ;
70
77
} ) ;
71
78
@@ -79,6 +86,7 @@ describe('ECDSA', function () {
79
86
const v = '0x1b' ; // 27 = 1b.
80
87
const signature = ethers . concat ( [ signatureWithoutV , v ] ) ;
81
88
expect ( await this . mock . $recover ( TEST_MESSAGE , signature ) ) . to . equal ( signer ) ;
89
+ expect ( await this . mock . $recoverCalldata ( TEST_MESSAGE , signature ) ) . to . equal ( signer ) ;
82
90
83
91
const { r, s, yParityAndS : vs } = ethers . Signature . from ( signature ) ;
84
92
expect ( await this . mock . getFunction ( '$recover(bytes32,uint8,bytes32,bytes32)' ) ( TEST_MESSAGE , v , r , s ) ) . to . equal (
@@ -92,6 +100,7 @@ describe('ECDSA', function () {
92
100
const v = '0x1c' ; // 28 = 1c.
93
101
const signature = ethers . concat ( [ signatureWithoutV , v ] ) ;
94
102
expect ( await this . mock . $recover ( TEST_MESSAGE , signature ) ) . to . not . equal ( signer ) ;
103
+ expect ( await this . mock . $recoverCalldata ( TEST_MESSAGE , signature ) ) . to . not . equal ( signer ) ;
95
104
96
105
const { r, s, yParityAndS : vs } = ethers . Signature . from ( signature ) ;
97
106
expect (
@@ -110,6 +119,10 @@ describe('ECDSA', function () {
110
119
this . mock ,
111
120
'ECDSAInvalidSignature' ,
112
121
) ;
122
+ await expect ( this . mock . $recoverCalldata ( TEST_MESSAGE , signature ) ) . to . be . revertedWithCustomError (
123
+ this . mock ,
124
+ 'ECDSAInvalidSignature' ,
125
+ ) ;
113
126
114
127
const { r, s } = ethers . Signature . from ( signature ) ;
115
128
await expect (
@@ -126,6 +139,9 @@ describe('ECDSA', function () {
126
139
await expect ( this . mock . $recover ( TEST_MESSAGE , compactSerialized ) )
127
140
. to . be . revertedWithCustomError ( this . mock , 'ECDSAInvalidSignatureLength' )
128
141
. withArgs ( 64 ) ;
142
+ await expect ( this . mock . $recoverCalldata ( TEST_MESSAGE , compactSerialized ) )
143
+ . to . be . revertedWithCustomError ( this . mock , 'ECDSAInvalidSignatureLength' )
144
+ . withArgs ( 64 ) ;
129
145
} ) ;
130
146
} ) ;
131
147
@@ -139,6 +155,7 @@ describe('ECDSA', function () {
139
155
const v = '0x1c' ; // 28 = 1c.
140
156
const signature = ethers . concat ( [ signatureWithoutV , v ] ) ;
141
157
expect ( await this . mock . $recover ( TEST_MESSAGE , signature ) ) . to . equal ( signer ) ;
158
+ expect ( await this . mock . $recoverCalldata ( TEST_MESSAGE , signature ) ) . to . equal ( signer ) ;
142
159
143
160
const { r, s, yParityAndS : vs } = ethers . Signature . from ( signature ) ;
144
161
expect ( await this . mock . getFunction ( '$recover(bytes32,uint8,bytes32,bytes32)' ) ( TEST_MESSAGE , v , r , s ) ) . to . equal (
@@ -152,6 +169,7 @@ describe('ECDSA', function () {
152
169
const v = '0x1b' ; // 27 = 1b.
153
170
const signature = ethers . concat ( [ signatureWithoutV , v ] ) ;
154
171
expect ( await this . mock . $recover ( TEST_MESSAGE , signature ) ) . to . not . equal ( signer ) ;
172
+ expect ( await this . mock . $recoverCalldata ( TEST_MESSAGE , signature ) ) . to . not . equal ( signer ) ;
155
173
156
174
const { r, s, yParityAndS : vs } = ethers . Signature . from ( signature ) ;
157
175
expect (
@@ -170,6 +188,10 @@ describe('ECDSA', function () {
170
188
this . mock ,
171
189
'ECDSAInvalidSignature' ,
172
190
) ;
191
+ await expect ( this . mock . $recoverCalldata ( TEST_MESSAGE , signature ) ) . to . be . revertedWithCustomError (
192
+ this . mock ,
193
+ 'ECDSAInvalidSignature' ,
194
+ ) ;
173
195
174
196
const { r, s } = ethers . Signature . from ( signature ) ;
175
197
await expect (
@@ -186,6 +208,9 @@ describe('ECDSA', function () {
186
208
await expect ( this . mock . $recover ( TEST_MESSAGE , compactSerialized ) )
187
209
. to . be . revertedWithCustomError ( this . mock , 'ECDSAInvalidSignatureLength' )
188
210
. withArgs ( 64 ) ;
211
+ await expect ( this . mock . $recoverCalldata ( TEST_MESSAGE , compactSerialized ) )
212
+ . to . be . revertedWithCustomError ( this . mock , 'ECDSAInvalidSignatureLength' )
213
+ . withArgs ( 64 ) ;
189
214
} ) ;
190
215
} ) ;
191
216
@@ -202,6 +227,9 @@ describe('ECDSA', function () {
202
227
await expect ( this . mock . $recover ( message , highSSignature ) )
203
228
. to . be . revertedWithCustomError ( this . mock , 'ECDSAInvalidSignatureS' )
204
229
. withArgs ( s ) ;
230
+ await expect ( this . mock . $recoverCalldata ( message , highSSignature ) )
231
+ . to . be . revertedWithCustomError ( this . mock , 'ECDSAInvalidSignatureS' )
232
+ . withArgs ( s ) ;
205
233
await expect ( this . mock . getFunction ( '$recover(bytes32,uint8,bytes32,bytes32)' ) ( TEST_MESSAGE , v , r , s ) )
206
234
. to . be . revertedWithCustomError ( this . mock , 'ECDSAInvalidSignatureS' )
207
235
. withArgs ( s ) ;
0 commit comments