Skip to content

Commit

Permalink
[fixup] refactors and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanlott committed Jul 17, 2023
1 parent f99e183 commit 99d12f4
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions persistence/trees/atomic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package trees

import (
"encoding/hex"
"fmt"
"testing"

mock_types "github.com/pokt-network/pocket/persistence/types/mocks"
Expand Down Expand Up @@ -37,19 +36,6 @@ func TestTreeStore_AtomicUpdates(t *testing.T) {
err = ts.Savepoint()
require.NoError(t, err)

t.Log("==========- EMPTY TREE -===========")

t.Log("=====================")
t.Logf("HASH 0 [%s] - EMPTY TREE", hash0)
t.Log("=====================")

t.Log("=====================")
t.Logf("SAVEPOINT 0 GENERATED @ %s - EMPTY TREE ", hex.EncodeToString(ts.Prev.RootTree.tree.Root()))
for _, treeName := range stateTreeNames {
fmt.Printf("%s: %s\n", treeName, hex.EncodeToString(ts.merkleTrees[treeName].tree.Root()))
}
t.Log("=====================")

for _, treeName := range stateTreeNames {
err := ts.merkleTrees[treeName].tree.Update([]byte("foo"), []byte("bar"))
require.NoError(t, err)
Expand All @@ -64,50 +50,23 @@ func TestTreeStore_AtomicUpdates(t *testing.T) {
require.NotEmpty(t, hash1)
require.NotEqual(t, hash0, hash1)

t.Log("=====================")
t.Logf("COMMIT - HASH 1 [%s]", hash1)
t.Log("=====================")

err = ts.Savepoint()
require.NoError(t, err)

require.NotEmpty(t, ts.Prev.MerkleTrees)
require.NotEmpty(t, ts.Prev.RootTree)
require.Equal(t, hash1, hex.EncodeToString(ts.Prev.RootTree.tree.Root()))

t.Log("=====================")
t.Logf("SAVEPOINT 1 [%s] - ROOT HASH [%s]", hex.EncodeToString(ts.Prev.RootTree.tree.Root()), hash1)
t.Log("=====================")

for _, treeName := range stateTreeNames {
require.NotEmpty(t, ts.merkleTrees[treeName])
require.NotEmpty(t, ts.Prev.MerkleTrees[treeName])
}

t.Log("=====================")
t.Log("UNCOMMITTED UPDATES")
for _, treeName := range stateTreeNames {
fmt.Printf("- %s: %v\n", treeName, hex.EncodeToString(ts.merkleTrees[treeName].tree.Root()))
require.NoError(t, err)
}
t.Log("=====================")

for _, treeName := range stateTreeNames {
fmt.Printf("%s: %s\n", treeName, hex.EncodeToString(ts.merkleTrees[treeName].tree.Root()))
}

ts.Rollback()
t.Log("=====================")
t.Logf("🛴 ROLLBACK ")
t.Log("=====================")

hash2 := ts.getStateHash()
require.Equal(t, hash2, hash1)

t.Log("=====================")
t.Logf("- HASH 2 [%s]\n- HASH 1 [%s]", hash2, hash1)
t.Log("=====================")

// confirm it's not in the tree
v, err := ts.merkleTrees[TransactionsTreeName].tree.Get([]byte("fiz"))
require.NoError(t, err)
Expand Down

0 comments on commit 99d12f4

Please sign in to comment.