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

Add exist and delete operations to the test #280

Merged
merged 1 commit into from
Dec 5, 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
33 changes: 27 additions & 6 deletions space/space_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1030,10 +1030,19 @@ func TestSwitchingFromMutableToImmutablePath(t *testing.T) {

// Let's locate the key hash 16 in the data item 0.

v16, err = s.NewEntry(snapshotID, key, StageData)
v16Read, err := s.NewEntry(snapshotID, key, StageData)
requireT.NoError(err)
requireT.NoError(s.Find(v16))
requireT.Equal(&pointerNode.Pointers[16].VolatileAddress, v16.nextDataNode) // Verify the next expected data node address.
requireT.NoError(s.Find(v16Read))
// Verify the next expected data node address.
requireT.Equal(&pointerNode.Pointers[16].VolatileAddress, v16Read.nextDataNode)

v16Exists, err := s.NewEntry(snapshotID, key, StageData)
requireT.NoError(err)
requireT.NoError(s.Find(v16Exists))

v16Delete, err := s.NewEntry(snapshotID, key, StageData)
requireT.NoError(err)
requireT.NoError(s.Find(v16Delete))

// Now let's split data node 0 using key hash 64.

Expand Down Expand Up @@ -1061,15 +1070,27 @@ func TestSwitchingFromMutableToImmutablePath(t *testing.T) {

requireT.NoError(s.AddPointerNode(v64, false))
requireT.True(pointerNode.Pointers[0].VolatileAddress.IsSet(types.FlagPointerNode))
requireT.True(v16.storeRequest.Store[v16.storeRequest.PointersToStore-1].Pointer.VolatileAddress.
requireT.True(v16Read.storeRequest.Store[v16Read.storeRequest.PointersToStore-1].Pointer.VolatileAddress.
IsSet(types.FlagPointerNode))

// We are now in situation where key hash 16 is no longer in the place pointed to by v16.
// When walking the tree now, it should not follow the current pointer node, but go back and switch
// to the immutable path.

balance, err := s.ReadKey(v16)
balance, err := s.ReadKey(v16Read)
requireT.NoError(err)
requireT.Equal(txtypes.Amount(16), balance)
requireT.Nil(v16.nextDataNode)
requireT.Nil(v16Read.nextDataNode)

exists, err := s.KeyExists(v16Exists)
requireT.NoError(err)
requireT.True(exists)
requireT.Nil(v16Exists.nextDataNode)

requireT.NoError(s.DeleteKey(v16Delete))
requireT.Nil(v16Delete.nextDataNode)

balance, exists = s.Query(key)
requireT.False(exists)
requireT.Equal(txtypes.Amount(0), balance)
}
55 changes: 0 additions & 55 deletions test/helpers.go_

This file was deleted.

Loading