Skip to content

Commit

Permalink
[FAB-3776] unit test get config after restart
Browse files Browse the repository at this point in the history
Added unit tests to cover the scenario described in
the comments of https://gerrit.hyperledger.org/r/#/c/9185/

Change-Id: I204eaf1adb60a8e8ffa24d3b87b68c483ea9f832
Signed-off-by: Luis Sanchez <sanchezl@us.ibm.com>
  • Loading branch information
Luis Sanchez committed May 19, 2017
1 parent 6765b35 commit 7563808
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion orderer/multichain/chainsupport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ func TestWriteLastConfig(t *testing.T) {

cm.SequenceVal = 1
expected = uint64(2)

if lc := utils.GetLastConfigIndexFromBlockOrPanic(cs.WriteBlock(cb.NewBlock(2, nil), nil, nil)); lc != expected {
t.Fatalf("Second block should have config block index of %d, but got %d", expected, lc)
}
Expand All @@ -140,4 +139,21 @@ func TestWriteLastConfig(t *testing.T) {
t.Fatalf("Second block should have config block index of %d, but got %d", expected, lc)
}

t.Run("ResetChainSupport", func(t *testing.T) {

cm.SequenceVal = 2
expected = uint64(4)

cs = &chainSupport{ledgerResources: &ledgerResources{configResources: &configResources{Manager: cm}, ledger: ml}, signer: mockCrypto()}

if lc := utils.GetLastConfigIndexFromBlockOrPanic(cs.WriteBlock(cb.NewBlock(4, nil), nil, nil)); lc != expected {
t.Fatalf("Second block should have config block index of %d, but got %d", expected, lc)
}

if lc := utils.GetLastConfigIndexFromBlockOrPanic(cs.WriteBlock(cb.NewBlock(5, nil), nil, nil)); lc != expected {
t.Fatalf("Second block should have config block index of %d, but got %d", expected, lc)
}

})

}

0 comments on commit 7563808

Please sign in to comment.