Skip to content

Commit 2b02681

Browse files
committed
test(zoe): ensure fake bundleIDs for real bundles contain their hash
1 parent 01a0772 commit 2b02681

33 files changed

+277
-153
lines changed

packages/orchestration/test/utils/zcf-tools.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ const makeTestContext = async () => {
2424
const bundleCache = await makeNodeBundleCache('bundles', {}, s => import(s));
2525
const contractBundle = await bundleCache.load(contractEntry);
2626

27-
fakeVatAdmin.vatAdminState.installBundle('b1-contract', contractBundle);
28-
const installation = await E(zoe).installBundleID('b1-contract');
27+
const bid = fakeVatAdmin.vatAdminState.registerBundle(
28+
'b1-contract',
29+
contractBundle,
30+
);
31+
const installation = await E(zoe).installBundleID(bid);
2932

3033
const stuff = makeIssuerKit('Stuff');
3134
await E(zoe).startInstance(installation, { Stuff: stuff.issuer });

packages/zoe/test/unitTests/blockedOffers.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ const setupContract = async (moolaIssuer, bucksIssuer) => {
3333

3434
// pack the contract
3535
const bundle = await bundleSource(contractRoot);
36-
vatAdminState.installBundle('b1-contract', bundle);
36+
const b1contract = vatAdminState.registerBundle('b1-contract', bundle);
3737
// install the contract
38-
const installation = await E(zoe).installBundleID('b1-contract');
38+
const installation = await E(zoe).installBundleID(b1contract);
3939

4040
// Alice creates an instance
4141
const issuerKeywordRecord = harden({

packages/zoe/test/unitTests/contractSupport/depositTo.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ async function setupContract(moolaIssuer, bucksIssuer) {
2626

2727
// pack the contract
2828
const contractBundle = await bundleSource(contractRoot);
29-
fakeVatAdmin.vatAdminState.installBundle('b1-contract', contractBundle);
29+
const b1contract = fakeVatAdmin.vatAdminState.registerBundle(
30+
'b1-contract',
31+
contractBundle,
32+
);
3033

3134
// install the contract
32-
const installation = await E(zoe).installBundleID('b1-contract');
35+
const installation = await E(zoe).installBundleID(b1contract);
3336

3437
// Alice creates an instance
3538
const issuerKeywordRecord = harden({

packages/zoe/test/unitTests/contractSupport/offerTo.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ const setupContract = async (moolaIssuer, bucksIssuer) => {
2525

2626
// pack the contract
2727
const bundle = await bundleSource(contractRoot);
28-
fakeVatAdmin.vatAdminState.installBundle('b1-contract', bundle);
28+
const b1contract = fakeVatAdmin.vatAdminState.registerBundle(
29+
'b1-contract',
30+
bundle,
31+
);
2932
// install the contract
30-
const installation = await E(zoe).installBundleID('b1-contract');
33+
const installation = await E(zoe).installBundleID(b1contract);
3134

3235
// Create TWO instances of the zcfTesterContract which have
3336
// different keywords

packages/zoe/test/unitTests/contractSupport/withdrawFrom.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ async function setupContract(moolaIssuer, bucksIssuer) {
3030

3131
// pack the contract
3232
const bundle = await bundleSource(contractRoot);
33-
fakeVatAdmin.vatAdminState.installBundle('b1-contract', bundle);
33+
const b1contract = fakeVatAdmin.vatAdminState.registerBundle(
34+
'b1-contract',
35+
bundle,
36+
);
3437
// install the contract
35-
const installation = await E(zoe).installBundleID('b1-contract');
38+
const installation = await E(zoe).installBundleID(b1contract);
3639

3740
// Alice creates an instance
3841
const issuerKeywordRecord = harden({

packages/zoe/test/unitTests/contracts/atomicSwap.test.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ test('zoe - atomicSwap', async t => {
2828
// pack the contract
2929
const bundle = await bundleSource(atomicSwapRoot);
3030
// install the contract
31-
vatAdminState.installBundle('b1-atomicswap', bundle);
32-
const installationP = E(zoe).installBundleID('b1-atomicswap');
31+
const b1atomicswap = vatAdminState.registerBundle(
32+
'b1-atomicswap',
33+
bundle,
34+
);
35+
const installationP = E(zoe).installBundleID(b1atomicswap);
3336
return installationP;
3437
},
3538
startInstance: async installation => {
@@ -195,8 +198,11 @@ test('zoe - non-fungible atomicSwap', async t => {
195198
// pack the contract
196199
const bundle = await bundleSource(atomicSwapRoot);
197200
// install the contract
198-
vatAdminState.installBundle('b1-atomicswap', bundle);
199-
const installationP = E(zoe).installBundleID('b1-atomicswap');
201+
const b1atomicswap = vatAdminState.registerBundle(
202+
'b1-atomicswap',
203+
bundle,
204+
);
205+
const installationP = E(zoe).installBundleID(b1atomicswap);
200206
return installationP;
201207
},
202208
startInstance: async installation => {
@@ -353,8 +359,8 @@ test('zoe - atomicSwap like-for-like', async t => {
353359
// pack the contract
354360
const bundle = await bundleSource(atomicSwapRoot);
355361
// install the contract
356-
vatAdminState.installBundle('b1-atomicswap', bundle);
357-
const installation = await E(zoe).installBundleID('b1-atomicswap');
362+
const b1atomicswap = vatAdminState.registerBundle('b1-atomicswap', bundle);
363+
const installation = await E(zoe).installBundleID(b1atomicswap);
358364

359365
// Setup Alice
360366
const aliceMoolaPayment = moolaMint.mintPayment(moola(3n));

packages/zoe/test/unitTests/contracts/auction.test.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ test('zoe - secondPriceAuction w/ 3 bids', async t => {
2929
// pack the contract
3030
const bundle = await bundleSource(auctionRoot);
3131
// install the contract
32-
vatAdminState.installBundle('b1-auctioneer', bundle);
33-
const installationP = E(zoe).installBundleID('b1-auctioneer');
32+
const b1auctioneer = vatAdminState.registerBundle(
33+
'b1-auctioneer',
34+
bundle,
35+
);
36+
const installationP = E(zoe).installBundleID(b1auctioneer);
3437
return installationP;
3538
},
3639
startInstance: async installation => {
@@ -271,8 +274,8 @@ test('zoe - secondPriceAuction - alice tries to exit', async t => {
271274
// Pack the contract.
272275
const bundle = await bundleSource(auctionRoot);
273276

274-
vatAdminState.installBundle('b1-auctioneer', bundle);
275-
const installation = await E(zoe).installBundleID('b1-auctioneer');
277+
const b1auctioneer = vatAdminState.registerBundle('b1-auctioneer', bundle);
278+
const installation = await E(zoe).installBundleID(b1auctioneer);
276279
const issuerKeywordRecord = harden({
277280
Asset: moolaKit.issuer,
278281
Ask: simoleanKit.issuer,
@@ -422,8 +425,8 @@ test('zoe - secondPriceAuction - all bidders try to exit', async t => {
422425

423426
// Pack the contract.
424427
const bundle = await bundleSource(auctionRoot);
425-
vatAdminState.installBundle('b1-auctioneer', bundle);
426-
const installation = await E(zoe).installBundleID('b1-auctioneer');
428+
const b1auctioneer = vatAdminState.registerBundle('b1-auctioneer', bundle);
429+
const installation = await E(zoe).installBundleID(b1auctioneer);
427430
const issuerKeywordRecord = harden({
428431
Asset: moolaKit.issuer,
429432
Ask: simoleanKit.issuer,
@@ -566,8 +569,8 @@ test('zoe - secondPriceAuction non-fungible asset', async t => {
566569

567570
// Pack the contract.
568571
const bundle = await bundleSource(auctionRoot);
569-
vatAdminState.installBundle('b1-auctioneer', bundle);
570-
const installation = await E(zoe).installBundleID('b1-auctioneer');
572+
const b1auctioneer = vatAdminState.registerBundle('b1-auctioneer', bundle);
573+
const installation = await E(zoe).installBundleID(b1auctioneer);
571574
const issuerKeywordRecord = harden({
572575
Asset: ccIssuer,
573576
Ask: moolaIssuer,
@@ -852,8 +855,11 @@ test('zoe - firstPriceAuction w/ 3 bids', async t => {
852855
// pack the contract
853856
const bundle = await bundleSource(auctionRoot);
854857
// install the contract
855-
vatAdminState.installBundle('b1-auctioneer', bundle);
856-
const installationP = E(zoe).installBundleID('b1-auctioneer');
858+
const b1auctioneer = vatAdminState.registerBundle(
859+
'b1-auctioneer',
860+
bundle,
861+
);
862+
const installationP = E(zoe).installBundleID(b1auctioneer);
857863
return installationP;
858864
},
859865
startInstance: async installation => {

packages/zoe/test/unitTests/contracts/automaticRefund.test.js

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ test('zoe - simplest automaticRefund', async t => {
1818
const { moolaKit, moola, zoe, vatAdminState } = setup();
1919
// Pack the contract.
2020
const bundle = await bundleSource(automaticRefundRoot);
21-
vatAdminState.installBundle('b1-automaticRefund', bundle);
22-
const installation = await E(zoe).installBundleID('b1-automaticRefund');
21+
const b1automaticRefund = vatAdminState.registerBundle(
22+
'b1-automaticRefund',
23+
bundle,
24+
);
25+
const installation = await E(zoe).installBundleID(b1automaticRefund);
2326

2427
// Setup Alice
2528
const aliceMoolaPayment = moolaKit.mint.mintPayment(moola(3n));
@@ -58,8 +61,11 @@ test('zoe - automaticRefund same issuer', async t => {
5861
const { moolaKit, moola, zoe, vatAdminState } = setup();
5962
// Pack the contract.
6063
const bundle = await bundleSource(automaticRefundRoot);
61-
vatAdminState.installBundle('b1-automaticRefund', bundle);
62-
const installation = await E(zoe).installBundleID('b1-automaticRefund');
64+
const b1automaticRefund = vatAdminState.registerBundle(
65+
'b1-automaticRefund',
66+
bundle,
67+
);
68+
const installation = await E(zoe).installBundleID(b1automaticRefund);
6369

6470
// Setup Alice
6571
const aliceMoolaPayment = moolaKit.mint.mintPayment(moola(9n));
@@ -116,8 +122,11 @@ test('zoe with automaticRefund', async t => {
116122
const bundle = await bundleSource(automaticRefundRoot);
117123

118124
// 1: Alice creates an automatic refund instance
119-
vatAdminState.installBundle('b1-automaticRefund', bundle);
120-
const installation = await E(zoe).installBundleID('b1-automaticRefund');
125+
const b1automaticRefund = vatAdminState.registerBundle(
126+
'b1-automaticRefund',
127+
bundle,
128+
);
129+
const installation = await E(zoe).installBundleID(b1automaticRefund);
121130
const issuerKeywordRecord = harden({
122131
Contribution1: moolaKit.issuer,
123132
Contribution2: simoleanKit.issuer,
@@ -250,8 +259,11 @@ test('multiple instances of automaticRefund for the same Zoe', async t => {
250259
// Pack the contract.
251260
const bundle = await bundleSource(automaticRefundRoot);
252261

253-
vatAdminState.installBundle('b1-automaticRefund', bundle);
254-
const installation = await E(zoe).installBundleID('b1-automaticRefund');
262+
const b1automaticRefund = vatAdminState.registerBundle(
263+
'b1-automaticRefund',
264+
bundle,
265+
);
266+
const installation = await E(zoe).installBundleID(b1automaticRefund);
255267
const issuerKeywordRecord = harden({
256268
ContributionA: moolaKit.issuer,
257269
ContributionB: simoleanKit.issuer,
@@ -325,8 +337,11 @@ test('zoe - alice tries to complete after completion has already occurred', asyn
325337

326338
// Pack the contract.
327339
const bundle = await bundleSource(automaticRefundRoot);
328-
vatAdminState.installBundle('b1-automaticRefund', bundle);
329-
const installation = await E(zoe).installBundleID('b1-automaticRefund');
340+
const b1automaticRefund = vatAdminState.registerBundle(
341+
'b1-automaticRefund',
342+
bundle,
343+
);
344+
const installation = await E(zoe).installBundleID(b1automaticRefund);
330345
const issuerKeywordRecord = harden({
331346
ContributionA: moolaKit.issuer,
332347
ContributionB: simoleanKit.issuer,
@@ -387,8 +402,11 @@ test('zoe - automaticRefund non-fungible', async t => {
387402

388403
// Pack the contract.
389404
const bundle = await bundleSource(automaticRefundRoot);
390-
vatAdminState.installBundle('b1-automaticRefund', bundle);
391-
const installation = await E(zoe).installBundleID('b1-automaticRefund');
405+
const b1automaticRefund = vatAdminState.registerBundle(
406+
'b1-automaticRefund',
407+
bundle,
408+
);
409+
const installation = await E(zoe).installBundleID(b1automaticRefund);
392410

393411
// Setup Alice
394412
const aliceCcPayment = ccMint.mintPayment(cryptoCats(harden(['tigger'])));

packages/zoe/test/unitTests/contracts/brokenContract.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ test('zoe - brokenAutomaticRefund', async t => {
2121
const zoe = makeZoeForTest(fakeVatAdmin);
2222
// Pack the contract.
2323
const bundle = await bundleSource(automaticRefundRoot);
24-
vatAdminState.installBundle('b1-brokenAutomaticRefund', bundle);
25-
const installation = await E(zoe).installBundleID('b1-brokenAutomaticRefund');
24+
const b1brokenAutomaticRefund = vatAdminState.registerBundle(
25+
'b1-brokenAutomaticRefund',
26+
bundle,
27+
);
28+
const installation = await E(zoe).installBundleID(b1brokenAutomaticRefund);
2629

2730
const issuerKeywordRecord = harden({ Contribution: moolaKit.issuer });
2831

packages/zoe/test/unitTests/contracts/coveredCall-want-pattern.test.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,18 @@ test('zoe - coveredCall with swap for invitation', async t => {
3939
// Pack the contract.
4040
const coveredCallBundle = await bundleSource(coveredCallRoot);
4141

42-
vatAdminState.installBundle('b1-coveredcall', coveredCallBundle);
43-
const coveredCallInstallation =
44-
await E(zoe).installBundleID('b1-coveredcall');
42+
const b1coveredcall = vatAdminState.registerBundle(
43+
'b1-coveredcall',
44+
coveredCallBundle,
45+
);
46+
const coveredCallInstallation = await E(zoe).installBundleID(b1coveredcall);
4547
const atomicSwapBundle = await bundleSource(atomicSwapRoot);
4648

47-
vatAdminState.installBundle('b1-atomicswap', atomicSwapBundle);
48-
const swapInstallationId = await E(zoe).installBundleID('b1-atomicswap');
49+
const b1atomicswap = vatAdminState.registerBundle(
50+
'b1-atomicswap',
51+
atomicSwapBundle,
52+
);
53+
const swapInstallationId = await E(zoe).installBundleID(b1atomicswap);
4954

5055
// Setup Alice
5156
// Alice starts with 3 moola

0 commit comments

Comments
 (0)