MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / TestLoadConfig

Function TestLoadConfig

sqlchain/observer/config_test.go:28–301  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func 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
59WorkingRoot: "./"
60PubKeyStoreFile: "public.keystore"
61PrivateKeyFile: "private.key"
62DHTFileName: "dht.db"
63ListenAddr: "127.0.0.1:2122"
64ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
65ValidDNSKeys:
66 koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
67 mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
68MinNodeIDDifficulty: 2
69DNSSeed:
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
77BlockProducer:
78 PublicKey: "02c76216704d797c64c58bc11519fb68582e8e63de7e5b3b2dbbbe8733efe5fd24"
79 NodeID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
80 Nonce:
81 a: 313283
82 b: 0
83 c: 0
84 d: 0
85 ChainFileName: "chain.db"

Callers

nothing calls this directly

Calls 2

NameMethod · 0.80
loadConfigFunction · 0.70

Tested by

no test coverage detected