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:
CPerezz 2026-04-08 11:59:22 +02:00
parent d38689e4ed
commit 5befdfa928
No known key found for this signature in database
GPG key ID: 62045F34B97177DD

View file

@ -466,23 +466,27 @@ func TestDeleteAccountDoesNotAffectMainStorage(t *testing.T) {
}
// 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)
}
// Main storage slot should still be readable — DeleteAccount must not
// have touched it.
got, err := tr.GetStorage(addr, slot[:])
stored, err := tr.GetStorage(addr, slot[:])
if err != nil {
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")
}
var expected [HashSize]byte
copy(expected[HashSize-len(value):], value)
if !bytes.Equal(got, expected[:]) {
t.Fatalf("main storage slot: got %x, want %x", got, expected)
if !bytes.Equal(stored, expected[:]) {
t.Fatalf("main storage slot: got %x, want %x", stored, expected)
}
}