diff --git a/LICENSE.md b/LICENSE.md index 8b48609..1b44338 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -29,7 +29,7 @@ Verbatim copies of both licenses are included below: ``` Apache License Version 2.0, January 2004 - http://www.apache.org/licenses/ + https://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION diff --git a/pkg/container/serial_test.go b/pkg/container/serial_test.go index e2d3d94..fea2efe 100644 --- a/pkg/container/serial_test.go +++ b/pkg/container/serial_test.go @@ -130,12 +130,6 @@ func BenchmarkContainerSerialisation(b *testing.B) { } } -func randBytes(n int) []byte { - b := make([]byte, n) - _, _ = rand.Read(b) - return b -} - func randDID() (crypto.PrivKey, did.DID) { privKey, _, err := crypto.GenerateEd25519Key(rand.Reader) if err != nil { @@ -150,7 +144,7 @@ func randDID() (crypto.PrivKey, did.DID) { func randomString(length int) string { b := make([]byte, length/2+1) - rand.Read(b) + _, _ = rand.Read(b) return fmt.Sprintf("%x", b)[0:length] } diff --git a/pkg/meta/meta_test.go b/pkg/meta/meta_test.go index 7b1d994..9ad3e2c 100644 --- a/pkg/meta/meta_test.go +++ b/pkg/meta/meta_test.go @@ -4,8 +4,9 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/ucan-wg/go-ucan/pkg/meta" "gotest.tools/v3/assert" + + "github.com/ucan-wg/go-ucan/pkg/meta" ) func TestMeta_Add(t *testing.T) { diff --git a/pkg/policy/selector/selector.go b/pkg/policy/selector/selector.go index d75607a..149078d 100644 --- a/pkg/policy/selector/selector.go +++ b/pkg/policy/selector/selector.go @@ -1,7 +1,6 @@ package selector import ( - "errors" "fmt" "math" "strconv" @@ -11,7 +10,6 @@ import ( "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent/qp" "github.com/ipld/go-ipld-prime/node/basicnode" - "github.com/ipld/go-ipld-prime/schema" ) // Selector describes a UCAN policy selector, as specified here: @@ -302,23 +300,6 @@ func kindString(n datamodel.Node) string { return n.Kind().String() } -func isMissing(err error) bool { - if _, ok := err.(datamodel.ErrNotExists); ok { - return true - } - if _, ok := err.(schema.ErrNoSuchField); ok { - return true - } - if _, ok := err.(schema.ErrInvalidKey); ok { - return true - } - return false -} - -func IsResolutionErr(err error) bool { - return errors.As(err, &resolutionerr{}) -} - type resolutionerr struct { msg string at []string diff --git a/pkg/policy/selector/selector_test.go b/pkg/policy/selector/selector_test.go index 4795efb..5da0231 100644 --- a/pkg/policy/selector/selector_test.go +++ b/pkg/policy/selector/selector_test.go @@ -1,6 +1,7 @@ package selector import ( + "errors" "fmt" "strings" "testing" @@ -144,7 +145,6 @@ func TestSelect(t *testing.T) { fmt.Println(err) require.ErrorAs(t, err, &resolutionerr{}, "error should be a resolution error") - require.True(t, IsResolutionErr(err)) }) t.Run("optional not exists", func(t *testing.T) { @@ -364,7 +364,7 @@ func FuzzParseAndSelect(f *testing.F) { // look for panic() _, err = sel.Select(node) - if err != nil && !IsResolutionErr(err) { + if err != nil && !errors.As(err, &resolutionerr{}) { // not normal, we should only have resolution errors t.Fatal(err) } diff --git a/pkg/policy/selector/supported_test.go b/pkg/policy/selector/supported_test.go index 6a7b087..db22216 100644 --- a/pkg/policy/selector/supported_test.go +++ b/pkg/policy/selector/supported_test.go @@ -101,7 +101,6 @@ func TestSupportedForms(t *testing.T) { // attempt to select res, err := sel.Select(makeNode(t, tc.Input)) require.Error(t, err) - require.True(t, selector.IsResolutionErr(err)) require.Nil(t, res) }) }