Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect tests #80

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions db/code_db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package db

import (
"bytes"
"errors"
"fmt"
"testing"

Expand Down Expand Up @@ -82,8 +83,12 @@ func TestCodeDB_DeleteCode(t *testing.T) {
}

code, err := db.GetCode(hash)
if err != nil {
t.Fatalf("get code returned error; %v", err)
if err == nil {
t.Fatal("get code must fail")
}

if got, want := err, leveldb.ErrNotFound; !errors.Is(got, want) {
t.Fatalf("unexpected err, got: %v, want: %v", got, want)
}

if code != nil {
Expand Down
9 changes: 7 additions & 2 deletions db/substate_db_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package db

import (
"errors"
"fmt"
"math/big"
"testing"
Expand Down Expand Up @@ -98,8 +99,12 @@ func TestSubstateDB_DeleteSubstate(t *testing.T) {
}

ss, err := db.GetSubstate(37_534_834, 1)
if err != nil {
t.Fatalf("get substate returned error; %v", err)
if err == nil {
t.Fatal("get substate must fail")
}

if got, want := err, leveldb.ErrNotFound; !errors.Is(got, want) {
t.Fatalf("unexpected err, got: %v, want: %v", got, want)
}

if ss != nil {
Expand Down
4 changes: 2 additions & 2 deletions db/update_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (db *updateDB) GetUpdateSet(block uint64) (*updateset.UpdateSet, error) {
key := UpdateDBKey(block)
value, err := db.Get(key)
if err != nil {
return nil, fmt.Errorf("cannot get updateset block: %v, key %v; %v", block, key, err)
return nil, fmt.Errorf("cannot get updateset block: %v, key %v; %w", block, key, err)
}

if value == nil {
Expand All @@ -130,7 +130,7 @@ func (db *updateDB) GetUpdateSet(block uint64) (*updateset.UpdateSet, error) {
// decode value
var updateSetRLP updateset.UpdateSetRLP
if err = trlp.DecodeBytes(value, &updateSetRLP); err != nil {
return nil, fmt.Errorf("cannot decode update-set rlp block: %v, key %v; %v", block, key, err)
return nil, fmt.Errorf("cannot decode update-set rlp block: %v, key %v; %w", block, key, err)
}

return updateSetRLP.ToWorldState(db.GetCode, block)
Expand Down
9 changes: 7 additions & 2 deletions db/update_db_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package db

import (
"errors"
"fmt"
"math/big"
"testing"
Expand Down Expand Up @@ -98,8 +99,12 @@ func TestUpdateDB_DeleteUpdateSet(t *testing.T) {
}

us, err := db.GetUpdateSet(testUpdateSet.Block)
if err != nil {
t.Fatalf("get update=set returned error; %v", err)
if err == nil {
t.Fatal("get update-set must fail")
}

if got, want := err, leveldb.ErrNotFound; !errors.Is(got, want) {
t.Fatalf("unexpected err, got: %v, want: %v", got, want)
}

if us != nil {
Expand Down
Loading