aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/rlpx_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'p2p/rlpx_test.go')
-rw-r--r--p2p/rlpx_test.go31
1 files changed, 2 insertions, 29 deletions
diff --git a/p2p/rlpx_test.go b/p2p/rlpx_test.go
index bca460402..7ae800774 100644
--- a/p2p/rlpx_test.go
+++ b/p2p/rlpx_test.go
@@ -35,6 +35,7 @@ import (
"github.com/ethereum/go-ethereum/crypto/ecies"
"github.com/ethereum/go-ethereum/crypto/sha3"
"github.com/ethereum/go-ethereum/p2p/discover"
+ "github.com/ethereum/go-ethereum/p2p/simulations/pipes"
"github.com/ethereum/go-ethereum/rlp"
)
@@ -159,7 +160,7 @@ func TestProtocolHandshake(t *testing.T) {
wg sync.WaitGroup
)
- fd0, fd1, err := tcpPipe()
+ fd0, fd1, err := pipes.TCPPipe()
if err != nil {
t.Fatal(err)
}
@@ -601,31 +602,3 @@ func TestHandshakeForwardCompatibility(t *testing.T) {
t.Errorf("ingress-mac('foo') mismatch:\ngot %x\nwant %x", fooIngressHash, wantFooIngressHash)
}
}
-
-// tcpPipe creates an in process full duplex pipe based on a localhost TCP socket
-func tcpPipe() (net.Conn, net.Conn, error) {
- l, err := net.Listen("tcp", "127.0.0.1:0")
- if err != nil {
- return nil, nil, err
- }
- defer l.Close()
-
- var aconn net.Conn
- aerr := make(chan error, 1)
- go func() {
- var err error
- aconn, err = l.Accept()
- aerr <- err
- }()
-
- dconn, err := net.Dial("tcp", l.Addr().String())
- if err != nil {
- <-aerr
- return nil, nil, err
- }
- if err := <-aerr; err != nil {
- dconn.Close()
- return nil, nil, err
- }
- return aconn, dconn, nil
-}