MCPcopy Create free account
hub / github.com/DOSNetwork/core / TestExchangeID

Function TestExchangeID

p2p/client_test.go:61–85  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func TestExchangeID(t *testing.T) {
62 var listenerA net.Listener
63 var err error
64 if listenerA, err = net.Listen("tcp", ":9901"); err != nil {
65 return
66 }
67 go listen(t, listenerA, "server")
68
69 add := "localhost:9901"
70 var conn net.Conn
71 var client *client
72 if conn, err = net.Dial("tcp", add); err != nil {
73 t.Errorf("Can't Dial to %s ,Error %s", add, err.Error())
74 }
75 suite := suites.MustFind("bn256")
76 secret := suite.Scalar().Pick(suite.RandomStream())
77 public := suite.Point().Mul(secret, nil)
78 client, err = newClient(suite, secret, public, []byte("local"), conn, false)
79 if err != nil {
80 t.Errorf("newClient,Error %s", err.Error())
81 }
82 if string(client.localID) != "local" || string(client.remoteID) != "server" {
83 t.Errorf("ExchangeID ,Error %s %s", string(client.localID), string(client.remoteID))
84 }
85}
86
87func TestRequest(t *testing.T) {
88 var listenerA net.Listener

Callers

nothing calls this directly

Calls 9

listenFunction · 0.85
newClientFunction · 0.85
ListenMethod · 0.65
ErrorMethod · 0.65
PickMethod · 0.45
ScalarMethod · 0.45
RandomStreamMethod · 0.45
MulMethod · 0.45
PointMethod · 0.45

Tested by

no test coverage detected