-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
closes #243
- Loading branch information
1 parent
adb3a8d
commit 1bacd54
Showing
2 changed files
with
230 additions
and
8 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 |
---|---|---|
|
@@ -2,6 +2,9 @@ import * as Space from '@web3-storage/capabilities/space' | |
import assert from 'assert' | ||
import { context } from './helpers/context.js' | ||
import { createSpace } from './helpers/utils.js' | ||
import { parseLink } from '@ucanto/core' | ||
import * as Store from '@web3-storage/capabilities/store' | ||
import * as Upload from '@web3-storage/capabilities/upload' | ||
// @ts-ignore | ||
import isSubset from 'is-subset' | ||
|
||
|
@@ -72,4 +75,215 @@ describe('space/info', function () { | |
) | ||
} | ||
}) | ||
|
||
it('should return space info with store/add as proof', async function () { | ||
const { issuer, service, conn } = ctx | ||
|
||
const { space, delegation } = await createSpace( | ||
issuer, | ||
service, | ||
conn, | ||
'[email protected]' | ||
) | ||
|
||
const inv = await Space.info | ||
.invoke({ | ||
issuer, | ||
audience: service, | ||
with: space.did(), | ||
proofs: [ | ||
await Store.add.delegate({ | ||
audience: issuer, | ||
issuer: space, | ||
with: space.did(), | ||
proofs: [delegation], | ||
nb: { | ||
size: 1000, | ||
link: parseLink('bafkqaaa'), | ||
}, | ||
}), | ||
], | ||
}) | ||
.execute(conn) | ||
|
||
if (inv?.error) { | ||
assert.fail(inv.message) | ||
} else { | ||
assert.deepEqual(inv.did, space.did()) | ||
} | ||
}) | ||
|
||
it('should return space info with store/list as proof', async function () { | ||
const { issuer, service, conn } = ctx | ||
|
||
const { space, delegation } = await createSpace( | ||
issuer, | ||
service, | ||
conn, | ||
'[email protected]' | ||
) | ||
|
||
const inv = await Space.info | ||
.invoke({ | ||
issuer, | ||
audience: service, | ||
with: space.did(), | ||
proofs: [ | ||
await Store.list.delegate({ | ||
audience: issuer, | ||
issuer: space, | ||
with: space.did(), | ||
proofs: [delegation], | ||
}), | ||
], | ||
}) | ||
.execute(conn) | ||
|
||
if (inv?.error) { | ||
assert.fail(inv.message) | ||
} else { | ||
assert.deepEqual(inv.did, space.did()) | ||
} | ||
}) | ||
|
||
it('should return space info with store/remove as proof', async function () { | ||
const { issuer, service, conn } = ctx | ||
|
||
const { space, delegation } = await createSpace( | ||
issuer, | ||
service, | ||
conn, | ||
'[email protected]' | ||
) | ||
|
||
const inv = await Space.info | ||
.invoke({ | ||
issuer, | ||
audience: service, | ||
with: space.did(), | ||
proofs: [ | ||
await Store.remove.delegate({ | ||
audience: issuer, | ||
issuer: space, | ||
with: space.did(), | ||
proofs: [delegation], | ||
nb: { | ||
link: parseLink('bafkqaaa'), | ||
}, | ||
}), | ||
], | ||
}) | ||
.execute(conn) | ||
|
||
if (inv?.error) { | ||
assert.fail(inv.message) | ||
} else { | ||
assert.deepEqual(inv.did, space.did()) | ||
} | ||
}) | ||
|
||
it('should return space info with upload/add as proof', async function () { | ||
const { issuer, service, conn } = ctx | ||
|
||
const { space, delegation } = await createSpace( | ||
issuer, | ||
service, | ||
conn, | ||
'[email protected]' | ||
) | ||
|
||
const inv = await Space.info | ||
.invoke({ | ||
issuer, | ||
audience: service, | ||
with: space.did(), | ||
proofs: [ | ||
await Upload.add.delegate({ | ||
audience: issuer, | ||
issuer: space, | ||
with: space.did(), | ||
proofs: [delegation], | ||
nb: { | ||
root: parseLink('bafkqaaa'), | ||
}, | ||
}), | ||
], | ||
}) | ||
.execute(conn) | ||
|
||
if (inv?.error) { | ||
assert.fail(inv.message) | ||
} else { | ||
assert.deepEqual(inv.did, space.did()) | ||
} | ||
}) | ||
|
||
it('should return space info with upload/list as proof', async function () { | ||
const { issuer, service, conn } = ctx | ||
|
||
const { space, delegation } = await createSpace( | ||
issuer, | ||
service, | ||
conn, | ||
'[email protected]' | ||
) | ||
|
||
const inv = await Space.info | ||
.invoke({ | ||
issuer, | ||
audience: service, | ||
with: space.did(), | ||
proofs: [ | ||
await Upload.list.delegate({ | ||
audience: issuer, | ||
issuer: space, | ||
with: space.did(), | ||
proofs: [delegation], | ||
}), | ||
], | ||
}) | ||
.execute(conn) | ||
|
||
if (inv?.error) { | ||
assert.fail(inv.message) | ||
} else { | ||
assert.deepEqual(inv.did, space.did()) | ||
} | ||
}) | ||
|
||
it('should return space info with upload/remove as proof', async function () { | ||
const { issuer, service, conn } = ctx | ||
|
||
const { space, delegation } = await createSpace( | ||
issuer, | ||
service, | ||
conn, | ||
'[email protected]' | ||
) | ||
|
||
const inv = await Space.info | ||
.invoke({ | ||
issuer, | ||
audience: service, | ||
with: space.did(), | ||
proofs: [ | ||
await Upload.remove.delegate({ | ||
audience: issuer, | ||
issuer: space, | ||
with: space.did(), | ||
proofs: [delegation], | ||
nb: { | ||
root: parseLink('bafkqaaa'), | ||
}, | ||
}), | ||
], | ||
}) | ||
.execute(conn) | ||
|
||
if (inv?.error) { | ||
assert.fail(inv.message) | ||
} else { | ||
assert.deepEqual(inv.did, space.did()) | ||
} | ||
}) | ||
}) |
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