@@ -40,6 +40,8 @@ import (
40
40
var (
41
41
testKey , _ = crypto .HexToECDSA ("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291" )
42
42
testAddr = crypto .PubkeyToAddress (testKey .PublicKey )
43
+ testSlot = common .HexToHash ("0xdeadbeef" )
44
+ testValue = crypto .Keccak256Hash (testSlot [:])
43
45
testBalance = big .NewInt (2e15 )
44
46
)
45
47
@@ -73,7 +75,7 @@ func generateTestChain() (*core.Genesis, []*types.Block) {
73
75
config := params .AllEthashProtocolChanges
74
76
genesis := & core.Genesis {
75
77
Config : config ,
76
- Alloc : core.GenesisAlloc {testAddr : {Balance : testBalance }},
78
+ Alloc : core.GenesisAlloc {testAddr : {Balance : testBalance , Storage : map [common. Hash ]common. Hash { testSlot : testValue } }},
77
79
ExtraData : []byte ("test genesis" ),
78
80
Timestamp : 9000 ,
79
81
}
@@ -191,7 +193,7 @@ func testAccessList(t *testing.T, client *rpc.Client) {
191
193
func testGetProof (t * testing.T , client * rpc.Client ) {
192
194
ec := New (client )
193
195
ethcl := ethclient .NewClient (client )
194
- result , err := ec .GetProof (context .Background (), testAddr , []string {}, nil )
196
+ result , err := ec .GetProof (context .Background (), testAddr , []string {testSlot . String () }, nil )
195
197
if err != nil {
196
198
t .Fatal (err )
197
199
}
@@ -208,6 +210,19 @@ func testGetProof(t *testing.T, client *rpc.Client) {
208
210
if result .Balance .Cmp (balance ) != 0 {
209
211
t .Fatalf ("invalid balance, want: %v got: %v" , balance , result .Balance )
210
212
}
213
+ // test storage
214
+ if len (result .StorageProof ) != 1 {
215
+ t .Fatalf ("invalid storage proof, want 1 proof, got %v proof(s)" , len (result .StorageProof ))
216
+ }
217
+ proof := result .StorageProof [0 ]
218
+ slotValue , _ := ethcl .StorageAt (context .Background (), testAddr , testSlot , nil )
219
+ if ! bytes .Equal (slotValue , proof .Value .Bytes ()) {
220
+ t .Fatalf ("invalid storage proof value, want: %v, got: %v" , slotValue , proof .Value .Bytes ())
221
+ }
222
+ if proof .Key != testSlot .String () {
223
+ t .Fatalf ("invalid storage proof key, want: %v, got: %v" , testSlot .String (), proof .Key )
224
+ }
225
+
211
226
}
212
227
213
228
func testGCStats (t * testing.T , client * rpc.Client ) {
0 commit comments