Skip to content

Commit

Permalink
chore: increase code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Apr 3, 2024
1 parent 55efd8b commit 4f96c4c
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions packages/core/test/invocation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { invoke, UCAN, Invocation } from '../src/lib.js'
import { alice, service as w3 } from './fixtures.js'
import { getBlock } from './utils.js'
import { assert, test } from './test.js'
import { isInvocation } from '../src/invocation.js'

test('encode invocation', async () => {
const add = invoke({
Expand Down Expand Up @@ -42,8 +43,8 @@ test('encode invocation with attached block in capability nb', async () => {
with: alice.did(),
link: 'bafy...stuff',
nb: {
inlineBlock: block.cid.link()
}
inlineBlock: block.cid.link(),
},
},
proofs: [],
})
Expand All @@ -61,12 +62,12 @@ test('encode invocation with attached block in capability nb', async () => {

const reassembledInvocation = Invocation.view({
root: view.root.cid.link(),
blocks: blockStore
blocks: blockStore,
})

/** @type {import('@ucanto/interface').BlockStore<unknown>} */
const reassembledBlockstore = new Map()

for (const b of reassembledInvocation.iterateIPLDBlocks()) {
reassembledBlockstore.set(`${b.cid}`, b)
}
Expand All @@ -75,7 +76,6 @@ test('encode invocation with attached block in capability nb', async () => {
assert.ok(reassembledBlockstore.get(`${block.cid}`))
})


test('expired invocation', async () => {
const expiration = UCAN.now() - 5
const invocation = invoke({
Expand Down Expand Up @@ -226,3 +226,17 @@ test('receipt view fallback', async () => {
'returns fallback'
)
})

test('isInvocation', async () => {
const invocation = await invoke({
issuer: alice,
audience: w3,
capability: {
can: 'test/echo',
with: alice.did(),
},
}).delegate()

assert.equal(Invocation.isInvocation(invocation), true)
assert.equal(Invocation.isInvocation(invocation.link()), false)
})

0 comments on commit 4f96c4c

Please sign in to comment.