From 5befdfa928e7ef744b0a49e060cb8438ca80b25a Mon Sep 17 00:00:00 2001 From: CPerezz Date: Wed, 8 Apr 2026 11:59:22 +0200 Subject: [PATCH] trie/bintrie: stop swallowing GetAccount error in delete test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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`. --- trie/bintrie/trie_test.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/trie/bintrie/trie_test.go b/trie/bintrie/trie_test.go index 46fb3cdb94..de04bd7949 100644 --- a/trie/bintrie/trie_test.go +++ b/trie/bintrie/trie_test.go @@ -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) } }