mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
node: make tests compile
This commit is contained in:
parent
e6e5664396
commit
6bb697d649
3 changed files with 6 additions and 21 deletions
|
|
@ -25,6 +25,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/p2p"
|
||||
)
|
||||
|
||||
// Tests that datadirs can be successfully created, be them manually configured
|
||||
|
|
@ -109,7 +110,7 @@ func TestNodeKeyPersistency(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("failed to generate one-shot node key: %v", err)
|
||||
}
|
||||
config := &Config{Name: "unit-test", DataDir: dir, PrivateKey: key}
|
||||
config := &Config{Name: "unit-test", DataDir: dir, P2P: p2p.Config{PrivateKey: key}}
|
||||
config.NodeKey()
|
||||
if _, err := os.Stat(filepath.Join(keyfile)); err == nil {
|
||||
t.Fatalf("one-shot node key persisted to data directory")
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import (
|
|||
|
||||
"github.com/ethereum/go-ethereum/node"
|
||||
"github.com/ethereum/go-ethereum/p2p"
|
||||
"github.com/ethereum/go-ethereum/p2p/discover"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
)
|
||||
|
||||
|
|
@ -42,23 +41,8 @@ func (s *SampleService) Start(*p2p.Server) error { fmt.Println("Service starti
|
|||
func (s *SampleService) Stop() error { fmt.Println("Service stopping..."); return nil }
|
||||
|
||||
func ExampleService() {
|
||||
// Create a network node to run protocols with the default values. The below list
|
||||
// is only used to display each of the configuration options. All of these could
|
||||
// have been omitted if the default behavior is desired.
|
||||
nodeConfig := &node.Config{
|
||||
DataDir: "", // Empty uses ephemeral storage
|
||||
PrivateKey: nil, // Nil generates a node key on the fly
|
||||
Name: "", // Any textual node name is allowed
|
||||
NoDiscovery: false, // Can disable discovering remote nodes
|
||||
BootstrapNodes: []*discover.Node{}, // List of bootstrap nodes to use
|
||||
ListenAddr: ":0", // Network interface to listen on
|
||||
NAT: nil, // UPnP port mapper to use for crossing firewalls
|
||||
Dialer: nil, // Custom dialer to use for establishing peer connections
|
||||
NoDial: false, // Can prevent this node from dialing out
|
||||
MaxPeers: 0, // Number of peers to allow
|
||||
MaxPendingPeers: 0, // Number of peers allowed to handshake concurrently
|
||||
}
|
||||
stack, err := node.New(nodeConfig)
|
||||
// Create a network node to run protocols with the default values.
|
||||
stack, err := node.New(&node.Config{})
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create network node: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ var (
|
|||
|
||||
func testNodeConfig() *Config {
|
||||
return &Config{
|
||||
PrivateKey: testNodeKey,
|
||||
Name: "test node",
|
||||
Name: "test node",
|
||||
P2P: p2p.Config{PrivateKey: testNodeKey},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue