Skip to content

Commit

Permalink
fix: assert keyword in getPayout (#1790)
Browse files Browse the repository at this point in the history
  • Loading branch information
katelynsills authored Sep 17, 2020
1 parent 07710d7 commit e4ec018
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
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

0 comments on commit e4ec018

Please sign in to comment.