Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangchiqing committed Nov 16, 2023
1 parent 2f01917 commit 0eebf10
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions engine/execution/storehouse/executing_block_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,41 @@ func TestExtendingBlockSnapshot(t *testing.T) {
// should get un-changed value
value, err := snap2.Get(reg1.Key)
require.NoError(t, err)
require.Equal(t, reg1.Value, value)
require.Equal(t, []byte("val1"), value)

value, err = snap2.Get(reg2.Key)
require.NoError(t, err)
require.Equal(t, []byte("val22"), value)

value, err = snap2.Get(reg3.Key)
require.NoError(t, err)
require.Equal(t, []byte("val3"), value)

// should get nil for unknown register
unknown := makeReg("unknown", "unknownV")
value, err = snap2.Get(unknown.Key)
require.NoError(t, err)
require.Equal(t, []byte(nil), value)

// should get updated value
value, err = snap2.Get(reg2.Key)
require.NoError(t, err)
require.Equal(t, updatedReg2.Value, value)

// create snap3 with reg3 updated
// snap3: { key1: val1, key2: val22, key3: val33 }
updatedReg3 := makeReg("key3", "val33")
// snap3: { key1: val1, key2: val222, key3: val33 }
snap3 := snap1.Extend(unittest.StateCommitmentFixture(), map[flow.RegisterID]flow.RegisterValue{
snap3 := snap2.Extend(unittest.StateCommitmentFixture(), map[flow.RegisterID]flow.RegisterValue{
updatedReg3.Key: updatedReg3.Value,
})

// verify it's getting from the previous snapshot
// verify all keys
value, err = snap3.Get(reg1.Key)
require.NoError(t, err)
require.Equal(t, []byte("val1"), value)

value, err = snap3.Get(reg2.Key)
require.NoError(t, err)
require.Equal(t, updatedReg2.Value, value)
require.Equal(t, []byte("val22"), value)

value, err = snap3.Get(reg3.Key)
require.NoError(t, err)
require.Equal(t, updatedReg3.Value, value)

require.Equal(t, []byte("val33"), value)
})
}

Expand Down

0 comments on commit 0eebf10

Please sign in to comment.