]> Sergey Matveev's repositories - btrtrc.git/commitdiff
metainfo: Check for error unmarshalling bad nodes contents from a metainfo
authorMatt Joiner <anacrolix@gmail.com>
Tue, 23 Feb 2016 12:53:39 +0000 (23:53 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 23 Feb 2016 12:53:39 +0000 (23:53 +1100)
metainfo/nodes_test.go

index 585120b76f23f9405fa13b071524c738252497da..ca769b16ac4980ea53fc61f13e5401f938c60eee 100644 (file)
@@ -53,3 +53,10 @@ func TestMarshalMetainfoNodes(t *testing.T) {
                Nodes: []Node{"1.2.3.4:5555", "not a hostport"},
        })
 }
+
+func TestUnmarshalBadMetainfoNodes(t *testing.T) {
+       var mi MetaInfo
+       // Should barf on the integer in the nodes list.
+       err := bencode.Unmarshal([]byte("d5:nodesl1:ai42eee"), &mi)
+       require.Error(t, err)
+}