channeldb/addr_test: add tests for invalid onion addresses

This commit is contained in:
Johan T. Halseth 2019-01-17 14:11:56 +01:00
parent 6a3e1423d2
commit 8af2473644
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -84,6 +84,30 @@ var addrTests = []struct {
},
serErr: "unable to encode",
},
{
expAddr: &tor.OnionAddr{
// Invalid suffix.
OnionService: "vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd.inion",
Port: 80,
},
serErr: "invalid suffix",
},
{
expAddr: &tor.OnionAddr{
// Invalid length.
OnionService: "vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyy.onion",
Port: 80,
},
serErr: "unknown onion service length",
},
{
expAddr: &tor.OnionAddr{
// Invalid encoding.
OnionService: "vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyA.onion",
Port: 80,
},
serErr: "illegal base32",
},
}
// TestAddrSerialization tests that the serialization method used by channeldb