File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 9
9
)
10
10
11
11
type MetaInfo struct {
12
- InfoBytes bencode.Bytes `bencode:"info"`
12
+ InfoBytes bencode.Bytes `bencode:"info,omitempty "`
13
13
Announce string `bencode:"announce,omitempty"`
14
14
AnnounceList AnnounceList `bencode:"announce-list,omitempty"`
15
15
Nodes []Node `bencode:"nodes,omitempty"`
Original file line number Diff line number Diff line change 1
1
package metainfo
2
2
3
3
import (
4
+ "bytes"
4
5
"testing"
5
6
6
7
"github.com/stretchr/testify/assert"
@@ -61,3 +62,13 @@ func TestUnmarshalBadMetainfoNodes(t *testing.T) {
61
62
err := bencode .Unmarshal ([]byte ("d5:nodesl1:ai42eee" ), & mi )
62
63
require .Error (t , err )
63
64
}
65
+
66
+ func TestMetainfoEmptyInfoBytes (t * testing.T ) {
67
+ var buf bytes.Buffer
68
+ require .NoError (t , (& MetaInfo {
69
+ // Include a non-empty field that comes after "info".
70
+ UrlList : []string {"hello" },
71
+ }).Write (& buf ))
72
+ var mi MetaInfo
73
+ require .NoError (t , bencode .Unmarshal (buf .Bytes (), & mi ))
74
+ }
You can’t perform that action at this time.
0 commit comments