Skip to content

Commit

Permalink
[FAB-3545] Improve unit test coverage for provisional
Browse files Browse the repository at this point in the history
Improve unit test coverage for common/configtx/tool/provisional.
This change set improves the test coverage from 77% to 86%.

Change-Id: Ifc82ab1c2597114636ad754b5616ac6cae121a44
Signed-off-by: Yuki Kondo <yuki.kondo@hal.hitachi.com>
  • Loading branch information
yuki-kon authored and yacovm committed May 11, 2017
1 parent a39904a commit 7f5d017
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion common/configtx/tool/provisional/provisional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ import (

genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig"
cb "github.com/hyperledger/fabric/protos/common"
"github.com/stretchr/testify/assert"
)

var confSolo *genesisconfig.Profile
var confKafka *genesisconfig.Profile
var testCases []*genesisconfig.Profile

func init() {
confSolo = genesisconfig.Load(genesisconfig.SampleSingleMSPSoloProfile)
testCases = []*genesisconfig.Profile{confSolo}
confKafka = genesisconfig.Load("SampleInsecureKafka")
testCases = []*genesisconfig.Profile{confSolo, confKafka}
}

func TestGenesisBlockHeader(t *testing.T) {
Expand Down Expand Up @@ -58,3 +61,13 @@ func TestGenesisMetadata(t *testing.T) {
}
}
}

func TestGenesisBlockForChannelHeader(t *testing.T) {
expectedHeaderNumber := uint64(0)

for _, tc := range testCases {
genesisBlock := New(tc).GenesisBlockForChannel("mychannel")
assert.Equal(t, expectedHeaderNumber, genesisBlock.Header.Number, "Case %s: Header number should be equal", tc.Orderer.OrdererType)
assert.Nil(t, genesisBlock.Header.PreviousHash, "Case %s: Header previousHash to be nil", tc.Orderer.OrdererType)
}
}

0 comments on commit 7f5d017

Please sign in to comment.