MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / createOutboundPeerAndPerformHandshake

Function createOutboundPeerAndPerformHandshake

p2p/peer_test.go:78–105  ·  view source on GitHub ↗
(
	addr *NetAddress,
	config *config.P2PConfig,
	mConfig tmconn.MConnConfig,
)

Source from the content-addressed store, hash-verified

76}
77
78func createOutboundPeerAndPerformHandshake(
79 addr *NetAddress,
80 config *config.P2PConfig,
81 mConfig tmconn.MConnConfig,
82) (*peer, error) {
83 chDescs := []*tmconn.ChannelDescriptor{
84 {ID: testCh, Priority: 1},
85 }
86 reactorsByCh := map[byte]Reactor{testCh: NewTestReactor(chDescs, true)}
87 msgTypeByChID := map[byte]proto.Message{
88 testCh: &p2p.Message{},
89 }
90 pk := ed25519.GenPrivKey()
91 pc, err := testOutboundPeerConn(addr, config, false, pk)
92 if err != nil {
93 return nil, err
94 }
95 timeout := 1 * time.Second
96 ourNodeInfo := testNodeInfo(addr.ID, "host_peer")
97 peerNodeInfo, err := handshake(pc.conn, timeout, ourNodeInfo)
98 if err != nil {
99 return nil, err
100 }
101
102 p := newPeer(pc, mConfig, peerNodeInfo, reactorsByCh, msgTypeByChID, chDescs, func(p Peer, r interface{}) {}, newMetricsLabelCache())
103 p.SetLogger(log.TestingLogger().With("peer", addr))
104 return p, nil
105}
106
107func testDial(addr *NetAddress, cfg *config.P2PConfig) (net.Conn, error) {
108 if cfg.TestDialFail {

Callers 2

TestPeerBasicFunction · 0.85
TestPeerSendFunction · 0.85

Calls 10

GenPrivKeyFunction · 0.92
TestingLoggerFunction · 0.92
NewTestReactorFunction · 0.85
testOutboundPeerConnFunction · 0.85
testNodeInfoFunction · 0.85
handshakeFunction · 0.85
newPeerFunction · 0.85
newMetricsLabelCacheFunction · 0.85
SetLoggerMethod · 0.65
WithMethod · 0.65

Tested by

no test coverage detected