Filter out empty addresses in persistent_peers/seeds lists (#2323)

Fixes #2320
This commit is contained in:
JamesRay
2018-09-05 14:13:25 +08:00
committed by Anton Kaliaev
parent d27cd972d2
commit d0bb1ab2b0
4 changed files with 48 additions and 24 deletions

View File

@ -56,3 +56,22 @@ func TestNodeStartStop(t *testing.T) {
t.Fatal("timed out waiting for shutdown")
}
}
func TestSplitAndTrimEmpty(t *testing.T) {
testCases := []struct {
s string
sep string
cutset string
expected []string
}{
{"a,b,c", ",", " ", []string{"a", "b", "c"}},
{" a , b , c ", ",", " ", []string{"a", "b", "c"}},
{" a, b, c ", ",", " ", []string{"a", "b", "c"}},
{" a, ", ",", " ", []string{"a"}},
{" ", ",", " ", []string{}},
}
for _, tc := range testCases {
assert.Equal(t, tc.expected, splitAndTrimEmpty(tc.s, tc.sep, tc.cutset), "%s", tc.s)
}
}