|
43 | 43 | testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
44 | 44 | testAddr = crypto.PubkeyToAddress(testKey.PublicKey)
|
45 | 45 | testContract = common.HexToAddress("0xbeef")
|
| 46 | + testEmpty = common.HexToAddress("0xeeee") |
46 | 47 | testSlot = common.HexToHash("0xdeadbeef")
|
47 | 48 | testValue = crypto.Keccak256Hash(testSlot[:])
|
48 | 49 | testBalance = big.NewInt(2e15)
|
@@ -96,6 +97,7 @@ func generateTestChain() (*core.Genesis, []*types.Block) {
|
96 | 97 | rcfg.IsCurieSlot: common.BytesToHash([]byte{1}),
|
97 | 98 | },
|
98 | 99 | },
|
| 100 | + testEmpty: {Balance: big.NewInt(1)}, |
99 | 101 | },
|
100 | 102 | ExtraData: []byte("test genesis"),
|
101 | 103 | Timestamp: 9000,
|
@@ -125,6 +127,12 @@ func TestGethClient(t *testing.T) {
|
125 | 127 | }, {
|
126 | 128 | "TestGetProof2",
|
127 | 129 | func(t *testing.T) { testGetProof(t, client, testContract) },
|
| 130 | + }, { |
| 131 | + "TestGetProofEmpty", |
| 132 | + func(t *testing.T) { testGetProof(t, client, testEmpty) }, |
| 133 | + }, { |
| 134 | + "TestGetProofNonExistent", |
| 135 | + func(t *testing.T) { testGetProofNonExistent(t, client) }, |
128 | 136 | }, {
|
129 | 137 | "TestGetProofCanonicalizeKeys",
|
130 | 138 | func(t *testing.T) { testGetProofCanonicalizeKeys(t, client) },
|
@@ -292,6 +300,38 @@ func testGetProofCanonicalizeKeys(t *testing.T, client *rpc.Client) {
|
292 | 300 | }
|
293 | 301 | }
|
294 | 302 |
|
| 303 | +func testGetProofNonExistent(t *testing.T, client *rpc.Client) { |
| 304 | + addr := common.HexToAddress("0x0001") |
| 305 | + ec := New(client) |
| 306 | + result, err := ec.GetProof(context.Background(), addr, nil, nil) |
| 307 | + if err != nil { |
| 308 | + t.Fatal(err) |
| 309 | + } |
| 310 | + if result.Address != addr { |
| 311 | + t.Fatalf("unexpected address, have: %v want: %v", result.Address, addr) |
| 312 | + } |
| 313 | + // test nonce |
| 314 | + if result.Nonce != 0 { |
| 315 | + t.Fatalf("invalid nonce, want: %v got: %v", 0, result.Nonce) |
| 316 | + } |
| 317 | + // test balance |
| 318 | + if result.Balance.Cmp(big.NewInt(0)) != 0 { |
| 319 | + t.Fatalf("invalid balance, want: %v got: %v", 0, result.Balance) |
| 320 | + } |
| 321 | + // test storage |
| 322 | + if have := len(result.StorageProof); have != 0 { |
| 323 | + t.Fatalf("invalid storage proof, want 0 proof, got %v proof(s)", have) |
| 324 | + } |
| 325 | + // test codeHash |
| 326 | + if have, want := result.CodeHash, (common.Hash{}); have != want { |
| 327 | + t.Fatalf("codehash wrong, have %v want %v ", have, want) |
| 328 | + } |
| 329 | + // test codeHash |
| 330 | + if have, want := result.StorageHash, (common.Hash{}); have != want { |
| 331 | + t.Fatalf("storagehash wrong, have %v want %v ", have, want) |
| 332 | + } |
| 333 | +} |
| 334 | + |
295 | 335 | func testGCStats(t *testing.T, client *rpc.Client) {
|
296 | 336 | ec := New(client)
|
297 | 337 | _, err := ec.GCStats(context.Background())
|
|
0 commit comments