Skip to content

Commit

Permalink
[fixup] addressing review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanlott committed Aug 4, 2023
1 parent df52d32 commit 9f05e2d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions persistence/blockstore/block_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ func (bs *blockStore) Backup(path string) error {
return bs.kv.Backup(path)
}

///////////////
// Accessors //
///////////////

func (bs *blockStore) Delete(key []byte) error { return bs.kv.Delete(key) }
func (bs *blockStore) Exists(key []byte) (bool, error) { return bs.kv.Exists(key) }
func (bs *blockStore) GetAll(prefixKey []byte, descending bool) (keys, values [][]byte, err error) {
Expand Down
15 changes: 11 additions & 4 deletions persistence/trees/atomic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ const (
h1 = "7d5712ea1507915c40e295845fa58773baa405b24b87e9d99761125d826ff915"
)

var testKey = []byte("fiz")
var (
testFoo = []byte("foo")
testBar = []byte("bar")
testKey = []byte("fiz")
testVal = []byte("buz")
)

func TestTreeStore_AtomicUpdatesWithSuccessfulRollback(t *testing.T) {
ctrl := gomock.NewController(t)
Expand All @@ -49,7 +54,7 @@ func TestTreeStore_AtomicUpdatesWithSuccessfulRollback(t *testing.T) {

// insert test data into every tree
for _, treeName := range stateTreeNames {
err := ts.merkleTrees[treeName].tree.Update([]byte("foo"), []byte("bar"))
err := ts.merkleTrees[treeName].tree.Update(testFoo, testBar)
require.NoError(t, err)
}

Expand Down Expand Up @@ -82,7 +87,7 @@ func TestTreeStore_AtomicUpdatesWithSuccessfulRollback(t *testing.T) {

// insert additional test data into all of the trees
for _, treeName := range stateTreeNames {
require.NoError(t, ts.merkleTrees[treeName].tree.Update(testKey, []byte("buz")))
require.NoError(t, ts.merkleTrees[treeName].tree.Update(testKey, testVal))
}

// rollback the changes made to the trees above BEFORE anything was committed
Expand Down Expand Up @@ -178,6 +183,7 @@ func TestTreeStore_SaveAndLoad(t *testing.T) {

// creates a new tree store with a tmp directory for nodestore persistence
// and then starts the tree store and returns its pointer.
// TECHDEBT(#796) - Organize and dedupe this function into testutil package
func newTestTreeStore(t *testing.T) *treeStore {
t.Helper()
ctrl := gomock.NewController(t)
Expand All @@ -198,7 +204,7 @@ func newTestTreeStore(t *testing.T) *treeStore {
require.NotNil(t, ts.rootTree.tree)

for _, treeName := range stateTreeNames {
err := ts.merkleTrees[treeName].tree.Update([]byte("foo"), []byte("bar"))
err := ts.merkleTrees[treeName].tree.Update(testFoo, testBar)
require.NoError(t, err)
}

Expand All @@ -211,6 +217,7 @@ func newTestTreeStore(t *testing.T) *treeStore {
return ts
}

// TECHDEBT(#796) - Organize and dedupe this function into testutil package
func isEmpty(dir string) (bool, error) {
f, err := os.Open(dir)
if err != nil {
Expand Down

0 comments on commit 9f05e2d

Please sign in to comment.