Skip to content

Commit

Permalink
Merge "[FAB-7397] Peer deliver panic for nonexistent channel"
Browse files Browse the repository at this point in the history
  • Loading branch information
yacovm authored and Gerrit Code Review committed Dec 8, 2017
2 parents dd7a116 + cbc9b49 commit 19a35f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/peer/peer.go
Expand Up @@ -734,6 +734,9 @@ type DeliverSupportManager struct {

func (dsm DeliverSupportManager) GetChain(chainID string) (deliver.Support, bool) {
channel, ok := chains.list[chainID]
if !ok {
return nil, ok
}
return channel.cs, ok
}

Expand Down
15 changes: 15 additions & 0 deletions core/peer/peer_test.go
Expand Up @@ -213,3 +213,18 @@ func TestGetLocalIP(t *testing.T) {
ip := GetLocalIP()
t.Log(ip)
}

func TestDeliverSupportManager(t *testing.T) {
// reset chains for testing
MockInitialize()

manager := &DeliverSupportManager{}
chainSupport, ok := manager.GetChain("fake")
assert.Nil(t, chainSupport, "chain support should be nil")
assert.False(t, ok, "Should not find fake channel")

MockCreateChain("testchain")
chainSupport, ok = manager.GetChain("testchain")
assert.NotNil(t, chainSupport, "chain support should not be nil")
assert.True(t, ok, "Should find testchain channel")
}

0 comments on commit 19a35f3

Please sign in to comment.