envelope: fuzz Inspect and FindTag
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/ipld/go-ipld-prime"
|
||||
@@ -170,3 +171,39 @@ func TestInspect(t *testing.T) {
|
||||
assert.Equal(t, "ucan/example@v1.0.0-rc.1", info.Tag)
|
||||
assert.Equal(t, []byte{0x34, 0xed, 0x1, 0x71}, info.VarsigHeader)
|
||||
}
|
||||
|
||||
func FuzzInspect(f *testing.F) {
|
||||
data, err := os.ReadFile("testdata/example.dagcbor")
|
||||
require.NoError(f, err)
|
||||
|
||||
f.Add(data)
|
||||
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
node, err := ipld.Decode(data, dagcbor.Decode)
|
||||
if err != nil {
|
||||
t.Skip()
|
||||
}
|
||||
_, err = envelope.Inspect(node)
|
||||
if err != nil {
|
||||
t.Skip()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func FuzzFindTag(f *testing.F) {
|
||||
data, err := os.ReadFile("testdata/example.dagcbor")
|
||||
require.NoError(f, err)
|
||||
|
||||
f.Add(data)
|
||||
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
node, err := ipld.Decode(data, dagcbor.Decode)
|
||||
if err != nil {
|
||||
t.Skip()
|
||||
}
|
||||
_, err = envelope.FindTag(node)
|
||||
if err != nil {
|
||||
t.Skip()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user