diff options
author | Felix Lange <fjl@twurst.com> | 2016-05-18 17:31:00 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-05-18 18:19:04 +0800 |
commit | 542b839ec74ff0ce94ab0d34e25531f5819d95d1 (patch) | |
tree | 75fa706a695285a134efc5d3c7ed4a5f497e04b3 /p2p/server_test.go | |
parent | c8a8ad97f7e8889ca9f3aece7ddb50cce8ef18c7 (diff) | |
download | dexon-542b839ec74ff0ce94ab0d34e25531f5819d95d1.tar.gz dexon-542b839ec74ff0ce94ab0d34e25531f5819d95d1.tar.zst dexon-542b839ec74ff0ce94ab0d34e25531f5819d95d1.zip |
node, p2p: move network config out of Server
This silences a go vet message about copying p2p.Server in package node.
Diffstat (limited to 'p2p/server_test.go')
-rw-r--r-- | p2p/server_test.go | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/p2p/server_test.go b/p2p/server_test.go index b437ac367..deb34f5bb 100644 --- a/p2p/server_test.go +++ b/p2p/server_test.go @@ -67,11 +67,14 @@ func (c *testTransport) close(err error) { } func startTestServer(t *testing.T, id discover.NodeID, pf func(*Peer)) *Server { + config := Config{ + Name: "test", + MaxPeers: 10, + ListenAddr: "127.0.0.1:0", + PrivateKey: newkey(), + } server := &Server{ - Name: "test", - MaxPeers: 10, - ListenAddr: "127.0.0.1:0", - PrivateKey: newkey(), + Config: config, newPeerHook: pf, newTransport: func(fd net.Conn) transport { return newTestTransport(id, fd) }, } @@ -200,10 +203,10 @@ func TestServerTaskScheduling(t *testing.T) { // The Server in this test isn't actually running // because we're only interested in what run does. srv := &Server{ - MaxPeers: 10, - quit: make(chan struct{}), - ntab: fakeTable{}, - running: true, + Config: Config{MaxPeers: 10}, + quit: make(chan struct{}), + ntab: fakeTable{}, + running: true, } srv.loopWG.Add(1) go func() { @@ -314,10 +317,12 @@ func (t *testTask) Do(srv *Server) { func TestServerAtCap(t *testing.T) { trustedID := randomID() srv := &Server{ - PrivateKey: newkey(), - MaxPeers: 10, - NoDial: true, - TrustedNodes: []*discover.Node{{ID: trustedID}}, + Config: Config{ + PrivateKey: newkey(), + MaxPeers: 10, + NoDial: true, + TrustedNodes: []*discover.Node{{ID: trustedID}}, + }, } if err := srv.Start(); err != nil { t.Fatalf("could not start: %v", err) @@ -415,10 +420,12 @@ func TestServerSetupConn(t *testing.T) { for i, test := range tests { srv := &Server{ - PrivateKey: srvkey, - MaxPeers: 10, - NoDial: true, - Protocols: []Protocol{discard}, + Config: Config{ + PrivateKey: srvkey, + MaxPeers: 10, + NoDial: true, + Protocols: []Protocol{discard}, + }, newTransport: func(fd net.Conn) transport { return test.tt }, } if !test.dontstart { |