@@ -40,6 +40,8 @@ import (
4040var (
4141 testKey , _ = crypto .HexToECDSA ("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291" )
4242 testAddr = crypto .PubkeyToAddress (testKey .PublicKey )
43+ testSlot = common .HexToHash ("0xdeadbeef" )
44+ testValue = crypto .Keccak256Hash (testSlot [:])
4345 testBalance = big .NewInt (2e15 )
4446)
4547
@@ -73,7 +75,7 @@ func generateTestChain() (*core.Genesis, []*types.Block) {
7375 config := params .AllEthashProtocolChanges
7476 genesis := & core.Genesis {
7577 Config : config ,
76- Alloc : core.GenesisAlloc {testAddr : {Balance : testBalance }},
78+ Alloc : core.GenesisAlloc {testAddr : {Balance : testBalance , Storage : map [common. Hash ]common. Hash { testSlot : testValue } }},
7779 ExtraData : []byte ("test genesis" ),
7880 Timestamp : 9000 ,
7981 }
@@ -191,7 +193,7 @@ func testAccessList(t *testing.T, client *rpc.Client) {
191193func testGetProof (t * testing.T , client * rpc.Client ) {
192194 ec := New (client )
193195 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 )
195197 if err != nil {
196198 t .Fatal (err )
197199 }
@@ -208,6 +210,19 @@ func testGetProof(t *testing.T, client *rpc.Client) {
208210 if result .Balance .Cmp (balance ) != 0 {
209211 t .Fatalf ("invalid balance, want: %v got: %v" , balance , result .Balance )
210212 }
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+
211226}
212227
213228func testGCStats (t * testing.T , client * rpc.Client ) {
0 commit comments