diff --git a/core/contract_test.go b/core/contract_test.go index 8ace83ba7e..e93a292df6 100644 --- a/core/contract_test.go +++ b/core/contract_test.go @@ -171,7 +171,7 @@ func TestUpdateStorageAndStorage(t *testing.T) { require.NoError(t, contract.UpdateStorage(map[felt.Felt]*felt.Felt{*addr: new(felt.Felt)}, NoopOnValueChanged)) val, err := core.ContractStorage(addr, addr, txn) - require.NoError(t, err) + require.Error(t, err) require.Equal(t, &felt.Zero, val) sRoot, err := core.ContractRoot(addr, txn) diff --git a/core/trie/trie.go b/core/trie/trie.go index c03357d3af..0b63b6fc5c 100644 --- a/core/trie/trie.go +++ b/core/trie/trie.go @@ -195,8 +195,8 @@ func (t *Trie) Get(key *felt.Felt) (*felt.Felt, error) { storageKey := t.feltToKey(key) value, err := t.storage.Get(&storageKey) if err != nil { - if errors.Is(err, db.ErrKeyNotFound) { - return &felt.Zero, nil + if errors.Is(err, db.ErrKeyNotFound) { // a non-existent key returns a zero value + return &felt.Zero, db.ErrKeyNotFound } return nil, err } diff --git a/core/trie/trie_test.go b/core/trie/trie_test.go index fb5460739d..41de9bb333 100644 --- a/core/trie/trie_test.go +++ b/core/trie/trie_test.go @@ -47,7 +47,7 @@ func TestTriePut(t *testing.T) { require.NoError(t, err) value, err := tempTrie.Get(key) - assert.NoError(t, err) + assert.Error(t, err) assert.Equal(t, &felt.Zero, value) // Trie's root should be nil assert.Nil(t, tempTrie.RootKey()) @@ -138,7 +138,7 @@ func TestTrieDeleteBasic(t *testing.T) { val, err := tempTrie.Get(key) - assert.NoError(t, err, "shouldnt return an error when access a deleted key") + assert.Error(t, err, "should return an error when access a deleted key") assert.Equal(t, &felt.Zero, val, "should return zero value when access a deleted key") }