Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(zoe): Fix guards to accurately guard args #8642

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions packages/zoe/src/typeGuards.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,12 @@ export const ZoeStorageManagerIKit = harden({
getBundleIDFromInstallation: M.call(InstallationShape).returns(
M.eref(M.string()),
),
installBundle: M.call(M.or(InstanceHandleShape, BundleShape)).returns(
M.promise(),
),
installBundleID: M.call(M.string()).returns(M.promise()),
installBundle: M.call(M.or(InstanceHandleShape, BundleShape))
.optional(M.string())
.returns(M.promise()),
installBundleID: M.call(M.string())
.optional(M.string())
.returns(M.promise()),

getPublicFacet: M.call(InstanceHandleShape).returns(
M.eref(M.remotable('PublicFacet')),
Expand Down Expand Up @@ -310,6 +312,7 @@ export const ZoeStorageManagerIKit = harden({
IssuerPKeywordRecordShape,
M.or(InstanceHandleShape, BundleShape),
erights marked this conversation as resolved.
Show resolved Hide resolved
M.or(BundleCapShape, BundleShape),
M.string(),
).returns(M.promise()),
unwrapInstallation: M.callWhen(M.eref(InstallationShape)).returns(
UnwrappedInstallationShape,
Expand All @@ -321,10 +324,10 @@ export const ZoeStorageManagerIKit = harden({
});

export const ZoeServiceI = M.interface('ZoeService', {
install: M.call(M.any()).returns(M.promise()),
installBundleID: M.call(M.string()).returns(M.promise()),
install: M.call(M.any()).optional(M.string()).returns(M.promise()),
installBundleID: M.call(M.string()).optional(M.string()).returns(M.promise()),
startInstance: M.call(M.eref(InstallationShape))
.optional(IssuerPKeywordRecordShape, M.any(), M.any())
.optional(IssuerPKeywordRecordShape, M.record(), M.record(), M.string())
.returns(M.promise()),
offer: M.call(M.eref(InvitationShape))
.optional(ProposalShape, PaymentPKeywordRecordShape, M.any())
Expand Down
8 changes: 6 additions & 2 deletions packages/zoe/src/zoeService/installationStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ export const makeInstallationStorage = (getBundleCapForID, zoeBaggage) => {
InstanceHandleShape,
M.recordOf(M.string(), M.string({ stringLengthLimit: Infinity })),
),
).returns(M.promise()),
installBundleID: M.call(M.string()).returns(M.promise()),
)
.optional(M.string())
.returns(M.promise()),
installBundleID: M.call(M.string())
.optional(M.string())
.returns(M.promise()),
unwrapInstallation: M.callWhen(M.await(InstallationShape)).returns(
UnwrappedInstallationShape,
),
Expand Down
9 changes: 9 additions & 0 deletions packages/zoe/test/unitTests/test-zoe.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ test(`E(zoe).installBundleID bad id`, async t => {
});
});

test(`E(zoe).installBundleID bad label`, async t => {
const { zoe } = setup();
// @ts-expect-error deliberate invalid arguments for testing
await t.throwsAsync(() => E(zoe).installBundleID('a', harden([])), {
message:
'In "installBundleID" method of (ZoeService): arg 1?: copyArray [] - Must be a string',
});
});

test(`E(zoe).installBundleID(bundleID)`, async t => {
const { zoe, vatAdminState } = setup();
const contractPath = `${dirname}/../../src/contracts/atomicSwap`;
Expand Down
Loading