-
Notifications
You must be signed in to change notification settings - Fork 839
chore(customrawdb): delete customrawdb package and switch to avalanchego imports #4626
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
base: master
Are you sure you want to change the base?
Changes from 21 commits
9f0d1d4
96d4893
74692e4
93eb1e6
52e1913
181e587
fe381d0
8ed20f7
18a61ea
591fc29
0cfd4ad
68b7e32
b8b7be5
1700205
7212c83
dc77bea
484d76f
8d6e9ea
ffd26b6
5cdf50c
98a81dc
17f9aa3
ef4dc7c
a34b609
13ef109
7207b18
edb90f3
f4bab82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,10 +28,12 @@ | |
| package snapshot | ||
|
|
||
| import ( | ||
| "errors" | ||
| "math/rand" | ||
| "testing" | ||
|
|
||
| "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/customrawdb" | ||
| "github.com/ava-labs/avalanchego/database" | ||
| "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" | ||
| "github.com/ava-labs/libevm/common" | ||
| "github.com/ava-labs/libevm/core/rawdb" | ||
| "github.com/ava-labs/libevm/ethdb/memorydb" | ||
|
|
@@ -72,8 +74,12 @@ func TestWipe(t *testing.T) { | |
| if items := count(); items != 128 { | ||
| t.Fatalf("snapshot size mismatch: have %d, want %d", items, 128) | ||
| } | ||
| if hash := customrawdb.ReadSnapshotBlockHash(db); hash == (common.Hash{}) { | ||
| t.Errorf("snapshot block hash marker mismatch: have %#x, want <not-nil>", hash) | ||
| blockHash, err := customrawdb.ReadSnapshotBlockHash(db) | ||
| switch { | ||
| case err != nil: | ||
| t.Fatalf("failed to read snapshot block hash before wipe: %v", err) | ||
| case blockHash == (common.Hash{}): | ||
| t.Fatalf("snapshot block hash is empty before wipe") | ||
| } | ||
| if hash := rawdb.ReadSnapshotRoot(db); hash == (common.Hash{}) { | ||
| t.Errorf("snapshot block root marker mismatch: have %#x, want <not-nil>", hash) | ||
|
|
@@ -96,8 +102,14 @@ func TestWipe(t *testing.T) { | |
| t.Fatalf("misc item count mismatch: have %d, want %d", items, 1000) | ||
| } | ||
|
|
||
| if hash := customrawdb.ReadSnapshotBlockHash(db); hash != (common.Hash{}) { | ||
| t.Errorf("snapshot block hash marker remained after wipe: %#x", hash) | ||
| // Verify snapshot markers are removed. | ||
| blockHash, err = customrawdb.ReadSnapshotBlockHash(db) | ||
| switch { | ||
| case errors.Is(err, database.ErrNotFound): // Expected: marker was deleted. | ||
| case err != nil: | ||
| t.Errorf("unexpected error reading snapshot block hash after wipe: %v", err) | ||
| case blockHash != (common.Hash{}): | ||
| t.Errorf("snapshot block hash marker remained after wipe: %#x", blockHash) | ||
| } | ||
|
Comment on lines
+107
to
113
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't check the blockhash if the error is
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In either case, this definitely seems like it's a symptom of racy code. Will you add a comment describing why the error may or may not be nil? |
||
| if hash := rawdb.ReadSnapshotRoot(db); hash != (common.Hash{}) { | ||
| t.Errorf("snapshot block root marker remained after wipe: %#x", hash) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.