Skip to content

Commit 6db57de

Browse files
committed
Fix bootstrap test, since our bootstrap node went away.
1 parent 248ef67 commit 6db57de

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

tox_test.go

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ import (
1818
// `go test -v -run Covers` will show untested functions
1919
// TODO boundary value testing
2020

21-
var bsnodes = []string{
22-
"tox.ngc.zone", "33445", "15E9C309CFCB79FDDF0EBA057DABB49FE15F3803B1BFF06536AE2E5BA5E4690E",
23-
"node.tox.biribiri.org", "33445", "F404ABAA1C99A9D37D61AB54898F56793E1DEF8BD46B1038B9D822E8460FAB67",
24-
"178.62.250.138", "33445", "788236D34978D1D5BD822F0A5BEBD2C53C64CC31CD3149350EE27D4D9A2F9B6B",
25-
"198.98.51.198", "33445", "1D5A5F2F5D6233058BF0259B09622FB40B482E4FA0931EB8FD3AB8E7BF7DAF6F",
21+
var bsnodes = []struct {
22+
host string
23+
port string
24+
key string
25+
}{
26+
{"node.tox.biribiri.org", "33445", "F404ABAA1C99A9D37D61AB54898F56793E1DEF8BD46B1038B9D822E8460FAB67"},
27+
{"178.62.250.138", "33445", "788236D34978D1D5BD822F0A5BEBD2C53C64CC31CD3149350EE27D4D9A2F9B6B"},
28+
{"198.98.51.198", "33445", "1D5A5F2F5D6233058BF0259B09622FB40B482E4FA0931EB8FD3AB8E7BF7DAF6F"},
2629
}
2730

2831
func init() {
@@ -210,30 +213,31 @@ func TestBase(t *testing.T) {
210213
}
211214

212215
func TestBootstrap(t *testing.T) {
216+
bsnode := bsnodes[0]
213217
_t := NewTox(nil)
214218
defer _t.Kill()
215-
port, _ := strconv.Atoi(bsnodes[1])
219+
port, _ := strconv.Atoi(bsnode.port)
216220

217221
t.Run("success", func(t *testing.T) {
218-
if ok, err := _t.Bootstrap(bsnodes[0], uint16(port), bsnodes[2]); !ok || err != nil {
222+
if ok, err := _t.Bootstrap(bsnode.host, uint16(port), bsnode.key); !ok || err != nil {
219223
t.Error("must ok", ok, err)
220224
}
221225
})
222226
t.Run("failed", func(t *testing.T) {
223-
brkey := bsnodes[2]
224-
brkey = "XYZAB" + bsnodes[2][3:]
225-
if ok, err := _t.Bootstrap(bsnodes[0], uint16(port), brkey); ok || err == nil {
227+
brkey := bsnode.key
228+
brkey = "XYZAB" + bsnode.key[3:]
229+
if ok, err := _t.Bootstrap(bsnode.host, uint16(port), brkey); ok || err == nil {
226230
t.Error("must failed", ok, err)
227231
}
228-
if ok, err := _t.Bootstrap("a.b.c.d", uint16(port), bsnodes[2]); ok || err == nil {
232+
if ok, err := _t.Bootstrap("a.b.c.d", uint16(port), bsnode.key); ok || err == nil {
229233
t.Error("must failed", ok, err)
230234
}
231235
})
232236
t.Run("relay", func(t *testing.T) {
233-
if ok, err := _t.AddTcpRelay(bsnodes[0], uint16(port), bsnodes[2]); !ok || err != nil {
237+
if ok, err := _t.AddTcpRelay(bsnode.host, uint16(port), bsnode.key); !ok || err != nil {
234238
t.Error("must ok", ok, err)
235239
}
236-
if ok, err := _t.AddTcpRelay("a.b.c.d", uint16(port), bsnodes[2]); ok || err == nil {
240+
if ok, err := _t.AddTcpRelay("a.b.c.d", uint16(port), bsnode.key); ok || err == nil {
237241
t.Error("must failed", ok, err)
238242
}
239243
})
@@ -267,11 +271,12 @@ func (minitox *MiniTox) Iterate() {
267271

268272
func (minitox *MiniTox) bootstrap() {
269273
for idx := 0; idx < len(bsnodes)/3; idx++ {
270-
port, err := strconv.Atoi(bsnodes[1+idx*3])
271-
_, err = minitox.t.Bootstrap(bsnodes[0+idx*3], uint16(port), bsnodes[2+idx*3])
274+
bsnode := bsnodes[idx]
275+
port, err := strconv.Atoi(bsnode.port)
276+
_, err = minitox.t.Bootstrap(bsnode.host, uint16(port), bsnode.key)
272277
if err != nil {
273278
}
274-
_, err = minitox.t.AddTcpRelay(bsnodes[0+idx*3], uint16(port), bsnodes[2+idx*3])
279+
_, err = minitox.t.AddTcpRelay(bsnode.host, uint16(port), bsnode.key)
275280
if err != nil {
276281
}
277282
}
@@ -1097,7 +1102,7 @@ func TestCovers(t *testing.T) {
10971102
// t.Log(v.fns)
10981103

10991104
notins := make(map[string]bool)
1100-
for mn, _ := range mths {
1105+
for mn := range mths {
11011106
if _, ok := v.fns[mn]; !ok {
11021107
t.Log("not tested:", mn)
11031108
notins[mn] = false

0 commit comments

Comments
 (0)