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: assert keyword in getPayout #1790

Merged
merged 1 commit into from
Sep 17, 2020
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
5 changes: 4 additions & 1 deletion packages/zoe/src/zoeService/zoeSeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ export const makeZoeSeatAdminKit = (
getCurrentAllocation: async () => zoeSeatAdmin.getCurrentAllocation(),
getProposal: async () => proposal,
getPayouts: async () => payoutPromiseKit.promise,
getPayout: async keyword => E.G(payoutPromiseKit.promise)[keyword],
getPayout: async keyword => {
assert(keyword, 'A keyword must be provided');
return E.G(payoutPromiseKit.promise)[keyword];
},
getOfferResult: async () => offerResult,
hasExited: async () => !instanceAdmin.hasZoeSeatAdmin(zoeSeatAdmin),
tryExit: async () => E(exitObj).exit(),
Expand Down
21 changes: 8 additions & 13 deletions packages/zoe/test/unitTests/zcf/test-zcf.js
Original file line number Diff line number Diff line change
Expand Up @@ -1054,19 +1054,14 @@ test(`userSeat.getPayouts, getPayout from zcf.makeEmptySeatKit`, async t => {
});
});

test.failing(
`userSeat.getPayout() should throw from zcf.makeEmptySeatKit`,
async t => {
const { zcf } = await setupZCFTest();
const { userSeat } = zcf.makeEmptySeatKit();

// TODO: Not providing a keyword should throw.
// https://github.com/Agoric/agoric-sdk/issues/1754
await t.throwsAsync(() => E(userSeat).getPayout(), {
message: 'A keyword must be provided to get the payout',
});
},
);
test(`userSeat.getPayout() should throw from zcf.makeEmptySeatKit`, async t => {
const { zcf } = await setupZCFTest();
const { userSeat } = zcf.makeEmptySeatKit();
// @ts-ignore
await t.throwsAsync(() => E(userSeat).getPayout(), {
message: 'A keyword must be provided',
});
});

test(`zcf.reallocate < 2 seats`, async t => {
const { zcf } = await setupZCFTest();
Expand Down