|
|
@ -8,7 +8,7 @@ import ( |
|
|
|
|
|
|
|
|
|
|
|
"github.com/harmony-one/harmony/internal/utils" |
|
|
|
"github.com/harmony-one/harmony/internal/utils" |
|
|
|
"github.com/harmony-one/harmony/p2p" |
|
|
|
"github.com/harmony-one/harmony/p2p" |
|
|
|
"github.com/harmony-one/harmony/p2p/host/hostv2" |
|
|
|
"github.com/harmony-one/harmony/p2p/p2pimpl" |
|
|
|
|
|
|
|
|
|
|
|
peer "github.com/libp2p/go-libp2p-peer" |
|
|
|
peer "github.com/libp2p/go-libp2p-peer" |
|
|
|
multiaddr "github.com/multiformats/go-multiaddr" |
|
|
|
multiaddr "github.com/multiformats/go-multiaddr" |
|
|
@ -21,7 +21,7 @@ func TestSendMessage(test *testing.T) { |
|
|
|
priKey1, pubKey1, _ := utils.GenKeyP2P(peer1.IP, peer1.Port) |
|
|
|
priKey1, pubKey1, _ := utils.GenKeyP2P(peer1.IP, peer1.Port) |
|
|
|
peerID1, _ := peer.IDFromPublicKey(pubKey1) |
|
|
|
peerID1, _ := peer.IDFromPublicKey(pubKey1) |
|
|
|
peer1.PeerID = peerID1 |
|
|
|
peer1.PeerID = peerID1 |
|
|
|
host1 := hostv2.New(&peer1, priKey1) |
|
|
|
host1, _ := p2pimpl.NewHost(&peer1, priKey1) |
|
|
|
|
|
|
|
|
|
|
|
peer2 := p2p.Peer{IP: "127.0.0.1", Port: "9001"} |
|
|
|
peer2 := p2p.Peer{IP: "127.0.0.1", Port: "9001"} |
|
|
|
selfAddr2, _ := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/0.0.0.0/tcp/%s", peer2.Port)) |
|
|
|
selfAddr2, _ := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/0.0.0.0/tcp/%s", peer2.Port)) |
|
|
@ -29,7 +29,7 @@ func TestSendMessage(test *testing.T) { |
|
|
|
priKey2, pubKey2, _ := utils.GenKeyP2P(peer2.IP, peer2.Port) |
|
|
|
priKey2, pubKey2, _ := utils.GenKeyP2P(peer2.IP, peer2.Port) |
|
|
|
peerID2, _ := peer.IDFromPublicKey(pubKey2) |
|
|
|
peerID2, _ := peer.IDFromPublicKey(pubKey2) |
|
|
|
peer2.PeerID = peerID2 |
|
|
|
peer2.PeerID = peerID2 |
|
|
|
host2 := hostv2.New(&peer2, priKey2) |
|
|
|
host2, _ := p2pimpl.NewHost(&peer2, priKey2) |
|
|
|
|
|
|
|
|
|
|
|
msg := []byte{0x00, 0x01, 0x02, 0x03, 0x04} |
|
|
|
msg := []byte{0x00, 0x01, 0x02, 0x03, 0x04} |
|
|
|
if err := host1.AddPeer(&peer2); err != nil { |
|
|
|
if err := host1.AddPeer(&peer2); err != nil { |
|
|
|