Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangchiqing committed Nov 10, 2023
1 parent 46d5140 commit ee8d328
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion engine/execution/storehouse/register_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (r *RegisterStore) getAndConvertNotFoundErr(register flow.RegisterID, heigh
// - exception if the block is below the pruned height
// - exception if the save block is saved again
// - exception for any other exception
func (r *RegisterStore) SaveRegisters(header *flow.Header, registers []flow.RegisterEntry) error {
func (r *RegisterStore) SaveRegisters(header *flow.Header, registers flow.RegisterEntries) error {
err := r.memStore.SaveRegisters(header.Height, header.ID(), header.ParentID, registers)
if err != nil {
return fmt.Errorf("cannot save register to memStore: %w", err)
Expand Down
38 changes: 19 additions & 19 deletions engine/execution/storehouse/register_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ func TestRegisterStoreSaveRegistersShouldFail(t *testing.T) {
headerByHeight map[uint64]*flow.Header,
) {
wrongParent := unittest.BlockHeaderFixture(unittest.WithHeaderHeight(rootHeight + 1))
err := rs.SaveRegisters(wrongParent, []flow.RegisterEntry{})
err := rs.SaveRegisters(wrongParent, flow.RegisterEntries{})
require.Error(t, err)
require.Contains(t, err.Error(), "parent")

err = rs.SaveRegisters(headerByHeight[rootHeight], []flow.RegisterEntry{})
err = rs.SaveRegisters(headerByHeight[rootHeight], flow.RegisterEntries{})
require.Error(t, err)
require.Contains(t, err.Error(), "pruned")
})
Expand Down Expand Up @@ -124,7 +124,7 @@ func TestRegisterStoreSaveRegistersShouldOK(t *testing.T) {

// save block 11
reg := makeReg("X", "1")
err = rs.SaveRegisters(headerByHeight[rootHeight+1], []flow.RegisterEntry{reg})
err = rs.SaveRegisters(headerByHeight[rootHeight+1], flow.RegisterEntries{reg})
require.NoError(t, err)

// should get value
Expand All @@ -138,7 +138,7 @@ func TestRegisterStoreSaveRegistersShouldOK(t *testing.T) {
require.True(t, executed)

// block 12 is empty
err = rs.SaveRegisters(headerByHeight[rootHeight+2], []flow.RegisterEntry{})
err = rs.SaveRegisters(headerByHeight[rootHeight+2], flow.RegisterEntries{})
require.NoError(t, err)

// should get same value
Expand Down Expand Up @@ -171,11 +171,11 @@ func TestRegisterStoreIsBlockExecuted(t *testing.T) {
) {
// save block 11
reg := makeReg("X", "1")
err := rs.SaveRegisters(headerByHeight[rootHeight+1], []flow.RegisterEntry{reg})
err := rs.SaveRegisters(headerByHeight[rootHeight+1], flow.RegisterEntries{reg})
require.NoError(t, err)

// save block 12
err = rs.SaveRegisters(headerByHeight[rootHeight+2], []flow.RegisterEntry{makeReg("X", "2")})
err = rs.SaveRegisters(headerByHeight[rootHeight+2], flow.RegisterEntries{makeReg("X", "2")})
require.NoError(t, err)

require.NoError(t, finalized.MockFinal(rootHeight+1))
Expand Down Expand Up @@ -217,15 +217,15 @@ func TestRegisterStoreReadingFromDisk(t *testing.T) {

// R <- 11 (X: 1, Y: 2) <- 12 (Y: 3) <- 13 (X: 4)
// save block 11
err := rs.SaveRegisters(headerByHeight[rootHeight+1], []flow.RegisterEntry{makeReg("X", "1"), makeReg("Y", "2")})
err := rs.SaveRegisters(headerByHeight[rootHeight+1], flow.RegisterEntries{makeReg("X", "1"), makeReg("Y", "2")})
require.NoError(t, err)

// save block 12
err = rs.SaveRegisters(headerByHeight[rootHeight+2], []flow.RegisterEntry{makeReg("Y", "3")})
err = rs.SaveRegisters(headerByHeight[rootHeight+2], flow.RegisterEntries{makeReg("Y", "3")})
require.NoError(t, err)

// save block 13
err = rs.SaveRegisters(headerByHeight[rootHeight+3], []flow.RegisterEntry{makeReg("X", "4")})
err = rs.SaveRegisters(headerByHeight[rootHeight+3], flow.RegisterEntries{makeReg("X", "4")})
require.NoError(t, err)

require.NoError(t, finalized.MockFinal(rootHeight+2))
Expand Down Expand Up @@ -267,16 +267,16 @@ func TestRegisterStoreReadingFromInMemStore(t *testing.T) {
// ^- 11 (X: 4)

// save block 11
err := rs.SaveRegisters(headerByHeight[rootHeight+1], []flow.RegisterEntry{makeReg("X", "1"), makeReg("Y", "2")})
err := rs.SaveRegisters(headerByHeight[rootHeight+1], flow.RegisterEntries{makeReg("X", "1"), makeReg("Y", "2")})
require.NoError(t, err)

// save block 12
err = rs.SaveRegisters(headerByHeight[rootHeight+2], []flow.RegisterEntry{makeReg("Y", "3")})
err = rs.SaveRegisters(headerByHeight[rootHeight+2], flow.RegisterEntries{makeReg("Y", "3")})
require.NoError(t, err)

// save block 11 fork
block11Fork := unittest.BlockWithParentFixture(headerByHeight[rootHeight]).Header
err = rs.SaveRegisters(block11Fork, []flow.RegisterEntry{makeReg("X", "4")})
err = rs.SaveRegisters(block11Fork, flow.RegisterEntries{makeReg("X", "4")})
require.NoError(t, err)

val, err := rs.GetRegister(rootHeight+1, headerByHeight[rootHeight+1].ID(), makeReg("X", "1").Key)
Expand Down Expand Up @@ -328,17 +328,17 @@ func TestRegisterStoreExecuteFirstFinalizeLater(t *testing.T) {
headerByHeight map[uint64]*flow.Header,
) {
// save block 11
err := rs.SaveRegisters(headerByHeight[rootHeight+1], []flow.RegisterEntry{makeReg("X", "1")})
err := rs.SaveRegisters(headerByHeight[rootHeight+1], flow.RegisterEntries{makeReg("X", "1")})
require.NoError(t, err)
require.Equal(t, rootHeight, rs.LastFinalizedAndExecutedHeight())

// save block 12
err = rs.SaveRegisters(headerByHeight[rootHeight+2], []flow.RegisterEntry{makeReg("X", "2")})
err = rs.SaveRegisters(headerByHeight[rootHeight+2], flow.RegisterEntries{makeReg("X", "2")})
require.NoError(t, err)
require.Equal(t, rootHeight, rs.LastFinalizedAndExecutedHeight())

// save block 13
err = rs.SaveRegisters(headerByHeight[rootHeight+3], []flow.RegisterEntry{makeReg("X", "3")})
err = rs.SaveRegisters(headerByHeight[rootHeight+3], flow.RegisterEntries{makeReg("X", "3")})
require.NoError(t, err)
require.Equal(t, rootHeight, rs.LastFinalizedAndExecutedHeight())

Expand Down Expand Up @@ -386,17 +386,17 @@ func TestRegisterStoreFinalizeFirstExecuteLater(t *testing.T) {
require.Equal(t, rootHeight, rs.LastFinalizedAndExecutedHeight())

// save block 11
err := rs.SaveRegisters(headerByHeight[rootHeight+1], []flow.RegisterEntry{makeReg("X", "1")})
err := rs.SaveRegisters(headerByHeight[rootHeight+1], flow.RegisterEntries{makeReg("X", "1")})
require.NoError(t, err)
require.Equal(t, rootHeight+1, rs.LastFinalizedAndExecutedHeight())

// save block 12
err = rs.SaveRegisters(headerByHeight[rootHeight+2], []flow.RegisterEntry{makeReg("X", "2")})
err = rs.SaveRegisters(headerByHeight[rootHeight+2], flow.RegisterEntries{makeReg("X", "2")})
require.NoError(t, err)
require.Equal(t, rootHeight+2, rs.LastFinalizedAndExecutedHeight())

// save block 13
err = rs.SaveRegisters(headerByHeight[rootHeight+3], []flow.RegisterEntry{makeReg("X", "3")})
err = rs.SaveRegisters(headerByHeight[rootHeight+3], flow.RegisterEntries{makeReg("X", "3")})
require.NoError(t, err)
require.Equal(t, rootHeight+3, rs.LastFinalizedAndExecutedHeight())
})
Expand Down Expand Up @@ -436,7 +436,7 @@ func TestRegisterStoreConcurrentFinalizeAndExecute(t *testing.T) {
savedHeights <- height
}

err := rs.SaveRegisters(headerByHeight[height], []flow.RegisterEntry{makeReg("X", fmt.Sprintf("%d", height))})
err := rs.SaveRegisters(headerByHeight[height], flow.RegisterEntries{makeReg("X", fmt.Sprintf("%d", height))})
require.NoError(t, err)
}
close(savedHeights)
Expand Down

0 comments on commit ee8d328

Please sign in to comment.