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

test(liveslots): relaxDurability should ignore promises #9539

Merged
merged 1 commit into from
Jul 10, 2024
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
4 changes: 4 additions & 0 deletions packages/inter-protocol/test/provisionPool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,15 @@ test('provisionPool publishes metricsOverride promptly', async t => {
},
);

// FIXME: remove the 'await null',
// https://github.com/Agoric/agoric-sdk/issues/9598
await null;
const metrics = E(facets.publicFacet).getMetrics();

const {
head: { value: initialMetrics },
} = await E(metrics).subscribeAfter();
// FIXME fails when fakeVatAdmin.js fixed for non-promise root. Why?
erights marked this conversation as resolved.
Show resolved Hide resolved
t.deepEqual(initialMetrics, {
totalMintedConverted: minted.make(20_000_000n),
totalMintedProvided: minted.make(750_000n),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
// @ts-check
import { Fail } from '@endo/errors';
import { E } from '@endo/eventual-send';
import {
makeFakeVatAdmin,
zcfBundleCap,
Expand Down Expand Up @@ -109,7 +110,8 @@ export const makePopulatedFakeVatAdmin = () => {
const baggage = makeScalarBigMapStore('baggage');
const adminNode =
/** @type {import('@agoric/swingset-vat').VatAdminFacet} */ ({});
return { root: buildRoot({}, vatParameters, baggage), adminNode };
const rootP = buildRoot({}, vatParameters, baggage);
return E.when(rootP, root => harden({ root, adminNode }));
};
const createVatByName = async name => {
return createVat(fakeNameToCap.get(name) || Fail`unknown vat ${name}`);
Expand Down
15 changes: 10 additions & 5 deletions packages/inter-protocol/test/smartWallet/contexts.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,19 @@ export const makeDefaultTestContext = async (t, makeSpace) => {
*/
const walletBridgeManager = await (bridgeManager &&
makeScopedBridge(bridgeManager, BridgeId.WALLET));

const customTerms = await deeplyFulfilledObject(
harden({
agoricNames, // may be a promise
board: consume.board, // may be a promise
assetPublisher,
}),
);

const walletFactory = await E(zoe).startInstance(
installation,
{},
{
agoricNames,
board: consume.board,
assetPublisher,
},
customTerms,
{ storageNode, walletBridgeManager },
);

Expand Down
19 changes: 11 additions & 8 deletions packages/pegasus/test/fakeVatAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ export default harden({
createMeter: () => {},
createUnlimitedMeter: () => {},
createVat: bundle => {
return harden({
root: E(evalContractBundle(bundle)).buildRootObject(),
adminNode: {
done: () => {
return makePromiseKit().promise;
const rootP = E(evalContractBundle(bundle)).buildRootObject();
return E.when(rootP, root =>
harden({
root,
adminNode: {
done: () => {
return makePromiseKit().promise;
},
terminate: () => {},
},
terminate: () => {},
},
});
}),
);
},
createVatByName: _name => {
throw Error(`createVatByName not supported in fake mode`);
Expand Down
15 changes: 10 additions & 5 deletions packages/smart-wallet/test/contexts.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,19 @@ export const makeDefaultTestContext = async (t, makeSpace) => {
const bridgeManager = await consume.bridgeManager;
const walletBridgeManager = await (bridgeManager &&
makeScopedBridge(bridgeManager, BridgeId.WALLET));
const walletFactory = await E(zoe).startInstance(
installation,
{},
{

const customTerms = await deeplyFulfilledObject(
harden({
agoricNames,
board: consume.board,
assetPublisher,
},
}),
);

const walletFactory = await E(zoe).startInstance(
installation,
{},
customTerms,
{ storageNode, walletBridgeManager },
);

Expand Down
13 changes: 9 additions & 4 deletions packages/smart-wallet/test/startWalletFactory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ test.before(async t => {

test('customTermsShape', async t => {
const { consume, bridgeManager, installation, storageNode } = t.context;
const { agoricNames, board, zoe } = consume;
const { zoe } = consume;
const privateArgs = { bridgeManager, storageNode };

const agoricNames = await consume.agoricNames;
const board = await consume.board;

// extra term
await t.throwsAsync(
E(zoe).startInstance(
Expand All @@ -73,7 +76,7 @@ test('customTermsShape', async t => {
),
{
message:
'customTerms: {"agoricNames":"[Promise]","assetPublisher":{},"board":"[Promise]","extra":"[Seen]"} - Must not have unexpected properties: ["extra"]',
'customTerms: {"agoricNames":"[Alleged: NameHubKit nameHub]","assetPublisher":{},"board":"[Alleged: Board board]","extra":"[Seen]"} - Must not have unexpected properties: ["extra"]',
},
);

Expand All @@ -90,14 +93,16 @@ test('customTermsShape', async t => {
),
{
message:
'customTerms: {"agoricNames":"[Promise]"} - Must have missing properties ["board","assetPublisher"]',
'customTerms: {"agoricNames":"[Alleged: NameHubKit nameHub]"} - Must have missing properties ["board","assetPublisher"]',
},
);
});

test('privateArgsShape', async t => {
const { consume, bridgeManager, installation } = t.context;
const { agoricNames, board, zoe } = consume;
const { zoe } = consume;
const agoricNames = await consume.agoricNames;
const board = await consume.board;
const terms = {
agoricNames,
board,
Expand Down
5 changes: 4 additions & 1 deletion packages/swingset-liveslots/src/virtualReferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,10 @@ export function makeVirtualReferenceManager(
*/
function isDurable(vref) {
const { type, id, virtual, durable, allocatedByVat } = parseVatSlot(vref);
if (relaxDurabilityRules) {
if (type === 'promise') {
// promises are not durable even if `relaxDurabilityRules === true`
return false;
} else if (relaxDurabilityRules) {
// we'll pretend an object is durable if running with relaxed rules
return true;
} else if (type === 'device') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ async function runDurabilityCheckTest(t, relaxDurabilityRules) {
passVal(() => virtualMap.init('non-scalar key', aNonScalarKey));
passVal(() => virtualMap.init('non-scalar non-key', aNonScalarNonKey));

condVal(() => durableMap.init('promise', aPassablePromise));
failVal(() => durableMap.init('promise', aPassablePromise));
passVal(() => durableMap.init('error', aPassableError));
passVal(() => durableMap.init('non-scalar key', aNonScalarKey));
passVal(() => durableMap.init('non-scalar non-key', aNonScalarNonKey));
Expand Down
4 changes: 3 additions & 1 deletion packages/vats/tools/boot-test-utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Fail } from '@endo/errors';
import { E } from '@endo/far';
import { Far } from '@endo/marshal';

import {
Expand Down Expand Up @@ -126,7 +127,8 @@ export const makePopulatedFakeVatAdmin = () => {
const baggage = makeScalarBigMapStore('baggage');
const adminNode =
/** @type {import('@agoric/swingset-vat').VatAdminFacet} */ ({});
return { root: buildRoot({}, vatParameters, baggage), adminNode };
const rootP = buildRoot({}, vatParameters, baggage);
return E.when(rootP, root => harden({ root, adminNode }));
};
const createVatByName = async name => {
return createVat(fakeNameToCap.get(name) || Fail`unknown vat ${name}`);
Expand Down
17 changes: 9 additions & 8 deletions packages/zoe/tools/fakeVatAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,16 @@ function makeFakeVatAdmin(testContextSetter = undefined, makeRemote = x => x) {
// buildRootObject: vp => ns.buildRootObject(vpow, vp, vatBaggage),
// }),
// );
return Promise.resolve(
const rootP = makeRemote(
E(evalContractBundle(zcfBundle)).buildRootObject(
vpow,
vatParameters,
vatBaggage,
),
);
return E.when(rootP, root =>
harden({
root: makeRemote(
E(evalContractBundle(zcfBundle)).buildRootObject(
vpow,
vatParameters,
vatBaggage,
),
),
root,
adminNode: Far('adminNode', {
done: () => {
return exitKit.promise;
Expand Down
Loading