Skip to content

Commit

Permalink
test(delegation): calculate newCID from new.dagjson so tests are not …
Browse files Browse the repository at this point in the history
…brittle
  • Loading branch information
smoyer64 committed Dec 10, 2024
1 parent f2d75b7 commit 9036326
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 0 additions & 3 deletions token/delegation/delegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ const (
]
`

newCID = "zdpuAnaCA4uaSJyuthxdu6sRkgTeUt1fbGqzb1CsRxiBygjty"
rootCID = "zdpuAkgGmUp5JrXvehGuuw9JA8DLQKDaxtK3R8brDQQVC2i5X"

aesKey = "xQklMmNTnVrmaPBq/0pwV5fEwuv/iClF5HWak9MsgI8="
)

Expand Down
10 changes: 8 additions & 2 deletions token/delegation/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ func TestSchemaRoundTrip(t *testing.T) {
p1, err := delegation.FromDagJson(delegationJson)
require.NoError(t, err)

_, newCID, err := p1.ToSealed(privKey)
require.NoError(t, err)

cborBytes, id, err := p1.ToSealed(privKey)
require.NoError(t, err)
assert.Equal(t, newCID, envelope.CIDToBase58BTC(id))
assert.Equal(t, envelope.CIDToBase58BTC(newCID), envelope.CIDToBase58BTC(id))

p2, c2, err := delegation.FromSealed(cborBytes)
require.NoError(t, err)
Expand All @@ -58,10 +61,13 @@ func TestSchemaRoundTrip(t *testing.T) {
p1, err := delegation.FromDagJsonReader(buf)
require.NoError(t, err)

_, newCID, err := p1.ToSealed(privKey)
require.NoError(t, err)

cborBytes := &bytes.Buffer{}
id, err := p1.ToSealedWriter(cborBytes, privKey)
require.NoError(t, err)
assert.Equal(t, newCID, envelope.CIDToBase58BTC(id))
assert.Equal(t, envelope.CIDToBase58BTC(newCID), envelope.CIDToBase58BTC(id))

// buf = bytes.NewBuffer(cborBytes.Bytes())
p2, c2, err := delegation.FromSealedReader(cborBytes)
Expand Down

0 comments on commit 9036326

Please sign in to comment.