Remove NetworkID from cluster (#1163)

This commit is contained in:
Adam Babik 2018-08-26 12:54:58 +02:00 committed by GitHub
parent 7cd81a69f7
commit 3521c2ac45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 285 additions and 550 deletions

View File

@ -1,7 +1,5 @@
package params package params
import "errors"
// Define available fleets. // Define available fleets.
const ( const (
FleetUndefined = "" FleetUndefined = ""
@ -11,124 +9,63 @@ const (
// Cluster defines a list of Ethereum nodes. // Cluster defines a list of Ethereum nodes.
type Cluster struct { type Cluster struct {
NetworkID int `json:"networkID"`
StaticNodes []string `json:"staticnodes"` StaticNodes []string `json:"staticnodes"`
BootNodes []string `json:"bootnodes"` BootNodes []string `json:"bootnodes"`
MailServers []string `json:"mailservers"` // list of trusted mail servers MailServers []string `json:"mailservers"` // list of trusted mail servers
RendezvousNodes []string `json:"rendezvousnodes"` RendezvousNodes []string `json:"rendezvousnodes"`
} }
var ropstenCluster = Cluster{ // Consult this list with http://fleets.status.im/.
NetworkID: RopstenNetworkID, var clusters = map[string]func() Cluster{
BootNodes: []string{ FleetStaging: func() Cluster {
"enode://436cc6f674928fdc9a9f7990f2944002b685d1c37f025c1be425185b5b1f0900feaf1ccc2a6130268f9901be4a7d252f37302c8335a2c1a62736e9232691cc3a@174.138.105.243:30404", // boot-01.do-ams3.eth.beta return Cluster{
"enode://5395aab7833f1ecb671b59bf0521cf20224fe8162fc3d2675de4ee4d5636a75ec32d13268fc184df8d1ddfa803943906882da62a4df42d4fccf6d17808156a87@206.189.243.57:30404", // boot-02.do-ams3.eth.beta BootNodes: []string{
"enode://7427dfe38bd4cf7c58bb96417806fab25782ec3e6046a8053370022cbaa281536e8d64ecd1b02e1f8f72768e295d06258ba43d88304db068e6f2417ae8bcb9a6@104.154.88.123:30404", // boot-01.gc-us-central1-a.eth.beta "enode://10a78c17929a7019ef4aa2249d7302f76ae8a06f40b2dc88b7b31ebff4a623fbb44b4a627acba296c1ced3775d91fbe18463c15097a6a36fdb2c804ff3fc5b35@35.238.97.234:30404", // boot-01.gc-us-central1-a.eth.staging
"enode://ebefab39b69bbbe64d8cd86be765b3be356d8c4b24660f65d493143a0c44f38c85a257300178f7845592a1b0332811542e9a58281c835babdd7535babb64efc1@35.202.99.224:30404", // boot-02.gc-us-central1-a.eth.beta "enode://f79fb3919f72ca560ad0434dcc387abfe41e0666201ebdada8ede0462454a13deb05cda15f287d2c4bd85da81f0eb25d0a486bbbc8df427b971ac51533bd00fe@174.138.107.239:30404", // boot-01.do-ams3.eth.staging
},
StaticNodes: []string{
"enode://914c0b30f27bab30c1dfd31dad7652a46fda9370542aee1b062498b1345ee0913614b8b9e3e84622e84a7203c5858ae1d9819f63aece13ee668e4f6668063989@167.99.19.148:30305", // node-01.do-ams3.eth.staging
"enode://2d897c6e846949f9dcf10279f00e9b8325c18fe7fa52d658520ad7be9607c83008b42b06aefd97cfe1fdab571f33a2a9383ff97c5909ed51f63300834913237e@35.192.0.86:30305", // "node-01.gc-us-central1-a.eth.staging"
},
MailServers: []string{
"enode://69f72baa7f1722d111a8c9c68c39a31430e9d567695f6108f31ccb6cd8f0adff4991e7fdca8fa770e75bc8a511a87d24690cbc80e008175f40c157d6f6788d48@206.189.240.16:30504", // mail-01.do-ams3.eth.staging
"enode://e4fc10c1f65c8aed83ac26bc1bfb21a45cc1a8550a58077c8d2de2a0e0cd18e40fd40f7e6f7d02dc6cd06982b014ce88d6e468725ffe2c138e958788d0002a7f@35.239.193.41:30504", // mail-01.gc-us-central1-a.eth.staging
},
RendezvousNodes: []string{
"/ip4/174.138.107.239/tcp/30703/ethv4/16Uiu2HAkyJHeetQ4DNpd4NZ2ntzxMo25zcdpvGQRqkD5pB9BE6RU",
"/ip4/35.238.97.234/tcp/30703/ethv4/16Uiu2HAm1sVyXmkMNjdeDWqK2urbyC3oBHi8MDpCdYkns1nYafqz",
},
}
}, },
StaticNodes: []string{ FleetBeta: func() Cluster {
"enode://a6a2a9b3a7cbb0a15da74301537ebba549c990e3325ae78e1272a19a3ace150d03c184b8ac86cc33f1f2f63691e467d49308f02d613277754c4dccd6773b95e8@206.189.243.176:30304", // node-01.do-ams3.eth.beta return Cluster{
"enode://207e53d9bf66be7441e3daba36f53bfbda0b6099dba9a865afc6260a2d253fb8a56a72a48598a4f7ba271792c2e4a8e1a43aaef7f34857f520c8c820f63b44c8@35.224.15.65:30304", // node-01.gc-us-central1-a.eth.beta BootNodes: []string{
}, "enode://436cc6f674928fdc9a9f7990f2944002b685d1c37f025c1be425185b5b1f0900feaf1ccc2a6130268f9901be4a7d252f37302c8335a2c1a62736e9232691cc3a@174.138.105.243:30404", // boot-01.do-ams3.eth.beta
MailServers: []string{ "enode://5395aab7833f1ecb671b59bf0521cf20224fe8162fc3d2675de4ee4d5636a75ec32d13268fc184df8d1ddfa803943906882da62a4df42d4fccf6d17808156a87@206.189.243.57:30404", // boot-02.do-ams3.eth.beta
"enode://c42f368a23fa98ee546fd247220759062323249ef657d26d357a777443aec04db1b29a3a22ef3e7c548e18493ddaf51a31b0aed6079bd6ebe5ae838fcfaf3a49@206.189.243.162:30504", // mail-01.do-ams3.eth.beta "enode://7427dfe38bd4cf7c58bb96417806fab25782ec3e6046a8053370022cbaa281536e8d64ecd1b02e1f8f72768e295d06258ba43d88304db068e6f2417ae8bcb9a6@104.154.88.123:30404", // boot-01.gc-us-central1-a.eth.beta
"enode://7aa648d6e855950b2e3d3bf220c496e0cae4adfddef3e1e6062e6b177aec93bc6cdcf1282cb40d1656932ebfdd565729da440368d7c4da7dbd4d004b1ac02bf8@206.189.243.169:30504", // mail-02.do-ams3.eth.beta "enode://ebefab39b69bbbe64d8cd86be765b3be356d8c4b24660f65d493143a0c44f38c85a257300178f7845592a1b0332811542e9a58281c835babdd7535babb64efc1@35.202.99.224:30404", // boot-02.gc-us-central1-a.eth.beta
"enode://8a64b3c349a2e0ef4a32ea49609ed6eb3364be1110253c20adc17a3cebbc39a219e5d3e13b151c0eee5d8e0f9a8ba2cd026014e67b41a4ab7d1d5dd67ca27427@206.189.243.168:30504", // mail-03.do-ams3.eth.beta },
"enode://7de99e4cb1b3523bd26ca212369540646607c721ad4f3e5c821ed9148150ce6ce2e72631723002210fac1fd52dfa8bbdf3555e05379af79515e1179da37cc3db@35.188.19.210:30504", // mail-01.gc-us-central1-a.eth.beta StaticNodes: []string{
"enode://015e22f6cd2b44c8a51bd7a23555e271e0759c7d7f52432719665a74966f2da456d28e154e836bee6092b4d686fe67e331655586c57b718be3997c1629d24167@35.226.21.19:30504", // mail-02.gc-us-central1-a.eth.beta "enode://a6a2a9b3a7cbb0a15da74301537ebba549c990e3325ae78e1272a19a3ace150d03c184b8ac86cc33f1f2f63691e467d49308f02d613277754c4dccd6773b95e8@206.189.243.176:30304", // node-01.do-ams3.eth.beta
"enode://531e252ec966b7e83f5538c19bf1cde7381cc7949026a6e499b6e998e695751aadf26d4c98d5a4eabfb7cefd31c3c88d600a775f14ed5781520a88ecd25da3c6@35.225.227.79:30504", // mail-03.gc-us-central1-a.eth.beta "enode://207e53d9bf66be7441e3daba36f53bfbda0b6099dba9a865afc6260a2d253fb8a56a72a48598a4f7ba271792c2e4a8e1a43aaef7f34857f520c8c820f63b44c8@35.224.15.65:30304", // node-01.gc-us-central1-a.eth.beta
}, },
} MailServers: []string{
"enode://c42f368a23fa98ee546fd247220759062323249ef657d26d357a777443aec04db1b29a3a22ef3e7c548e18493ddaf51a31b0aed6079bd6ebe5ae838fcfaf3a49@206.189.243.162:30504", // mail-01.do-ams3.eth.beta
var rinkebyCluster = Cluster{ "enode://7aa648d6e855950b2e3d3bf220c496e0cae4adfddef3e1e6062e6b177aec93bc6cdcf1282cb40d1656932ebfdd565729da440368d7c4da7dbd4d004b1ac02bf8@206.189.243.169:30504", // mail-02.do-ams3.eth.beta
NetworkID: RinkebyNetworkID, "enode://8a64b3c349a2e0ef4a32ea49609ed6eb3364be1110253c20adc17a3cebbc39a219e5d3e13b151c0eee5d8e0f9a8ba2cd026014e67b41a4ab7d1d5dd67ca27427@206.189.243.168:30504", // mail-03.do-ams3.eth.beta
BootNodes: []string{ "enode://7de99e4cb1b3523bd26ca212369540646607c721ad4f3e5c821ed9148150ce6ce2e72631723002210fac1fd52dfa8bbdf3555e05379af79515e1179da37cc3db@35.188.19.210:30504", // mail-01.gc-us-central1-a.eth.beta
"enode://436cc6f674928fdc9a9f7990f2944002b685d1c37f025c1be425185b5b1f0900feaf1ccc2a6130268f9901be4a7d252f37302c8335a2c1a62736e9232691cc3a@174.138.105.243:30404", // boot-01.do-ams3.eth.beta "enode://015e22f6cd2b44c8a51bd7a23555e271e0759c7d7f52432719665a74966f2da456d28e154e836bee6092b4d686fe67e331655586c57b718be3997c1629d24167@35.226.21.19:30504", // mail-02.gc-us-central1-a.eth.beta
"enode://5395aab7833f1ecb671b59bf0521cf20224fe8162fc3d2675de4ee4d5636a75ec32d13268fc184df8d1ddfa803943906882da62a4df42d4fccf6d17808156a87@206.189.243.57:30404", // boot-02.do-ams3.eth.beta "enode://531e252ec966b7e83f5538c19bf1cde7381cc7949026a6e499b6e998e695751aadf26d4c98d5a4eabfb7cefd31c3c88d600a775f14ed5781520a88ecd25da3c6@35.225.227.79:30504", // mail-03.gc-us-central1-a.eth.beta
"enode://7427dfe38bd4cf7c58bb96417806fab25782ec3e6046a8053370022cbaa281536e8d64ecd1b02e1f8f72768e295d06258ba43d88304db068e6f2417ae8bcb9a6@104.154.88.123:30404", // boot-01.gc-us-central1-a.eth.beta },
"enode://ebefab39b69bbbe64d8cd86be765b3be356d8c4b24660f65d493143a0c44f38c85a257300178f7845592a1b0332811542e9a58281c835babdd7535babb64efc1@35.202.99.224:30404", // boot-02.gc-us-central1-a.eth.beta }
},
StaticNodes: []string{
"enode://a6a2a9b3a7cbb0a15da74301537ebba549c990e3325ae78e1272a19a3ace150d03c184b8ac86cc33f1f2f63691e467d49308f02d613277754c4dccd6773b95e8@206.189.243.176:30304", // node-01.do-ams3.eth.beta
"enode://207e53d9bf66be7441e3daba36f53bfbda0b6099dba9a865afc6260a2d253fb8a56a72a48598a4f7ba271792c2e4a8e1a43aaef7f34857f520c8c820f63b44c8@35.224.15.65:30304", // node-01.gc-us-central1-a.eth.beta
},
MailServers: []string{
"enode://c42f368a23fa98ee546fd247220759062323249ef657d26d357a777443aec04db1b29a3a22ef3e7c548e18493ddaf51a31b0aed6079bd6ebe5ae838fcfaf3a49@206.189.243.162:30504", // mail-01.do-ams3.eth.beta
"enode://7aa648d6e855950b2e3d3bf220c496e0cae4adfddef3e1e6062e6b177aec93bc6cdcf1282cb40d1656932ebfdd565729da440368d7c4da7dbd4d004b1ac02bf8@206.189.243.169:30504", // mail-02.do-ams3.eth.beta
"enode://8a64b3c349a2e0ef4a32ea49609ed6eb3364be1110253c20adc17a3cebbc39a219e5d3e13b151c0eee5d8e0f9a8ba2cd026014e67b41a4ab7d1d5dd67ca27427@206.189.243.168:30504", // mail-03.do-ams3.eth.beta
"enode://7de99e4cb1b3523bd26ca212369540646607c721ad4f3e5c821ed9148150ce6ce2e72631723002210fac1fd52dfa8bbdf3555e05379af79515e1179da37cc3db@35.188.19.210:30504", // mail-01.gc-us-central1-a.eth.beta
"enode://015e22f6cd2b44c8a51bd7a23555e271e0759c7d7f52432719665a74966f2da456d28e154e836bee6092b4d686fe67e331655586c57b718be3997c1629d24167@35.226.21.19:30504", // mail-02.gc-us-central1-a.eth.beta
"enode://531e252ec966b7e83f5538c19bf1cde7381cc7949026a6e499b6e998e695751aadf26d4c98d5a4eabfb7cefd31c3c88d600a775f14ed5781520a88ecd25da3c6@35.225.227.79:30504", // mail-03.gc-us-central1-a.eth.beta
},
}
var mainnetCluster = Cluster{
NetworkID: MainNetworkID,
BootNodes: []string{
"enode://436cc6f674928fdc9a9f7990f2944002b685d1c37f025c1be425185b5b1f0900feaf1ccc2a6130268f9901be4a7d252f37302c8335a2c1a62736e9232691cc3a@174.138.105.243:30404", // boot-01.do-ams3.eth.beta
"enode://5395aab7833f1ecb671b59bf0521cf20224fe8162fc3d2675de4ee4d5636a75ec32d13268fc184df8d1ddfa803943906882da62a4df42d4fccf6d17808156a87@206.189.243.57:30404", // boot-02.do-ams3.eth.beta
"enode://7427dfe38bd4cf7c58bb96417806fab25782ec3e6046a8053370022cbaa281536e8d64ecd1b02e1f8f72768e295d06258ba43d88304db068e6f2417ae8bcb9a6@104.154.88.123:30404", // boot-01.gc-us-central1-a.eth.beta
"enode://ebefab39b69bbbe64d8cd86be765b3be356d8c4b24660f65d493143a0c44f38c85a257300178f7845592a1b0332811542e9a58281c835babdd7535babb64efc1@35.202.99.224:30404", // boot-02.gc-us-central1-a.eth.beta
},
StaticNodes: []string{
"enode://a6a2a9b3a7cbb0a15da74301537ebba549c990e3325ae78e1272a19a3ace150d03c184b8ac86cc33f1f2f63691e467d49308f02d613277754c4dccd6773b95e8@206.189.243.176:30304", // node-01.do-ams3.eth.beta
"enode://207e53d9bf66be7441e3daba36f53bfbda0b6099dba9a865afc6260a2d253fb8a56a72a48598a4f7ba271792c2e4a8e1a43aaef7f34857f520c8c820f63b44c8@35.224.15.65:30304", // node-01.gc-us-central1-a.eth.beta
},
MailServers: []string{
"enode://c42f368a23fa98ee546fd247220759062323249ef657d26d357a777443aec04db1b29a3a22ef3e7c548e18493ddaf51a31b0aed6079bd6ebe5ae838fcfaf3a49@206.189.243.162:30504", // mail-01.do-ams3.eth.beta
"enode://7aa648d6e855950b2e3d3bf220c496e0cae4adfddef3e1e6062e6b177aec93bc6cdcf1282cb40d1656932ebfdd565729da440368d7c4da7dbd4d004b1ac02bf8@206.189.243.169:30504", // mail-02.do-ams3.eth.beta
"enode://8a64b3c349a2e0ef4a32ea49609ed6eb3364be1110253c20adc17a3cebbc39a219e5d3e13b151c0eee5d8e0f9a8ba2cd026014e67b41a4ab7d1d5dd67ca27427@206.189.243.168:30504", // mail-03.do-ams3.eth.beta
"enode://7de99e4cb1b3523bd26ca212369540646607c721ad4f3e5c821ed9148150ce6ce2e72631723002210fac1fd52dfa8bbdf3555e05379af79515e1179da37cc3db@35.188.19.210:30504", // mail-01.gc-us-central1-a.eth.beta
"enode://015e22f6cd2b44c8a51bd7a23555e271e0759c7d7f52432719665a74966f2da456d28e154e836bee6092b4d686fe67e331655586c57b718be3997c1629d24167@35.226.21.19:30504", // mail-02.gc-us-central1-a.eth.beta
"enode://531e252ec966b7e83f5538c19bf1cde7381cc7949026a6e499b6e998e695751aadf26d4c98d5a4eabfb7cefd31c3c88d600a775f14ed5781520a88ecd25da3c6@35.225.227.79:30504", // mail-03.gc-us-central1-a.eth.beta
},
}
var betaCluster = []Cluster{ropstenCluster, rinkebyCluster, mainnetCluster}
var stagingCluster = []Cluster{
{
NetworkID: MainNetworkID,
BootNodes: []string{
"enode://10a78c17929a7019ef4aa2249d7302f76ae8a06f40b2dc88b7b31ebff4a623fbb44b4a627acba296c1ced3775d91fbe18463c15097a6a36fdb2c804ff3fc5b35@35.238.97.234:30404", // boot-01.gc-us-central1-a.eth.staging
"enode://f79fb3919f72ca560ad0434dcc387abfe41e0666201ebdada8ede0462454a13deb05cda15f287d2c4bd85da81f0eb25d0a486bbbc8df427b971ac51533bd00fe@174.138.107.239:30404", // boot-01.do-ams3.eth.staging
},
RendezvousNodes: []string{
"/ip4/174.138.107.239/tcp/30703/ethv4/16Uiu2HAkyJHeetQ4DNpd4NZ2ntzxMo25zcdpvGQRqkD5pB9BE6RU",
"/ip4/35.238.97.234/tcp/30703/ethv4/16Uiu2HAm1sVyXmkMNjdeDWqK2urbyC3oBHi8MDpCdYkns1nYafqz",
},
},
{
NetworkID: RopstenNetworkID,
BootNodes: []string{
"enode://10a78c17929a7019ef4aa2249d7302f76ae8a06f40b2dc88b7b31ebff4a623fbb44b4a627acba296c1ced3775d91fbe18463c15097a6a36fdb2c804ff3fc5b35@35.238.97.234:30404", // boot-01.gc-us-central1-a.eth.staging
"enode://f79fb3919f72ca560ad0434dcc387abfe41e0666201ebdada8ede0462454a13deb05cda15f287d2c4bd85da81f0eb25d0a486bbbc8df427b971ac51533bd00fe@174.138.107.239:30404", // boot-01.do-ams3.eth.staging
},
RendezvousNodes: []string{
"/ip4/174.138.107.239/tcp/30703/ethv4/16Uiu2HAkyJHeetQ4DNpd4NZ2ntzxMo25zcdpvGQRqkD5pB9BE6RU",
"/ip4/35.238.97.234/tcp/30703/ethv4/16Uiu2HAm1sVyXmkMNjdeDWqK2urbyC3oBHi8MDpCdYkns1nYafqz",
},
}, },
} }
// ClusterForFleet returns a cluster for a given fleet. // ClusterForFleet returns a cluster for a given fleet.
func ClusterForFleet(fleet string) ([]Cluster, error) { func ClusterForFleet(fleet string) (Cluster, bool) {
switch fleet { cluster, ok := clusters[fleet]
case FleetStaging: if ok {
return stagingCluster, nil return cluster(), true
case FleetBeta:
return betaCluster, nil
default:
return nil, errors.New("fleet could not be found")
}
}
// ClusterForNetwork selects a cluster for a given network ID.
func ClusterForNetwork(clusters []Cluster, networkID int) (Cluster, bool) {
for _, c := range clusters {
if c.NetworkID == networkID {
return c, true
}
} }
return Cluster{}, false return Cluster{}, false
} }

View File

@ -385,7 +385,7 @@ func NewNodeConfig(dataDir, clstrCfgFile, fleet string, networkID uint64) (*Node
LogToStderr: LogToStderr, LogToStderr: LogToStderr,
ClusterConfigFile: clstrCfgFile, ClusterConfigFile: clstrCfgFile,
ClusterConfig: &ClusterConfig{ ClusterConfig: &ClusterConfig{
Enabled: fleet != FleetUndefined, Enabled: true, // cluster must be enabled by default
Fleet: fleet, Fleet: fleet,
StaticNodes: []string{}, StaticNodes: []string{},
BootNodes: []string{}, BootNodes: []string{},
@ -431,7 +431,7 @@ func LoadNodeConfig(configJSON string) (*NodeConfig, error) {
} }
func loadNodeConfig(configJSON string) (*NodeConfig, error) { func loadNodeConfig(configJSON string) (*NodeConfig, error) {
nodeConfig, err := NewNodeConfig("", "", FleetBeta, 0) nodeConfig, err := NewNodeConfig("", "", FleetUndefined, 0)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -616,10 +616,7 @@ func (c *NodeConfig) updateClusterConfig() error {
c.log.Info("update cluster config", "configFile", c.ClusterConfigFile, "fleet", c.ClusterConfig.Fleet) c.log.Info("update cluster config", "configFile", c.ClusterConfigFile, "fleet", c.ClusterConfig.Fleet)
var ( var cluster Cluster
clusters []Cluster
err error
)
if c.ClusterConfigFile != "" { if c.ClusterConfigFile != "" {
// Load cluster configuration from external file. // Load cluster configuration from external file.
@ -627,42 +624,34 @@ func (c *NodeConfig) updateClusterConfig() error {
if err != nil { if err != nil {
return fmt.Errorf("cluster configuration file '%s' could not be loaded: %s", c.ClusterConfigFile, err) return fmt.Errorf("cluster configuration file '%s' could not be loaded: %s", c.ClusterConfigFile, err)
} }
err = json.Unmarshal(configFile, &clusters) err = json.Unmarshal(configFile, &cluster)
if err != nil { if err != nil {
return fmt.Errorf("failed to unmarshal cluster configuration file: %s", err) return fmt.Errorf("failed to unmarshal cluster configuration file: %s", err)
} }
} else { } else {
clusters, err = ClusterForFleet(c.ClusterConfig.Fleet) cluster, _ = ClusterForFleet(c.ClusterConfig.Fleet)
if err != nil {
return fmt.Errorf("getting fleet '%s' failed: %v", c.ClusterConfig.Fleet, err)
}
} }
for _, cluster := range clusters { // allow to override bootnodes only if they were not defined earlier
if cluster.NetworkID == int(c.NetworkID) { if len(c.ClusterConfig.BootNodes) == 0 {
// allow to override bootnodes only if they were not defined earlier c.ClusterConfig.BootNodes = cluster.BootNodes
if len(c.ClusterConfig.BootNodes) == 0 {
c.ClusterConfig.BootNodes = cluster.BootNodes
}
// allow to override static nodes only if they were not defined earlier
if len(c.ClusterConfig.StaticNodes) == 0 {
c.ClusterConfig.StaticNodes = cluster.StaticNodes
}
// no point in running discovery if we don't have bootnodes.
// but in case if we do have nodes and NoDiscovery=true we will preserve that value
if len(cluster.BootNodes) == 0 {
c.NoDiscovery = true
}
if len(c.ClusterConfig.RendezvousNodes) == 0 {
c.ClusterConfig.RendezvousNodes = cluster.RendezvousNodes
}
if len(c.ClusterConfig.RendezvousNodes) != 0 {
c.Rendezvous = true
}
c.ClusterConfig.TrustedMailServers = cluster.MailServers
break
}
} }
// allow to override static nodes only if they were not defined earlier
if len(c.ClusterConfig.StaticNodes) == 0 {
c.ClusterConfig.StaticNodes = cluster.StaticNodes
}
// No point in running discovery if we don't have bootnodes.
// In a case when we do have bootnodes, NoDiscovery=true is preserved.
if len(cluster.BootNodes) == 0 {
c.NoDiscovery = true
}
if len(c.ClusterConfig.RendezvousNodes) == 0 {
c.ClusterConfig.RendezvousNodes = cluster.RendezvousNodes
}
if len(c.ClusterConfig.RendezvousNodes) != 0 {
c.Rendezvous = true
}
c.ClusterConfig.TrustedMailServers = cluster.MailServers
return nil return nil
} }

View File

@ -6,8 +6,6 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strconv"
"strings"
"testing" "testing"
"gopkg.in/go-playground/validator.v9" "gopkg.in/go-playground/validator.v9"
@ -18,417 +16,227 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
var clusterConfigData = []byte(` var clusterConfigData = []byte(`{
[ "staticnodes": [
{ "enode://7ab298cedc4185a894d21d8a4615262ec6bdce66c9b6783878258e0d5b31013d30c9038932432f70e5b2b6a5cd323bf820554fcb22fbc7b45367889522e9c449@10.1.1.1:30303",
"networkID": 3, "enode://f59e8701f18c79c5cbc7618dc7bb928d44dc2f5405c7d693dad97da2d8585975942ec6fd36d3fe608bfdc7270a34a4dd00f38cfe96b2baa24f7cd0ac28d382a1@10.1.1.2:30303"
"staticnodes": [ ]
"enode://7ab298cedc4185a894d21d8a4615262ec6bdce66c9b6783878258e0d5b31013d30c9038932432f70e5b2b6a5cd323bf820554fcb22fbc7b45367889522e9c449@10.1.1.1:30303", }`)
"enode://f59e8701f18c79c5cbc7618dc7bb928d44dc2f5405c7d693dad97da2d8585975942ec6fd36d3fe608bfdc7270a34a4dd00f38cfe96b2baa24f7cd0ac28d382a1@10.1.1.2:30303"
]
}
]
`)
var loadConfigTestCases = []struct { func TestLoadNodeConfigFromNonExistingFile(t *testing.T) {
name string _, err := params.LoadNodeConfig(`{
configJSON string "NetworkId": 3,
validator func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) "DataDir": "/tmp/statusgo",
}{ "ClusterConfigFile": "/file/does/not.exist"
{ }`)
`invalid input JSON (missing comma at the end of key:value pair)`, require.Error(t, err)
`{ require.Contains(t, err.Error(), "no such file or directory")
"NetworkId": 3
"DataDir": "$TMPDIR"
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.Error(t, err, "error is expected, not thrown")
},
},
{
`check static DataDir passing`,
`{
"NetworkId": 3,
"DataDir": "/storage/emulated/0/ethereum/"
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
require.Equal(t, "/storage/emulated/0/ethereum/", nodeConfig.DataDir)
},
},
{
`use default KeyStoreDir`,
`{
"NetworkId": 3,
"DataDir": "$TMPDIR"
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
_, err = os.Stat(dataDir)
require.False(t, os.IsNotExist(err), "data directory doesn't exist")
require.Equal(t, dataDir, nodeConfig.DataDir)
require.Equal(t, filepath.Join(dataDir, params.KeyStoreDir), filepath.Join(dataDir, params.KeyStoreDir))
},
},
{
`use non-default KeyStoreDir`,
`{
"NetworkId": 3,
"DataDir": "$TMPDIR",
"KeyStoreDir": "/foo/bar"
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
require.Equal(t, dataDir, nodeConfig.DataDir)
require.Equal(t, "/foo/bar", nodeConfig.KeyStoreDir)
},
},
{
`test Upstream config setting`,
`{
"NetworkId": 3,
"DataDir": "$TMPDIR",
"Name": "TestStatusNode",
"WSPort": 4242,
"IPCEnabled": true,
"WSEnabled": false,
"UpstreamConfig": {
"Enabled": true,
"URL": "http://upstream.loco.net/nodes"
}
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if nodeConfig.NetworkID != 3 {
t.Fatal("wrong NetworkId")
}
if !nodeConfig.UpstreamConfig.Enabled {
t.Fatal("wrong UpstreamConfig.Enabled state")
}
if nodeConfig.UpstreamConfig.URL != "http://upstream.loco.net/nodes" {
t.Fatal("wrong UpstreamConfig.URL value")
}
},
},
{
`test parameter overriding`,
`{
"NetworkId": 3,
"DataDir": "$TMPDIR",
"Name": "TestStatusNode",
"WSPort": 4242,
"IPCEnabled": true,
"WSEnabled": false,
"RPCEnabled": true,
"LightEthConfig": {
"DatabaseCache": 64
}
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
require.EqualValues(t, 3, nodeConfig.NetworkID)
require.Equal(t, "TestStatusNode", nodeConfig.Name)
require.Equal(t, params.HTTPPort, nodeConfig.HTTPPort)
require.Equal(t, params.HTTPHost, nodeConfig.HTTPHost)
require.True(t, nodeConfig.RPCEnabled)
require.True(t, nodeConfig.IPCEnabled)
require.Equal(t, 64, nodeConfig.LightEthConfig.DatabaseCache)
},
},
{
`test loading Testnet config`,
`{
"NetworkId": 3,
"DataDir": "$TMPDIR",
"Name": "TestStatusNode",
"WSPort": 8546,
"IPCEnabled": true,
"WSEnabled": false,
"LightEthConfig": {
"DatabaseCache": 64
}
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
genesis := new(core.Genesis)
err = json.Unmarshal([]byte(nodeConfig.LightEthConfig.Genesis), genesis)
require.NoError(t, err)
chainConfig := genesis.Config
refChainConfig := gethparams.TestnetChainConfig
require.Empty(t, chainConfig.HomesteadBlock.Cmp(refChainConfig.HomesteadBlock), "invalid chainConfig.HomesteadBlock")
require.Nil(t, chainConfig.DAOForkBlock)
require.Equal(t, refChainConfig.DAOForkSupport, chainConfig.DAOForkSupport)
require.Empty(t, chainConfig.EIP150Block.Cmp(refChainConfig.EIP150Block))
require.Equal(t, refChainConfig.EIP150Hash, chainConfig.EIP150Hash)
require.Empty(t, chainConfig.EIP155Block.Cmp(refChainConfig.EIP155Block))
require.Empty(t, chainConfig.EIP158Block.Cmp(refChainConfig.EIP158Block))
require.Empty(t, chainConfig.ChainID.Cmp(refChainConfig.ChainID))
},
},
{
`test loading Mainnet config`,
`{
"NetworkId": 1,
"DataDir": "$TMPDIR",
"Name": "TestStatusNode",
"WSPort": 8546,
"IPCEnabled": true,
"WSEnabled": false,
"LightEthConfig": {
"DatabaseCache": 64
}
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
genesis := new(core.Genesis)
err = json.Unmarshal([]byte(nodeConfig.LightEthConfig.Genesis), genesis)
require.NoError(t, err)
chainConfig := genesis.Config
require.Empty(t, chainConfig.HomesteadBlock.Cmp(gethparams.MainnetChainConfig.HomesteadBlock))
require.Empty(t, chainConfig.DAOForkBlock.Cmp(gethparams.MainnetChainConfig.DAOForkBlock))
require.True(t, chainConfig.DAOForkSupport)
require.Empty(t, chainConfig.EIP150Block.Cmp(gethparams.MainnetChainConfig.EIP150Block))
require.Equal(t, gethparams.MainnetChainConfig.EIP150Hash, chainConfig.EIP150Hash)
require.Empty(t, chainConfig.EIP155Block.Cmp(gethparams.MainnetChainConfig.EIP155Block))
require.Empty(t, chainConfig.EIP158Block.Cmp(gethparams.MainnetChainConfig.EIP158Block))
require.Empty(t, chainConfig.ChainID.Cmp(gethparams.MainnetChainConfig.ChainID))
},
},
{
`test loading Privatenet config`,
`{
"NetworkId": 311,
"DataDir": "$TMPDIR",
"Name": "TestStatusNode",
"WSPort": 8546,
"IPCEnabled": true,
"WSEnabled": false
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
require.EqualValues(t, 311, nodeConfig.NetworkID)
},
},
{
`default static nodes (Ropsten Dev)`,
`{
"NetworkId": 3,
"DataDir": "$TMPDIR"
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
require.True(t, nodeConfig.ClusterConfig.Enabled, "static nodes are expected to be enabled by default")
enodes := nodeConfig.ClusterConfig.StaticNodes
t.Logf("LEN SN %d", len(enodes))
require.Len(t, enodes, 2)
},
},
{
`custom boot nodes`,
`{
"NetworkId": 3,
"DataDir": "$TMPDIR",
"ClusterConfig": {
"BootNodes": ["a", "b", "c"]
}
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
enodes := nodeConfig.ClusterConfig.BootNodes
expectedEnodes := []string{"a", "b", "c"}
require.Equal(t, enodes, expectedEnodes)
},
},
{
`illegal cluster configuration file`,
`{
"NetworkId": 3,
"DataDir": "$TMPDIR",
"ClusterConfigFile": "/file/does/not.exist"
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.Error(t, err, "error is expected, not thrown")
},
},
{
`valid cluster configuration file`,
`{
"NetworkId": 3,
"DataDir": "$TMPDIR",
"ClusterConfigFile": "$TMPDIR/cluster.json"
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
require.True(t, nodeConfig.ClusterConfig.Enabled, "cluster configuration is expected to be enabled after loading file")
enodes := nodeConfig.ClusterConfig.StaticNodes
require.Len(t, enodes, 2)
},
},
{
`default cluster configuration (Ropsten Prod)`,
`{
"NetworkId": 3,
"DataDir": "$TMPDIR"
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
require.True(t, nodeConfig.ClusterConfig.Enabled, "cluster configuration is expected to be enabled by default")
enodes := nodeConfig.ClusterConfig.StaticNodes
require.Len(t, enodes, 2)
},
},
{
`disabled cluster configuration`,
`{
"NetworkId": 311,
"DataDir": "$TMPDIR",
"ClusterConfig": {
"Enabled": false
}
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
require.False(t, nodeConfig.ClusterConfig.Enabled, "cluster configuration is expected to be disabled")
},
},
{
`select cluster configuration (Rinkeby Dev)`,
`{
"NetworkId": 4,
"DataDir": "$TMPDIR"
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
require.True(t, nodeConfig.ClusterConfig.Enabled, "cluster configuration is expected to be enabled by default")
require.False(t, nodeConfig.NoDiscovery)
require.True(t, len(nodeConfig.ClusterConfig.BootNodes) >= 2)
},
},
{
`select cluster configuration (Mainnet dev)`,
`{
"NetworkId": 1,
"DataDir": "$TMPDIR"
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
require.True(t, nodeConfig.ClusterConfig.Enabled, "cluster configuration is expected to be enabled by default")
enodes := nodeConfig.ClusterConfig.StaticNodes
require.True(t, len(enodes) >= 2)
},
},
{
`explicit WhisperConfig.LightClient = true`,
`{
"NetworkId": 3,
"DataDir": "$TMPDIR",
"WhisperConfig": {
"LightClient": true
}
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
require.True(t, nodeConfig.WhisperConfig.LightClient)
},
},
{
`default peer limits`,
`{
"NetworkId": 4,
"DataDir": "$TMPDIR"
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
require.NotNil(t, nodeConfig.RequireTopics)
require.False(t, nodeConfig.NoDiscovery)
require.Contains(t, nodeConfig.RequireTopics, params.WhisperDiscv5Topic)
require.Equal(t, params.WhisperDiscv5Limits, nodeConfig.RequireTopics[params.WhisperDiscv5Topic])
},
},
{
`no discovery preserved`,
`{
"NetworkId": 4,
"DataDir": "$TMPDIR",
"NoDiscovery": true
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
require.True(t, nodeConfig.NoDiscovery)
},
},
{
`eth.staging fleet`,
`{
"NetworkId": ` + strconv.Itoa(params.RopstenNetworkID) + `,
"DataDir": "$TMPDIR",
"NoDiscovery": true,
"ClusterConfig": {
"Fleet": "eth.staging"
}
}`,
func(t *testing.T, _ string, nodeConfig *params.NodeConfig, loadConfErr error) {
stagingClusters, err := params.ClusterForFleet("eth.staging")
require.NoError(t, err)
staging, ok := params.ClusterForNetwork(stagingClusters, params.RopstenNetworkID)
require.True(t, ok)
betaClusters, err := params.ClusterForFleet("eth.beta")
require.NoError(t, err)
beta, ok := params.ClusterForNetwork(betaClusters, params.RopstenNetworkID)
require.True(t, ok)
require.NotEqual(t, staging, beta)
// assert
require.NoError(t, loadConfErr)
require.Equal(t, "eth.staging", nodeConfig.ClusterConfig.Fleet)
require.Equal(t, staging.BootNodes, nodeConfig.ClusterConfig.BootNodes)
},
},
} }
// TestLoadNodeConfig tests loading JSON configuration and setting default values. func TestLoadNodeConfigFromFile(t *testing.T) {
func TestLoadNodeConfig(t *testing.T) {
tmpDir, err := ioutil.TempDir(os.TempDir(), "geth-config-tests") tmpDir, err := ioutil.TempDir(os.TempDir(), "geth-config-tests")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
defer os.RemoveAll(tmpDir) // nolint: errcheck defer os.RemoveAll(tmpDir) // nolint: errcheck
// create sample bootnodes config // create cluster config file
err = ioutil.WriteFile(filepath.Join(tmpDir, "cluster.json"), clusterConfigData, os.ModePerm) clusterFile := filepath.Join(tmpDir, "cluster.json")
err = ioutil.WriteFile(clusterFile, clusterConfigData, os.ModePerm)
require.NoError(t, err) require.NoError(t, err)
t.Log(tmpDir)
for _, testCase := range loadConfigTestCases { c, err := params.LoadNodeConfig(`{
t.Run(testCase.name, func(t *testing.T) { "NetworkId": 3,
testCase.configJSON = strings.Replace(testCase.configJSON, "$TMPDIR", tmpDir, -1) "DataDir": "` + tmpDir + `",
nodeConfig, err := params.LoadNodeConfig(testCase.configJSON) "ClusterConfigFile": "` + clusterFile + `"
testCase.validator(t, tmpDir, nodeConfig, err) }`)
}) require.NoError(t, err)
require.True(t, c.ClusterConfig.Enabled)
require.Len(t, c.ClusterConfig.StaticNodes, 2)
}
// TestGenerateAndLoadNodeConfig tests creating and loading config
// exactly as it's done by status-react.
func TestGenerateAndLoadNodeConfig(t *testing.T) {
tmpDir, err := ioutil.TempDir(os.TempDir(), "geth-config-tests")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmpDir) // nolint: errcheck
var testCases = []struct {
Name string
Fleet string // optional; if omitted all fleets will be tested
NetworkID int // optional; if omitted all networks will be checked
Update func(*params.NodeConfig)
Validate func(t *testing.T, dataDir string, c *params.NodeConfig)
}{
{
Name: "default KeyStoreDir",
Update: func(config *params.NodeConfig) {},
Validate: func(t *testing.T, dataDir string, c *params.NodeConfig) {
require.Equal(t, dataDir, c.DataDir)
keyStoreDir := filepath.Join(dataDir, params.KeyStoreDir)
require.Equal(t, keyStoreDir, c.KeyStoreDir)
},
},
{
Name: "non-default KeyStoreDir",
Update: func(c *params.NodeConfig) {
c.KeyStoreDir = "/foo/bar"
},
Validate: func(t *testing.T, dataDir string, c *params.NodeConfig) {
require.Equal(t, "/foo/bar", c.KeyStoreDir)
},
},
{
Name: "custom network and upstream",
NetworkID: 333,
Update: func(c *params.NodeConfig) {
c.UpstreamConfig.Enabled = true
c.UpstreamConfig.URL = "http://custom.local"
},
Validate: func(t *testing.T, dataDir string, c *params.NodeConfig) {
require.Equal(t, uint64(333), c.NetworkID)
require.True(t, c.UpstreamConfig.Enabled)
require.Equal(t, "http://custom.local", c.UpstreamConfig.URL)
},
},
{
Name: "upstream config",
NetworkID: params.RopstenNetworkID,
Update: func(c *params.NodeConfig) {
c.UpstreamConfig.Enabled = true
c.UpstreamConfig.URL = params.RopstenEthereumNetworkURL
},
Validate: func(t *testing.T, dataDir string, c *params.NodeConfig) {
require.True(t, c.UpstreamConfig.Enabled)
require.Equal(t, params.RopstenEthereumNetworkURL, c.UpstreamConfig.URL)
},
},
{
Name: "loading LES config",
NetworkID: params.MainNetworkID,
Update: func(c *params.NodeConfig) {},
Validate: func(t *testing.T, dataDir string, c *params.NodeConfig) {
var genesis core.Genesis
err := json.Unmarshal([]byte(c.LightEthConfig.Genesis), &genesis)
require.NoError(t, err)
require.Zero(t, genesis.Config.ChainID.Cmp(gethparams.MainnetChainConfig.ChainID))
require.Zero(t, genesis.Config.HomesteadBlock.Cmp(gethparams.MainnetChainConfig.HomesteadBlock))
require.Zero(t, genesis.Config.EIP150Block.Cmp(gethparams.MainnetChainConfig.EIP150Block))
require.Zero(t, genesis.Config.EIP155Block.Cmp(gethparams.MainnetChainConfig.EIP155Block))
require.Zero(t, genesis.Config.EIP158Block.Cmp(gethparams.MainnetChainConfig.EIP158Block))
},
},
{
Name: "cluster nodes setup",
Update: func(c *params.NodeConfig) {},
Validate: func(t *testing.T, dataDir string, c *params.NodeConfig) {
require.True(t, c.ClusterConfig.Enabled)
require.NotEmpty(t, c.ClusterConfig.BootNodes)
require.NotEmpty(t, c.ClusterConfig.StaticNodes)
require.NotEmpty(t, c.ClusterConfig.TrustedMailServers)
},
},
{
Name: "custom bootnodes",
Update: func(c *params.NodeConfig) {
c.ClusterConfig.BootNodes = []string{"a", "b", "c"}
},
Validate: func(t *testing.T, dataDir string, c *params.NodeConfig) {
require.True(t, c.ClusterConfig.Enabled)
require.Equal(t, []string{"a", "b", "c"}, c.ClusterConfig.BootNodes)
},
},
{
Name: "disabled ClusterConfiguration",
Update: func(c *params.NodeConfig) {
c.ClusterConfig.Enabled = false
},
Validate: func(t *testing.T, dataDir string, c *params.NodeConfig) {
require.False(t, c.ClusterConfig.Enabled)
},
},
{
Name: "peers discovery and topics",
Update: func(c *params.NodeConfig) {},
Validate: func(t *testing.T, dataDir string, c *params.NodeConfig) {
require.NotNil(t, c.RequireTopics)
require.False(t, c.NoDiscovery)
require.Contains(t, c.RequireTopics, params.WhisperDiscv5Topic)
require.Equal(t, params.WhisperDiscv5Limits, c.RequireTopics[params.WhisperDiscv5Topic])
},
},
{
Name: "verify NoDiscovery preserved",
Update: func(c *params.NodeConfig) {
c.NoDiscovery = true
},
Validate: func(t *testing.T, dataDir string, c *params.NodeConfig) {
require.True(t, c.NoDiscovery)
},
},
{
Name: "staging fleet",
Fleet: params.FleetStaging,
Update: func(c *params.NodeConfig) {},
Validate: func(t *testing.T, dataDir string, c *params.NodeConfig) {
staging, ok := params.ClusterForFleet("eth.staging")
require.True(t, ok)
beta, ok := params.ClusterForFleet("eth.beta")
require.True(t, ok)
require.NotEqual(t, staging, beta)
// test case asserts
require.Equal(t, "eth.staging", c.ClusterConfig.Fleet)
require.Equal(t, staging.BootNodes, c.ClusterConfig.BootNodes)
},
},
{
Name: "Whisper light client",
Update: func(c *params.NodeConfig) {
c.WhisperConfig.LightClient = true
},
Validate: func(t *testing.T, dataDir string, c *params.NodeConfig) {
require.True(t, c.WhisperConfig.LightClient)
},
},
}
for _, tc := range testCases {
fleets := []string{params.FleetBeta, params.FleetStaging}
if tc.Fleet != params.FleetUndefined {
fleets = []string{tc.Fleet}
}
networks := []int{params.MainNetworkID, params.RinkebyNetworkID, params.RopstenNetworkID}
if tc.NetworkID != 0 {
networks = []int{tc.NetworkID}
}
for _, fleet := range fleets {
for _, networkID := range networks {
name := fmt.Sprintf("%s_%s_%d", tc.Name, fleet, networkID)
t.Run(name, func(t *testing.T) {
// Corresponds to GenerateConfig() binding.
config, err := params.NewNodeConfig(tmpDir, "", fleet, uint64(networkID))
require.NoError(t, err)
// Corresponds to config update in status-react.
tc.Update(config)
configBytes, err := json.Marshal(config)
require.NoError(t, err)
// Corresponds to starting node and loading config from JSON blob.
loadedConfig, err := params.LoadNodeConfig(string(configBytes))
require.NoError(t, err)
tc.Validate(t, tmpDir, loadedConfig)
})
}
}
} }
} }

View File

@ -143,7 +143,7 @@ func (s *DebugAPISuite) addPeerToCurrentNode(dir string) {
// newNode creates, configures and starts a new peer. // newNode creates, configures and starts a new peer.
func (s *DebugAPISuite) newPeer(name, dir string) *node.StatusNode { func (s *DebugAPISuite) newPeer(name, dir string) *node.StatusNode {
// network id is irrelevant // network id is irrelevant
cfg, err := MakeTestNodeConfigWithDataDir(name, dir, 777) cfg, err := MakeTestNodeConfigWithDataDir(name, dir, params.FleetUndefined, 777)
s.Require().NoError(err) s.Require().NoError(err)
n := node.New() n := node.New()
s.Require().NoError(n.Start(cfg)) s.Require().NoError(n.Start(cfg))

View File

@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6" whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/node" "github.com/status-im/status-go/node"
"github.com/status-im/status-go/params"
"github.com/status-im/status-go/signal" "github.com/status-im/status-go/signal"
"github.com/status-im/status-go/t/utils" "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
@ -32,7 +33,7 @@ func (s *WhisperExtensionSuite) SetupTest() {
dir, err := ioutil.TempDir("", "test-shhext-") dir, err := ioutil.TempDir("", "test-shhext-")
s.NoError(err) s.NoError(err)
// network id is irrelevant // network id is irrelevant
cfg, err := utils.MakeTestNodeConfigWithDataDir(fmt.Sprintf("test-shhext-%d", i), dir, 777) cfg, err := utils.MakeTestNodeConfigWithDataDir(fmt.Sprintf("test-shhext-%d", i), dir, params.FleetUndefined, 777)
s.Require().NoError(err) s.Require().NoError(err)
s.nodes[i] = node.New() s.nodes[i] = node.New()
s.Require().NoError(s.nodes[i].Start(cfg)) s.Require().NoError(s.nodes[i].Start(cfg))

View File

@ -263,8 +263,8 @@ func MakeTestNodeConfig(networkID int) (*params.NodeConfig, error) {
// MakeTestNodeConfigWithDataDir defines a function to return a params.NodeConfig // MakeTestNodeConfigWithDataDir defines a function to return a params.NodeConfig
// where specific network addresses are assigned based on provided network id, and assigns // where specific network addresses are assigned based on provided network id, and assigns
// a given name and data dir. // a given name and data dir.
func MakeTestNodeConfigWithDataDir(name, dataDir string, networkID uint64) (*params.NodeConfig, error) { func MakeTestNodeConfigWithDataDir(name, dataDir, fleet string, networkID uint64) (*params.NodeConfig, error) {
cfg, err := params.NewNodeConfig(dataDir, "", params.FleetBeta, networkID) cfg, err := params.NewNodeConfig(dataDir, "", fleet, networkID)
if err != nil { if err != nil {
return nil, err return nil, err
} }