SDK Go - Improve Broadcast mock method
@@ -7,6 +7,8 @@ SPDX-License-Identifier: Apache-2.0
package mocks
import (
+ "io"
+
"github.com/hyperledger/fabric/protos/common"
po "github.com/hyperledger/fabric/protos/orderer"
)
@@ -35,17 +37,21 @@ type MockBroadcastServer struct {
// Broadcast mock broadcast
func (m *MockBroadcastServer) Broadcast(server po.AtomicBroadcast_BroadcastServer) error {
-
+ _, err := server.Recv()
+ if err == io.EOF {
+ return nil
+ }
+ if err != nil {
+ return err
+ }
if m.BroadcastError != nil {
return m.BroadcastError
}
if m.BroadcastInternalServerError {
- server.Send(broadcastResponseError)
- return nil
+ return server.Send(broadcastResponseError)
}
- server.Send(broadcastResponseSuccess)
- return nil
+ return server.Send(broadcastResponseSuccess)
}
// Deliver mock deliver
