github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/utils/unittest/network/conduit.go (about) 1 package network 2 3 import ( 4 "github.com/onflow/flow-go/model/flow" 5 "github.com/onflow/flow-go/network" 6 "github.com/onflow/flow-go/network/channels" 7 "github.com/onflow/flow-go/network/mocknetwork" 8 ) 9 10 type Conduit struct { 11 mocknetwork.Conduit 12 net *Network 13 channel channels.Channel 14 } 15 16 var _ network.Conduit = (*Conduit)(nil) 17 18 // Publish sends a message on this mock network, invoking any callback that has 19 // been specified. This will panic if no callback is found. 20 func (c *Conduit) Publish(event interface{}, targetIDs ...flow.Identifier) error { 21 if c.net.publishFunc != nil { 22 return c.net.publishFunc(c.channel, event, targetIDs...) 23 } 24 panic("Publish called but no callback function was found.") 25 } 26 27 // ReportMisbehavior reports the misbehavior of a node on sending a message to the current node that appears valid 28 // based on the networking layer but is considered invalid by the current node based on the Flow protocol. 29 // This method is a no-op in the test helper implementation. 30 func (c *Conduit) ReportMisbehavior(_ network.MisbehaviorReport) { 31 // no-op 32 }