diff --git a/packages/zoe/test/unitTests/contracts/grifter.js b/packages/zoe/test/unitTests/contracts/grifter.js deleted file mode 100644 index 7b0f462116e..00000000000 --- a/packages/zoe/test/unitTests/contracts/grifter.js +++ /dev/null @@ -1,49 +0,0 @@ -// @ts-check - -// Eventually will be importable from '@agoric/zoe-contract-support' -import { - assertIssuerKeywords, - assertProposalShape, -} from '../../../src/contractSupport'; - -/** - * @type {ContractStartFn} - */ -const start = zcf => { - assertIssuerKeywords(zcf, harden(['Asset', 'Price'])); - - const makeAccompliceInvitation = malSeat => { - const { want: wantProposal } = malSeat.getProposal(); - - return zcf.makeInvitation( - vicSeat => { - const malAlloc = malSeat.getCurrentAllocation(); - const malSeatStaging = malSeat.stage(wantProposal); - const vicSeatStaging = vicSeat.stage(malAlloc); - zcf.reallocate(malSeatStaging, vicSeatStaging); - malSeat.exit(); - vicSeat.exit(); - }, - 'tantalizing offer', - harden({ - customProperties: { - Price: wantProposal.Price, - }, - }), - ); - }; - - const firstOfferExpected = harden({ - want: { Price: null }, - }); - - const creatorInvitation = zcf.makeInvitation( - assertProposalShape(makeAccompliceInvitation, firstOfferExpected), - 'firstOffer', - ); - - return harden({ creatorInvitation }); -}; - -harden(start); -export { start }; diff --git a/packages/zoe/test/unitTests/contracts/test-grifter.js b/packages/zoe/test/unitTests/contracts/test-grifter.js deleted file mode 100644 index a4ac33551f8..00000000000 --- a/packages/zoe/test/unitTests/contracts/test-grifter.js +++ /dev/null @@ -1,60 +0,0 @@ -import '@agoric/install-ses'; -// eslint-disable-next-line import/no-extraneous-dependencies -import { test } from 'tape-promise/tape'; -// eslint-disable-next-line import/no-extraneous-dependencies -import bundleSource from '@agoric/bundle-source'; -import { E } from '@agoric/eventual-send'; - -// noinspection ES6PreferShortImport -import { makeZoe } from '../../../src/zoeService/zoe'; -import { setup } from '../setupBasicMints'; -import fakeVatAdmin from './fakeVatAdmin'; - -const grifterRoot = `${__dirname}/grifter`; - -test('zoe - grifter tries to steal; prevented by offer safety', async t => { - t.plan(1); - // Setup zoe and mints - const { moola, moolaR, moolaMint, bucksR, bucks } = setup(); - const zoe = makeZoe(fakeVatAdmin); - // Pack the contract. - const bundle = await bundleSource(grifterRoot); - const installationHandle = await zoe.install(bundle); - - const issuerKeywordRecord = harden({ - Asset: bucksR.issuer, - Price: moolaR.issuer, - }); - - const { creatorInvitation: malloryInvitation } = await zoe.startInstance( - installationHandle, - issuerKeywordRecord, - ); - - // Mallory doesn't need any money - const malloryProposal = harden({ - want: { Price: moola(37) }, - }); - const mallorySeat = await zoe.offer( - malloryInvitation, - malloryProposal, - harden({}), - ); - - const vicInvitationP = await E(mallorySeat).getOfferResult(); - - const vicMoolaPayment = moolaMint.mintPayment(moola(37)); - const vicProposal = harden({ - give: { Price: moola(37) }, - want: { Asset: bucks(24) }, - exit: { onDemand: null }, - }); - const vicPayments = { Price: vicMoolaPayment }; - const vicSeat = await zoe.offer(vicInvitationP, vicProposal, vicPayments); - - t.rejects( - E(vicSeat).getOfferResult(), - /The reallocation was not offer safe/, - `vicOffer is rejected`, - ); -});