mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-28 12:11:44 +00:00
Use remotePeer for test switch
This commit is contained in:
@ -154,7 +154,7 @@ func (p *remotePeer) accept(l net.Listener) {
|
|||||||
_, err = pc.HandshakeTimeout(NodeInfo{
|
_, err = pc.HandshakeTimeout(NodeInfo{
|
||||||
ID: p.Addr().ID,
|
ID: p.Addr().ID,
|
||||||
Moniker: "remote_peer",
|
Moniker: "remote_peer",
|
||||||
Network: "testing",
|
Network: "localhost",
|
||||||
Version: "123.123.123",
|
Version: "123.123.123",
|
||||||
ListenAddr: l.Addr().String(),
|
ListenAddr: l.Addr().String(),
|
||||||
Channels: []byte{testCh},
|
Channels: []byte{testCh},
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package p2p
|
package p2p
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"time"
|
||||||
|
|
||||||
crypto "github.com/tendermint/go-crypto"
|
crypto "github.com/tendermint/go-crypto"
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
@ -80,7 +82,37 @@ func MakeConnectedSwitches(cfg *cfg.P2PConfig, n int, initSwitch func(int, *Swit
|
|||||||
func Connect2Switches(switches []*Switch, i, j int) {
|
func Connect2Switches(switches []*Switch, i, j int) {
|
||||||
switchI := switches[i]
|
switchI := switches[i]
|
||||||
switchJ := switches[j]
|
switchJ := switches[j]
|
||||||
c1, c2 := conn.NetPipe()
|
|
||||||
|
p1 := &remotePeer{
|
||||||
|
Config: switchJ.peerConfig,
|
||||||
|
PrivKey: switchJ.nodeKey.PrivKey,
|
||||||
|
}
|
||||||
|
p1.Start()
|
||||||
|
|
||||||
|
c1, err := net.DialTimeout(
|
||||||
|
"tcp",
|
||||||
|
fmt.Sprintf("%s:%d", p1.addr.IP.String(), p1.addr.Port),
|
||||||
|
100*time.Millisecond,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
p2 := &remotePeer{
|
||||||
|
Config: switchI.peerConfig,
|
||||||
|
PrivKey: switchI.nodeKey.PrivKey,
|
||||||
|
}
|
||||||
|
p2.Start()
|
||||||
|
|
||||||
|
c2, err := net.DialTimeout(
|
||||||
|
"tcp",
|
||||||
|
fmt.Sprintf("%s:%d", p2.addr.IP.String(), p2.addr.Port),
|
||||||
|
100*time.Millisecond,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
doneCh := make(chan struct{})
|
doneCh := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
err := switchI.addPeerWithConnection(c1)
|
err := switchI.addPeerWithConnection(c1)
|
||||||
|
Reference in New Issue
Block a user