mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-16 11:51:35 +00:00
trie/bintrie: stop swallowing GetAccount error in delete test
TestDeleteAccountDoesNotAffectMainStorage was using `if got, _ := tr.GetAccount(addr); got != nil` to assert deletion. If GetAccount ever returns a non-nil error on this path (a future change to GetValuesAtStem, a resolver-error case), `got` is nil and the assertion passes silently — exactly the kind of suppression the broader fix is designed to eliminate. Match the error-checking pattern used four lines earlier in the same test, and rename the now-shadowed `got` for the GetStorage result to `stored`.
This commit is contained in:
parent
d38689e4ed
commit
5befdfa928
1 changed files with 9 additions and 5 deletions
|
|
@ -466,23 +466,27 @@ func TestDeleteAccountDoesNotAffectMainStorage(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Account should be absent.
|
// Account should be absent.
|
||||||
if got, _ := tr.GetAccount(addr); got != nil {
|
got, err := tr.GetAccount(addr)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("GetAccount after delete: %v", err)
|
||||||
|
}
|
||||||
|
if got != nil {
|
||||||
t.Fatalf("GetAccount after delete: got %+v, want nil", got)
|
t.Fatalf("GetAccount after delete: got %+v, want nil", got)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main storage slot should still be readable — DeleteAccount must not
|
// Main storage slot should still be readable — DeleteAccount must not
|
||||||
// have touched it.
|
// have touched it.
|
||||||
got, err := tr.GetStorage(addr, slot[:])
|
stored, err := tr.GetStorage(addr, slot[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("GetStorage after DeleteAccount: %v", err)
|
t.Fatalf("GetStorage after DeleteAccount: %v", err)
|
||||||
}
|
}
|
||||||
if len(got) == 0 {
|
if len(stored) == 0 {
|
||||||
t.Fatal("main storage slot was wiped by DeleteAccount, expected it to survive")
|
t.Fatal("main storage slot was wiped by DeleteAccount, expected it to survive")
|
||||||
}
|
}
|
||||||
var expected [HashSize]byte
|
var expected [HashSize]byte
|
||||||
copy(expected[HashSize-len(value):], value)
|
copy(expected[HashSize-len(value):], value)
|
||||||
if !bytes.Equal(got, expected[:]) {
|
if !bytes.Equal(stored, expected[:]) {
|
||||||
t.Fatalf("main storage slot: got %x, want %x", got, expected)
|
t.Fatalf("main storage slot: got %x, want %x", stored, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue