Revert "swarm/network: Use actual remote peer ip in underlay (#19137)" (#19193)

This reverts commit 460d206f30.
This commit is contained in:
Anton Evangelatov
2019-03-02 08:45:07 +01:00
committed by Viktor Trón
parent b797dd07d2
commit f9aa1cd21f
2 changed files with 1 additions and 46 deletions

View File

@ -17,15 +17,12 @@
package network
import (
"bytes"
"flag"
"fmt"
"net"
"os"
"testing"
"time"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/enode"
@ -254,26 +251,3 @@ func TestBzzHandshakeLightNode(t *testing.T) {
})
}
}
// Tests the overwriting of localhost enode in handshake if actual remote ip is known
// (swarm.network/protocol.go:sanitizeEnodeRemote)
func TestSanitizeEnodeRemote(t *testing.T) {
pk, err := crypto.GenerateKey()
if err != nil {
t.Fatal(err)
}
remoteIP := net.IPv4(0x80, 0x40, 0x20, 0x10)
remoteAddr := net.TCPAddr{
IP: remoteIP,
Port: 30399,
}
nodLocal := enode.NewV4(&pk.PublicKey, net.IPv4(0x7f, 0x00, 0x00, 0x01), 30341, 30341)
nodRemote := enode.NewV4(&pk.PublicKey, remoteIP, 30341, 30341)
baddr := RandomAddr()
oldUAddr := []byte(nodLocal.String())
baddr.UAddr = oldUAddr
sanitizeEnodeRemote(&remoteAddr, baddr)
if !bytes.Equal(baddr.UAddr, []byte(nodRemote.String())) {
t.Fatalf("insane address. expected %v, got %v", nodRemote.String(), string(baddr.UAddr))
}
}