From 4aa7d3cc673e9f335f1a61a3cf113c842408e656 Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Mon, 24 Jun 2024 00:37:54 +0700 Subject: [PATCH] refactor --- block/manager.go | 6 +++--- block/manager_test.go | 2 ++ node/full_client_test.go | 1 + node/full_node_integration_test.go | 1 + types/utils.go | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/block/manager.go b/block/manager.go index 07e6a9175..5512674df 100644 --- a/block/manager.go +++ b/block/manager.go @@ -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) diff --git a/block/manager_test.go b/block/manager_test.go index 04b3f8eef..e3adabecd 100644 --- a/block/manager_test.go +++ b/block/manager_test.go @@ -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) @@ -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)) diff --git a/node/full_client_test.go b/node/full_client_test.go index edf96a64e..555b8876d 100644 --- a/node/full_client_test.go +++ b/node/full_client_test.go @@ -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) diff --git a/node/full_node_integration_test.go b/node/full_node_integration_test.go index 2746a842a..a28f7b8a4 100644 --- a/node/full_node_integration_test.go +++ b/node/full_node_integration_test.go @@ -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) diff --git a/types/utils.go b/types/utils.go index bb07c66b7..a3ef6e919 100644 --- a/types/utils.go +++ b/types/utils.go @@ -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 }