diff --git a/bencode/fuzz_test.go b/bencode/fuzz_test.go index a4996df3..d0dce71f 100644 --- a/bencode/fuzz_test.go +++ b/bencode/fuzz_test.go @@ -34,3 +34,20 @@ func Fuzz(f *testing.F) { c.Assert(d0, bencodeInterfaceChecker, d) }) } + +func FuzzInterfaceRoundTrip(f *testing.F) { + for _, ret := range random_encode_tests { + f.Add([]byte(ret.expected)) + } + f.Fuzz(func(t *testing.T, b []byte) { + c := qt.New(t) + var d interface{} + err := Unmarshal(b, &d) + if err != nil { + c.Skip(err) + } + b0, err := Marshal(d) + c.Assert(err, qt.IsNil) + c.Check(b0, qt.DeepEquals, b) + }) +} diff --git a/bencode/testdata/fuzz/FuzzInterfaceRoundTrip/1d7fd8d6b4e9380abbaa373f173a59a4d4418d23d3db9af8abd3ea5412c629c5 b/bencode/testdata/fuzz/FuzzInterfaceRoundTrip/1d7fd8d6b4e9380abbaa373f173a59a4d4418d23d3db9af8abd3ea5412c629c5 new file mode 100644 index 00000000..87fcc3d5 --- /dev/null +++ b/bencode/testdata/fuzz/FuzzInterfaceRoundTrip/1d7fd8d6b4e9380abbaa373f173a59a4d4418d23d3db9af8abd3ea5412c629c5 @@ -0,0 +1,2 @@ +go test fuzz v1 +[]byte("00:") diff --git a/bencode/testdata/fuzz/FuzzInterfaceRoundTrip/2674fedd58e056c9322ff8ed4bd0b23e2d9080499038d4353739f5c81b05fc0a b/bencode/testdata/fuzz/FuzzInterfaceRoundTrip/2674fedd58e056c9322ff8ed4bd0b23e2d9080499038d4353739f5c81b05fc0a new file mode 100644 index 00000000..903e02e1 --- /dev/null +++ b/bencode/testdata/fuzz/FuzzInterfaceRoundTrip/2674fedd58e056c9322ff8ed4bd0b23e2d9080499038d4353739f5c81b05fc0a @@ -0,0 +1,2 @@ +go test fuzz v1 +[]byte("d3:000e") diff --git a/bencode/testdata/fuzz/FuzzInterfaceRoundTrip/49dbd4b139383deb718477bee049320c697e6e7ae547e0a4c4ebd4c2cdd25c1b b/bencode/testdata/fuzz/FuzzInterfaceRoundTrip/49dbd4b139383deb718477bee049320c697e6e7ae547e0a4c4ebd4c2cdd25c1b new file mode 100644 index 00000000..b2ace7b4 --- /dev/null +++ b/bencode/testdata/fuzz/FuzzInterfaceRoundTrip/49dbd4b139383deb718477bee049320c697e6e7ae547e0a4c4ebd4c2cdd25c1b @@ -0,0 +1,2 @@ +go test fuzz v1 +[]byte("i00e")