diff --git a/cmd/swarm/config.go b/cmd/swarm/config.go index d50c65b438..32cd442a03 100644 --- a/cmd/swarm/config.go +++ b/cmd/swarm/config.go @@ -135,9 +135,9 @@ func initSwarmNode(config *bzzapi.Config, stack *node.Node, ctx *cli.Context, no return err } //configuration phase completed here - log.Info("Starting Swarm with the following parameters:") + log.Debug("Starting Swarm with the following parameters:") //after having created the config, print it to screen - log.Info(printConfig(config)) + log.Debug(printConfig(config)) return nil } diff --git a/cmd/swarm/config_test.go b/cmd/swarm/config_test.go index ee6b0c0825..869edd0f70 100644 --- a/cmd/swarm/config_test.go +++ b/cmd/swarm/config_test.go @@ -31,7 +31,6 @@ import ( "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/swarm" "github.com/ethereum/go-ethereum/swarm/api" - "github.com/ethereum/go-ethereum/swarm/log" ) func TestConfigDump(t *testing.T) { @@ -162,16 +161,6 @@ func TestConfigFileOverrides(t *testing.T) { defaultConf.HiveParams.KeepAliveInterval = 6000000000 defaultConf.Swap.Params.Strategy.AutoCashInterval = 600 * time.Second //defaultConf.SyncParams.KeyBufferSize = 512 - - dir, err := ioutil.TempDir("", "bzztest") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(dir) - conf, account, pk := getTestAccountWithPrivateKey(t, dir) - node := &testNode{Dir: dir} - defaultConf.Init(pk) - //create a TOML string out, err := tomlSettings.Marshal(&defaultConf) if err != nil { @@ -189,6 +178,14 @@ func TestConfigFileOverrides(t *testing.T) { } f.Sync() + dir, err := ioutil.TempDir("", "bzztest") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(dir) + conf, account := getTestAccount(t, dir) + node := &testNode{Dir: dir} + flags := []string{ fmt.Sprintf("--%s", SwarmTomlConfigPathFlag.Name), f.Name(), fmt.Sprintf("--%s", SwarmAccountFlag.Name), account.Address.String(), @@ -375,19 +372,6 @@ func TestConfigCmdLineOverridesFile(t *testing.T) { defaultConf.HiveParams.KeepAliveInterval = 6000000000 defaultConf.Swap.Params.Strategy.AutoCashInterval = 600 * time.Second //defaultConf.SyncParams.KeyBufferSize = 512 - - dir, err := ioutil.TempDir("", "bzztest") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(dir) - conf, account, pk := getTestAccountWithPrivateKey(t, dir) - node := &testNode{Dir: dir} - - expectNetworkId := uint64(77) - - defaultConf.Init(pk) - //create a TOML file out, err := tomlSettings.Marshal(&defaultConf) if err != nil { @@ -407,6 +391,16 @@ func TestConfigCmdLineOverridesFile(t *testing.T) { } f.Sync() + dir, err := ioutil.TempDir("", "bzztest") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(dir) + conf, account := getTestAccount(t, dir) + node := &testNode{Dir: dir} + + expectNetworkId := uint64(77) + flags := []string{ fmt.Sprintf("--%s", SwarmNetworkIdFlag.Name), "77", fmt.Sprintf("--%s", SwarmPortFlag.Name), httpPort, @@ -417,7 +411,6 @@ func TestConfigCmdLineOverridesFile(t *testing.T) { fmt.Sprintf("--%s", utils.DataDirFlag.Name), dir, fmt.Sprintf("--%s", utils.IPCPathFlag.Name), conf.IPCPath, } - log.Warn("exec with flags", "f", flags) node.Cmd = runSwarm(t, flags...) node.Cmd.InputLine(testPassphrase) defer func() { diff --git a/cmd/swarm/run_test.go b/cmd/swarm/run_test.go index 2fff3c7063..9681c8990a 100644 --- a/cmd/swarm/run_test.go +++ b/cmd/swarm/run_test.go @@ -222,12 +222,7 @@ type testNode struct { const testPassphrase = "swarm-test-passphrase" func getTestAccount(t *testing.T, dir string) (conf *node.Config, account accounts.Account) { - conf, account, _ = getTestAccountWithPrivateKey(t, dir) - return -} - -func getTestAccountWithPrivateKey(t *testing.T, dir string) (conf *node.Config, account accounts.Account, pk *ecdsa.PrivateKey) { - // create kej + // create key conf = &node.Config{ DataDir: dir, IPCPath: "bzzd.ipc", @@ -237,19 +232,17 @@ func getTestAccountWithPrivateKey(t *testing.T, dir string) (conf *node.Config, if err != nil { t.Fatal(err) } - ks := n.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) - account, err = ks.NewAccount(testPassphrase) + account, err = n.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore).NewAccount(testPassphrase) if err != nil { t.Fatal(err) } - pk = decryptStoreAccount(ks, account.Address.String(), []string{testPassphrase}) // use a unique IPCPath when running tests on Windows if runtime.GOOS == "windows" { conf.IPCPath = fmt.Sprintf("bzzd-%s.ipc", account.Address.String()) } - return conf, account, pk + return conf, account } func existingTestNode(t *testing.T, dir string, bzzaccount string) *testNode { diff --git a/p2p/simulations/adapters/types.go b/p2p/simulations/adapters/types.go index 74a144a713..1c82d6737c 100644 --- a/p2p/simulations/adapters/types.go +++ b/p2p/simulations/adapters/types.go @@ -268,14 +268,11 @@ func RegisterServices(services Services) { } func (n *NodeConfig) initEnode(ip net.IP, tcpport int, udpport int) error { - - // dialer in simulations based on ENR records - // doesn't work unless we explicitly set localhost record - enrIp := enr.IP(net.IPv4(127, 0, 0, 1)) + enrIp := enr.IP(ip) n.Record.Set(&enrIp) - enrTcpPort := enr.TCP(0) + enrTcpPort := enr.TCP(tcpport) n.Record.Set(&enrTcpPort) - enrUdpPort := enr.UDP(0) + enrUdpPort := enr.UDP(tcpport) n.Record.Set(&enrUdpPort) err := enode.SignV4(&n.Record, n.PrivateKey) diff --git a/swarm/api/config.go b/swarm/api/config.go index ad2e4f827a..f517d729aa 100644 --- a/swarm/api/config.go +++ b/swarm/api/config.go @@ -29,6 +29,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/p2p/enode" + "github.com/ethereum/go-ethereum/p2p/enr" "github.com/ethereum/go-ethereum/swarm/network" "github.com/ethereum/go-ethereum/swarm/pss" "github.com/ethereum/go-ethereum/swarm/services/swap" @@ -47,18 +48,17 @@ type Config struct { *storage.FileStoreParams *storage.LocalStoreParams *network.HiveParams - Swap *swap.LocalProfile - Pss *pss.PssParams - Contract common.Address - EnsRoot common.Address - EnsAPIs []string - Path string - ListenAddr string - Port string - PublicKey string - BzzKey string - //NodeID string - Enode *enode.Node `toml:",omit"` + Swap *swap.LocalProfile + Pss *pss.PssParams + Contract common.Address + EnsRoot common.Address + EnsAPIs []string + Path string + ListenAddr string + Port string + PublicKey string + BzzKey string + Enode *enode.Node `toml:"-"` NetworkID uint64 SwapEnabled bool SyncEnabled bool @@ -87,7 +87,6 @@ func NewConfig() (c *Config) { ListenAddr: DefaultHTTPListenAddr, Port: DefaultHTTPPort, Path: node.DefaultDataDir(), - Enode: &enode.Node{}, EnsAPIs: nil, EnsRoot: ens.TestNetAddress, NetworkID: network.DefaultNetworkID, diff --git a/swarm/swarm.go b/swarm/swarm.go index 05833cf15e..61813e23fc 100644 --- a/swarm/swarm.go +++ b/swarm/swarm.go @@ -171,7 +171,6 @@ func NewSwarm(config *api.Config, mockStore *mock.NodeStore) (self *Swarm, err e } nodeID := config.Enode.ID() - bzzconfig.UnderlayAddr = []byte(nodeID.String()) syncing := stream.SyncingAutoSubscribe if !config.SyncEnabled || config.LightNodeEnabled {