Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tuantran1702 committed Jun 23, 2024
1 parent f7d735e commit 4aa7d3c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ func NewManager(
execMetrics *state.Metrics,
) (*Manager, error) {
s, err := getInitialState(store, genesis)
//set block height in store
store.SetHeight(context.Background(), s.LastBlockHeight)

if err != nil {
return nil, err
}
//set block height in store
store.SetHeight(context.Background(), s.LastBlockHeight)

// genesis should have exactly one "validator", the centralized sequencer.
// this should have been validated in the above call to getInitialState.
valSet := types.GetValidatorSetFromGenesis(genesis)
Expand Down
2 changes: 2 additions & 0 deletions block/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func TestInitialStateClean(t *testing.T) {
es, _ := store.NewDefaultInMemoryKVStore()
emptyStore := store.New(es)
s, err := getInitialState(emptyStore, genesis)
require.NoError(err)
require.Equal(s.LastBlockHeight, uint64(genesis.InitialHeight-1))
require.NoError(err)
require.Equal(uint64(genesis.InitialHeight), s.InitialHeight)
Expand All @@ -90,6 +91,7 @@ func TestInitialStateStored(t *testing.T) {
err := store.UpdateState(ctx, sampleState)
require.NoError(err)
s, err := getInitialState(store, genesis)
require.NoError(err)
require.Equal(s.LastBlockHeight, uint64(100))
require.NoError(err)
require.Equal(s.InitialHeight, uint64(1))
Expand Down
1 change: 1 addition & 0 deletions node/full_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ func TestGenesisChunked(t *testing.T) {
startNodeWithCleanup(t, rpc.node)
expectedID = 0
gc2, err := rpc.GenesisChunked(context.Background(), expectedID)
require.NoError(t, err)
gotID := gc2.ChunkNumber
assert.NoError(err)
assert.NotNil(gc2)
Expand Down
1 change: 1 addition & 0 deletions node/full_node_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func TestLazyAggregator(t *testing.T) {
BlockManagerConfig: blockManagerConfig,
LazyAggregator: true,
}, key, signingKey, proxy.NewLocalClientCreator(app), genesisDoc, DefaultMetricsProvider(cmconfig.DefaultInstrumentationConfig()), log.TestingLogger())
require.NoError(err)
assert.False(node.IsRunning())
assert.NoError(err)

Expand Down
2 changes: 1 addition & 1 deletion types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ func GetFirstSignedHeader(privkey ed25519.PrivKey, valSet *cmtypes.ValidatorSet)
Validators: valSet,
}
commit, err := GetCommit(header, privkey)
signedHeader.Commit = *commit
if err != nil {
return nil, err
}
signedHeader.Commit = *commit
return &signedHeader, nil
}

Expand Down

0 comments on commit 4aa7d3c

Please sign in to comment.