-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-9651] Closed channel should return error
Change-Id: I6391cfe2b5f45be54e4bd1b408c5eb77b3807f02 Signed-off-by: Saad Karim <[email protected]>
- Loading branch information
Saad Karim
committed
Apr 24, 2018
1 parent
db0c395
commit 5f37d12
Showing
5 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package shim | ||
|
||
import ( | ||
"testing" | ||
|
||
pb "github.com/hyperledger/fabric/protos/peer" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRecvChannelClosedError(t *testing.T) { | ||
ch := make(chan *pb.ChaincodeMessage) | ||
|
||
stream := newInProcStream(ch, ch) | ||
|
||
// Close the channel | ||
close(ch) | ||
|
||
// Trying to call a closed receive channel should return an error | ||
_, err := stream.Recv() | ||
if assert.Error(t, err, "Should return an error") { | ||
assert.Contains(t, err.Error(), "channel is closed") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters