feat(delegation): make Token constructors resemble invocation.New() signature

This commit is contained in:
Steve Moyer
2024-11-25 15:12:29 -05:00
parent d90715d1fe
commit 60bdc8873b
9 changed files with 173 additions and 185 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/require"
"gotest.tools/v3/golden"
"github.com/ucan-wg/go-ucan/did/didtest"
"github.com/ucan-wg/go-ucan/token/internal/envelope"
"github.com/ucan-wg/go-ucan/token/invocation"
)
@@ -78,6 +79,16 @@ func TestSchemaRoundTrip(t *testing.T) {
assert.JSONEq(t, string(invocationJson), readJson.String())
})
t.Run("fails with wrong PrivKey", func(t *testing.T) {
t.Parallel()
p1, err := invocation.FromDagJson(invocationJson)
require.NoError(t, err)
_, _, err = p1.ToSealed(didtest.PersonaBob.PrivKey())
require.EqualError(t, err, "private key doesn't match the issuer")
})
}
func privKey(t require.TestingT, privKeyCfg string) crypto.PrivKey {