diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-27 09:34:32 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-27 09:34:32 +0900 |
commit | c66b596122b6c27546ed21c7604bd0d6a042fd6c (patch) | |
tree | 9f8f4f34fb4bbb69d2cb6e9e213df3ea35afcf4f /server/rpki_test.go | |
parent | ed5026413cfb87527541a7cf9f83118df311ca73 (diff) |
server: fix radix key bug in rpki test
also clean up functions to create a radix key.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/rpki_test.go')
-rw-r--r-- | server/rpki_test.go | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/server/rpki_test.go b/server/rpki_test.go index 4fd5de50..9dd135ec 100644 --- a/server/rpki_test.go +++ b/server/rpki_test.go @@ -23,37 +23,28 @@ import ( "testing" ) -func addROA(tree *radix.Tree, addr string, as uint32, prefixLen, maxLen uint8) { - a := net.ParseIP(addr) - b := a.To4() - if b == nil { - b = a.To16() - } - handleIPPrefix(tree, prefixToKey(net.ParseIP(addr), prefixLen), as, b, prefixLen, maxLen) -} - func TestValidate(t *testing.T) { assert := assert.New(t) tree := radix.New() - addROA(tree, "192.168.0.0", 100, 24, 32) - addROA(tree, "192.168.0.0", 200, 24, 24) + addROA(tree, 100, net.ParseIP("192.168.0.0"), 24, 32) + addROA(tree, 200, net.ParseIP("192.168.0.0"), 24, 24) - r1 := validateOne(tree, prefixToKey(net.ParseIP("192.168.0.0"), 24), 24, 100) + r1 := validateOne(tree, "192.168.0.0/24", 100) assert.Equal(r1, config.RPKI_VALIDATION_RESULT_TYPE_VALID) - r2 := validateOne(tree, prefixToKey(net.ParseIP("192.168.0.0"), 24), 24, 200) + r2 := validateOne(tree, "192.168.0.0/24", 200) assert.Equal(r2, config.RPKI_VALIDATION_RESULT_TYPE_VALID) - r3 := validateOne(tree, prefixToKey(net.ParseIP("192.168.0.0"), 24), 24, 300) + r3 := validateOne(tree, "192.168.0.0/24", 300) assert.Equal(r3, config.RPKI_VALIDATION_RESULT_TYPE_INVALID) - r4 := validateOne(tree, prefixToKey(net.ParseIP("192.168.0.0"), 25), 25, 100) + r4 := validateOne(tree, "192.168.0.0/25", 100) assert.Equal(r4, config.RPKI_VALIDATION_RESULT_TYPE_VALID) - r5 := validateOne(tree, prefixToKey(net.ParseIP("192.168.0.0"), 25), 25, 200) + r5 := validateOne(tree, "192.168.0.0/25", 200) assert.Equal(r5, config.RPKI_VALIDATION_RESULT_TYPE_INVALID) - r6 := validateOne(tree, prefixToKey(net.ParseIP("192.168.0.0"), 25), 25, 300) + r6 := validateOne(tree, "192.168.0.0/25", 300) assert.Equal(r6, config.RPKI_VALIDATION_RESULT_TYPE_INVALID) } |