Skip to content

Commit 1fe644b

Browse files
committed
test: add avnu_paymaster_invoke test cases for message and type hashing
- Introduced new test cases for the TypedData name "avnu_paymaster_invoke" in TestGetMessageHash, TestGetTypeHash, and TestGetStructHash. - Each test case includes the corresponding address and expected hash values to ensure correct functionality.
1 parent 8ec1e76 commit 1fe644b

File tree

2 files changed

+97
-2
lines changed

2 files changed

+97
-2
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"types": {
3+
"StarknetDomain": [
4+
{
5+
"name": "name",
6+
"type": "shortstring"
7+
},
8+
{
9+
"name": "version",
10+
"type": "shortstring"
11+
},
12+
{
13+
"name": "chainId",
14+
"type": "shortstring"
15+
},
16+
{
17+
"name": "revision",
18+
"type": "shortstring"
19+
}
20+
],
21+
"OutsideExecution": [
22+
{
23+
"name": "Caller",
24+
"type": "ContractAddress"
25+
},
26+
{
27+
"name": "Nonce",
28+
"type": "felt"
29+
},
30+
{
31+
"name": "Execute After",
32+
"type": "u128"
33+
},
34+
{
35+
"name": "Execute Before",
36+
"type": "u128"
37+
},
38+
{
39+
"name": "Calls",
40+
"type": "Call*"
41+
}
42+
],
43+
"Call": [
44+
{
45+
"name": "To",
46+
"type": "ContractAddress"
47+
},
48+
{
49+
"name": "Selector",
50+
"type": "selector"
51+
},
52+
{
53+
"name": "Calldata",
54+
"type": "felt*"
55+
}
56+
]
57+
},
58+
"domain": {
59+
"name": "Account.execute_from_outside",
60+
"version": "2",
61+
"chainId": "SN_SEPOLIA",
62+
"revision": "1"
63+
},
64+
"primaryType": "OutsideExecution",
65+
"message": {
66+
"Caller": "0x75a180e18e56da1b1cae181c92a288f586f5fe22c18df21cf97886f1e4b316c",
67+
"Nonce": "0x89ac3804c1e246bb124ae7c586a17cd8",
68+
"Execute After": "0x1",
69+
"Execute Before": "0x68d2eea3",
70+
"Calls": [
71+
{
72+
"To": "0x669e24364ce0ae7ec2864fb03eedbe60cfbc9d1c74438d10fa4b86552907d54",
73+
"Selector": "0x2f0b3c5710379609eb5495f1ecd348cb28167711b73609fe565a72734550354",
74+
"Calldata": [
75+
"0x2710",
76+
"0x0"
77+
]
78+
}
79+
]
80+
}
81+
}

typedData/typedData_test.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var (
2323
"v1Nested",
2424
"allInOne",
2525
"example_enumNested",
26+
"avnu_paymaster_invoke",
2627
}
2728
)
2829

@@ -122,7 +123,6 @@ func TestGetMessageHash(t *testing.T) {
122123
ExpectedMessageHash string
123124
}
124125

125-
//nolint:dupl
126126
testSet := []testSetType{
127127
{
128128
TypedDataName: "baseExample",
@@ -174,6 +174,11 @@ func TestGetMessageHash(t *testing.T) {
174174
Address: "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826",
175175
ExpectedMessageHash: "0x691fc54567306a8ea5431130f1b98299e74a748ac391540a86736f20ef5f2b7",
176176
},
177+
{
178+
TypedDataName: "avnu_paymaster_invoke",
179+
Address: "0x05c74db20fa8f151bfd3a7a462cf2e8d4578a88aa4bd7a1746955201c48d8e5e",
180+
ExpectedMessageHash: "0x523f153f2a3ca228a2ea222fb5114437a9191bdade099667ef0c113f5444fa0",
181+
},
177182
}
178183

179184
for _, test := range testSet {
@@ -236,6 +241,11 @@ func TestGetTypeHash(t *testing.T) {
236241
TypeName: "Example",
237242
ExpectedHash: "0x2143bb787fabace39d62e9acf8b6e97d9a369000516c3e6ffd963dc1370fc1a",
238243
},
244+
{
245+
TypedDataName: "avnu_paymaster_invoke",
246+
TypeName: "OutsideExecution",
247+
ExpectedHash: "0x312b56c05a7965066ddbda31c016d8d05afc305071c0ca3cdc2192c3c2f1f0f",
248+
},
239249
}
240250
for _, test := range testSet {
241251
t.Run(test.TypedDataName, func(t *testing.T) {
@@ -268,7 +278,6 @@ func TestEncodeType(t *testing.T) {
268278
ExpectedEncode string
269279
}
270280

271-
//nolint:dupl
272281
testSet := []testSetType{
273282
{
274283
TypedDataName: "baseExample",
@@ -380,6 +389,11 @@ func TestGetStructHash(t *testing.T) {
380389
TypeName: "Example",
381390
ExpectedHash: "0x1e1bb5d477e92cbf562b3b766c5c1e5f8590f2df868d4c8249c0db8416f8c37",
382391
},
392+
{
393+
TypedDataName: "avnu_paymaster_invoke",
394+
TypeName: "OutsideExecution",
395+
ExpectedHash: "0x117e7ef9a7d447eb4bb3d9ebbb60594e0630f463ec7875f6fcc0ffad8d71c96",
396+
},
383397
}
384398
for _, test := range testSet {
385399
td := typedDataExamples[test.TypedDataName]

0 commit comments

Comments
 (0)