Skip to content

Commit

Permalink
Fix empty Info marshalling test
Browse files Browse the repository at this point in the history
  • Loading branch information
anacrolix committed Aug 27, 2024
1 parent 1b6a6f7 commit 8bbecda
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 6 additions & 5 deletions metainfo/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import (

// The info dictionary. See BEP 3 and BEP 52.
type Info struct {
PieceLength int64 `bencode:"piece length"` // BEP3
Pieces []byte `bencode:"pieces,omitempty"` // BEP3
Name string `bencode:"name"` // BEP3
NameUtf8 string `bencode:"name.utf-8,omitempty"`
Length int64 `bencode:"length,omitempty"` // BEP3, mutually exclusive with Files
PieceLength int64 `bencode:"piece length"` // BEP3
// BEP 3. This can be omitted because isn't needed in non-hybrid v2 infos. See BEP 52.
Pieces []byte `bencode:"pieces,omitempty"`
Name string `bencode:"name"` // BEP3
NameUtf8 string `bencode:"name.utf-8,omitempty"`
Length int64 `bencode:"length,omitempty"` // BEP3, mutually exclusive with Files
ExtendedFileAttrs
Private *bool `bencode:"private,omitempty"` // BEP27
// TODO: Document this field.
Expand Down
2 changes: 2 additions & 0 deletions metainfo/info_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package metainfo

import (
g "github.com/anacrolix/generics"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -10,6 +11,7 @@ import (

func TestMarshalInfo(t *testing.T) {
var info Info
g.MakeSliceWithLength(&info.Pieces, 0)
b, err := bencode.Marshal(info)
assert.NoError(t, err)
assert.EqualValues(t, "d4:name0:12:piece lengthi0e6:pieces0:e", string(b))
Expand Down

0 comments on commit 8bbecda

Please sign in to comment.