From 83b40b25d65b858adefab812a93464b819304911 Mon Sep 17 00:00:00 2001 From: Emmanuel Odeke Date: Thu, 5 Oct 2017 21:20:01 -0600 Subject: [PATCH] blockchain: deduplicate store header value tests --- blockchain/store_test.go | 56 ++++++++++++---------------------------- 1 file changed, 16 insertions(+), 40 deletions(-) diff --git a/blockchain/store_test.go b/blockchain/store_test.go index 65832e22f..e026025e7 100644 --- a/blockchain/store_test.go +++ b/blockchain/store_test.go @@ -128,6 +128,14 @@ func TestBlockStoreSaveLoadBlock(t *testing.T) { uncontiguousPartSet := types.NewPartSetFromHeader(types.PartSetHeader{Total: 0}) uncontiguousPartSet.AddPart(part2, false) + header1 := types.Header{ + Height: 1, + NumTxs: 100, + ChainID: "block_test", + } + header2 := header1 + header2.Height = 4 + // End of setup, test data tuples := []struct { @@ -145,11 +153,7 @@ func TestBlockStoreSaveLoadBlock(t *testing.T) { }{ { block: &types.Block{ - Header: &types.Header{ - Height: 1, - NumTxs: 100, - ChainID: "block_test", - }, + Header: &header1, LastCommit: &types.Commit{Precommits: []*types.Vote{{Height: 10}}}, }, parts: validPartSet, @@ -163,11 +167,7 @@ func TestBlockStoreSaveLoadBlock(t *testing.T) { { block: &types.Block{ - Header: &types.Header{ - Height: 4, - NumTxs: 100, - ChainID: "block_test", - }, + Header: &header2, LastCommit: &types.Commit{Precommits: []*types.Vote{{Height: 10}}}, }, parts: uncontiguousPartSet, @@ -176,11 +176,7 @@ func TestBlockStoreSaveLoadBlock(t *testing.T) { { block: &types.Block{ - Header: &types.Header{ - Height: 1, - NumTxs: 100, - ChainID: "block_test", - }, + Header: &header1, LastCommit: &types.Commit{Precommits: []*types.Vote{{Height: 10}}}, }, parts: incompletePartSet, @@ -189,11 +185,7 @@ func TestBlockStoreSaveLoadBlock(t *testing.T) { { block: &types.Block{ - Header: &types.Header{ - Height: 1, - NumTxs: 100, - ChainID: "block_test", - }, + Header: &header1, LastCommit: &types.Commit{Precommits: []*types.Vote{{Height: 10}}}, }, parts: validPartSet, @@ -204,11 +196,7 @@ func TestBlockStoreSaveLoadBlock(t *testing.T) { { block: &types.Block{ - Header: &types.Header{ - Height: 1, - NumTxs: 100, - ChainID: "block_test", - }, + Header: &header1, LastCommit: &types.Commit{Precommits: []*types.Vote{{Height: 10}}}, }, parts: validPartSet, @@ -219,11 +207,7 @@ func TestBlockStoreSaveLoadBlock(t *testing.T) { { block: &types.Block{ - Header: &types.Header{ - Height: 1, - NumTxs: 100, - ChainID: "block_test", - }, + Header: &header1, LastCommit: &types.Commit{Precommits: []*types.Vote{{Height: 10}}}, }, parts: validPartSet, @@ -235,11 +219,7 @@ func TestBlockStoreSaveLoadBlock(t *testing.T) { { block: &types.Block{ - Header: &types.Header{ - Height: 1, - NumTxs: 100, - ChainID: "block_test", - }, + Header: &header1, LastCommit: &types.Commit{Precommits: []*types.Vote{{Height: 10}}}, }, parts: validPartSet, @@ -251,11 +231,7 @@ func TestBlockStoreSaveLoadBlock(t *testing.T) { { block: &types.Block{ - Header: &types.Header{ - Height: 1, - NumTxs: 100, - ChainID: "block_test", - }, + Header: &header1, LastCommit: &types.Commit{Precommits: []*types.Vote{{Height: 10}}}, }, parts: validPartSet,