-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support execution of materialized invocations (#199)
* feat: support execution of delegations * chore: add one more test
- Loading branch information
Showing
8 changed files
with
139 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ import * as Service from './service.js' | |
import { alice, bob, mallory, service as w3 } from './fixtures.js' | ||
import fetch from '@web-std/fetch' | ||
|
||
test('encode inovocation', async () => { | ||
test('encode invocation', async () => { | ||
/** @type {Client.ConnectionView<Service.Service>} */ | ||
const connection = Client.connect({ | ||
id: w3, | ||
|
@@ -225,3 +225,40 @@ test('execute', async () => { | |
url: 'http://localhost:9090/', | ||
}) | ||
}) | ||
|
||
test('execute with delegations', async () => { | ||
const car = await CAR.codec.write({ | ||
roots: [await CBOR.codec.write({ hello: 'world ' })], | ||
}) | ||
|
||
const add = Client.invoke({ | ||
issuer: bob, | ||
audience: w3, | ||
capability: { | ||
can: 'store/add', | ||
with: bob.did(), | ||
nb: { link: car.cid }, | ||
}, | ||
proofs: [], | ||
}) | ||
|
||
const [e1] = await connection.execute(await add.delegate()) | ||
|
||
assert.deepEqual(e1, { | ||
error: true, | ||
name: 'UnknownDIDError', | ||
message: `DID ${bob.did()} has no account`, | ||
did: bob.did(), | ||
}) | ||
|
||
// fake register alice | ||
service.access.accounts.register(bob.did(), 'did:email:[email protected]', car.cid) | ||
|
||
const [r1] = await connection.execute(await add.delegate()) | ||
assert.deepEqual(r1, { | ||
with: bob.did(), | ||
link: car.cid, | ||
status: 'upload', | ||
url: 'http://localhost:9090/', | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.