node, p2p: move network config out of Server

This silences a go vet message about copying p2p.Server in package node.
This commit is contained in:
Felix Lange
2016-05-18 11:31:00 +02:00
parent c8a8ad97f7
commit 542b839ec7
4 changed files with 36 additions and 28 deletions

View File

@ -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 {