(t *testing.T)
| 26 | ) |
| 27 | |
| 28 | func TestLoadConfig(t *testing.T) { |
| 29 | // Create |
| 30 | Convey("Given a working directory", t, func() { |
| 31 | var ( |
| 32 | tmp, fl string |
| 33 | err error |
| 34 | cfg *Config |
| 35 | ) |
| 36 | tmp, err = ioutil.TempDir("", "covenantsql") |
| 37 | So(err, ShouldBeNil) |
| 38 | Reset(func() { |
| 39 | err = os.RemoveAll(tmp) |
| 40 | So(err, ShouldBeNil) |
| 41 | }) |
| 42 | fl = path.Join(tmp, t.Name()) |
| 43 | Convey("The LoadConfig func should report error at a nonexist file", func() { |
| 44 | cfg, err = loadConfig(fl) |
| 45 | So(err, ShouldNotBeNil) |
| 46 | }) |
| 47 | Convey("Given a empty config file", func() { |
| 48 | err = ioutil.WriteFile(fl, nil, 0644) |
| 49 | So(err, ShouldBeNil) |
| 50 | Convey("The LoadConfig func should return a nil config", func() { |
| 51 | cfg, err = loadConfig(fl) |
| 52 | So(err, ShouldBeNil) |
| 53 | So(cfg, ShouldBeNil) |
| 54 | }) |
| 55 | }) |
| 56 | Convey("Given a config file without observer section", func() { |
| 57 | err = ioutil.WriteFile(fl, []byte( |
| 58 | `UseTestMasterKey: true |
| 59 | WorkingRoot: "./" |
| 60 | PubKeyStoreFile: "public.keystore" |
| 61 | PrivateKeyFile: "private.key" |
| 62 | DHTFileName: "dht.db" |
| 63 | ListenAddr: "127.0.0.1:2122" |
| 64 | ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9" |
| 65 | ValidDNSKeys: |
| 66 | koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com |
| 67 | mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com |
| 68 | MinNodeIDDifficulty: 2 |
| 69 | DNSSeed: |
| 70 | EnforcedDNSSEC: false |
| 71 | DNSServers: |
| 72 | - 1.1.1.1 |
| 73 | - 202.46.34.74 |
| 74 | - 202.46.34.75 |
| 75 | - 202.46.34.76 |
| 76 | |
| 77 | BlockProducer: |
| 78 | PublicKey: "02c76216704d797c64c58bc11519fb68582e8e63de7e5b3b2dbbbe8733efe5fd24" |
| 79 | NodeID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9 |
| 80 | Nonce: |
| 81 | a: 313283 |
| 82 | b: 0 |
| 83 | c: 0 |
| 84 | d: 0 |
| 85 | ChainFileName: "chain.db" |
nothing calls this directly
no test coverage detected