MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestGenTestNetDomain

Function TestGenTestNetDomain

route/ipv6seed_test.go:107–177  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

105}
106
107func TestGenTestNetDomain(t *testing.T) {
108 isc := IPv6SeedClient{}
109 Convey("generate testnet domain", t, func() {
110 log.SetLevel(log.DebugLevel)
111 var (
112 baseDir = utils.GetProjectSrcDir()
113 testnetConf = utils.FJ(baseDir, "./conf/testnet/testnet-bp.yaml")
114 )
115
116 conf, err := conf.LoadConfig(testnetConf)
117 So(err, ShouldBeNil)
118 var i int
119 for _, node := range conf.KnownNodes {
120 if node.Role == proto.Leader || node.Role == proto.Follower {
121 if node.Addr[:4] != fmt.Sprintf("bp%02d", i) {
122 t.Errorf("BP order in yaml should follow 00,01...")
123 }
124 bpDomain := fmt.Sprintf("bp%02d.testnet.gridb.io", i)
125 i++
126 out, err := isc.GenBPIPv6(&node, bpDomain)
127 if err != nil {
128 t.Errorf("gen ipv6 failed: %v", err)
129 return
130 }
131 fmt.Print(out)
132
133 m, err := isc.GetBPFromDNSSeed(bpDomain)
134 So(err, ShouldBeNil)
135 So(len(m), ShouldEqual, 1)
136 So(m[*node.ID.ToRawNodeID()].ID, ShouldResemble, node.ID)
137 So(m[*node.ID.ToRawNodeID()].Addr, ShouldResemble, node.Addr)
138 So(m[*node.ID.ToRawNodeID()].PublicKey.Serialize(), ShouldResemble, node.PublicKey.Serialize())
139 So(m[*node.ID.ToRawNodeID()].Nonce, ShouldResemble, node.Nonce)
140 }
141 }
142 })
143 Convey("generate testnet w domain", t, func() {
144 log.SetLevel(log.DebugLevel)
145 var (
146 baseDir = utils.GetProjectSrcDir()
147 testnetConf = utils.FJ(baseDir, "./conf/testnet/w/testnet-w-bp.yaml")
148 )
149
150 conf, err := conf.LoadConfig(testnetConf)
151 So(err, ShouldBeNil)
152 var i int
153 for _, node := range conf.KnownNodes {
154 if node.Role == proto.Leader || node.Role == proto.Follower {
155 if node.Addr[:4] != fmt.Sprintf("bp%02d", i) {
156 t.Errorf("BP order in yaml should follow 00,01...")
157 }
158 bpDomain := fmt.Sprintf("bp%02d.testnetw.gridb.io", i)
159 i++
160 out, err := isc.GenBPIPv6(&node, bpDomain)
161 if err != nil {
162 t.Errorf("gen ipv6 failed: %v", err)
163 return
164 }

Callers

nothing calls this directly

Calls 9

GenBPIPv6Method · 0.95
GetBPFromDNSSeedMethod · 0.95
SetLevelFunction · 0.92
GetProjectSrcDirFunction · 0.92
LoadConfigFunction · 0.92
ErrorfMethod · 0.80
PrintMethod · 0.80
ToRawNodeIDMethod · 0.80
SerializeMethod · 0.45

Tested by

no test coverage detected