@@ -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
@@ -77,7 +79,7 @@ func generateTestChain() (*core.Genesis, []*types.Block) {
7779 config := params .AllEthashProtocolChanges
7880 genesis := & core.Genesis {
7981 Config : config ,
80- Alloc : core.GenesisAlloc {testAddr : {Balance : testBalance }},
82+ Alloc : core.GenesisAlloc {testAddr : {Balance : testBalance , Storage : map [common. Hash ]common. Hash { testSlot : testValue } }},
8183 ExtraData : []byte ("test genesis" ),
8284 Timestamp : 9000 ,
8385 }
@@ -195,7 +197,7 @@ func testAccessList(t *testing.T, client *rpc.Client) {
195197func testGetProof (t * testing.T , client * rpc.Client ) {
196198 ec := New (client )
197199 ethcl := ethclient .NewClient (client )
198- result , err := ec .GetProof (context .Background (), testAddr , []string {}, nil )
200+ result , err := ec .GetProof (context .Background (), testAddr , []string {testSlot . String () }, nil )
199201 if err != nil {
200202 t .Fatal (err )
201203 }
@@ -212,6 +214,19 @@ func testGetProof(t *testing.T, client *rpc.Client) {
212214 if result .Balance .Cmp (balance ) != 0 {
213215 t .Fatalf ("invalid balance, want: %v got: %v" , balance , result .Balance )
214216 }
217+ // test storage
218+ if len (result .StorageProof ) != 1 {
219+ t .Fatalf ("invalid storage proof, want 1 proof, got %v proof(s)" , len (result .StorageProof ))
220+ }
221+ proof := result .StorageProof [0 ]
222+ slotValue , _ := ethcl .StorageAt (context .Background (), testAddr , testSlot , nil )
223+ if ! bytes .Equal (slotValue , proof .Value .Bytes ()) {
224+ t .Fatalf ("invalid storage proof value, want: %v, got: %v" , slotValue , proof .Value .Bytes ())
225+ }
226+ if proof .Key != testSlot .String () {
227+ t .Fatalf ("invalid storage proof key, want: %v, got: %v" , testSlot .String (), proof .Key )
228+ }
229+
215230}
216231
217232func testGCStats (t * testing.T , client * rpc.Client ) {
0 commit comments