Skip to content

Commit

Permalink
chore(bootstrap-exports): WIP, override provisionBridgeManager
Browse files Browse the repository at this point in the history
Refs: #10425
  • Loading branch information
anilhelvaci committed Nov 21, 2024
1 parent 0096916 commit 9d066c0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
1 change: 1 addition & 0 deletions a3p-integration/proposals/p:upgrade-19/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
replaceFeeDistributor/
replaceProvisioningHandler/
3 changes: 2 additions & 1 deletion a3p-integration/proposals/p:upgrade-19/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"agoricProposal": {
"type": "/agoric.swingset.CoreEvalProposal",
"sdk-generate": [
"testing/replace-feeDistributor-short.js replaceFeeDistributor"
"testing/replace-feeDistributor-short.js replaceFeeDistributor",
"vats/replace-provisioningHandler.js replaceProvisioningHandler"
]
},
"type": "module",
Expand Down
15 changes: 14 additions & 1 deletion a3p-integration/proposals/p:upgrade-19/provisioning.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ import {
VALIDATORADDR,
CHAINID,
GOV1ADDR,
evalBundles,
} from '@agoric/synthetic-chain';
import {
retryUntilCondition,
makeVstorageKit,
waitUntilAccountFunded,
sleep,
} from '@agoric/client-utils';
import { execFileSync } from 'child_process';

const CORE_EVAL_DIR = 'replaceProvisioningHandler';

const agd = makeAgd({ execFileSync }).withOpts({ keyringBackend: 'test' });

/**
*
* @param {string} addr
* @param {string} wanted
* @param {string} [from]
Expand Down Expand Up @@ -78,6 +81,16 @@ test.before(async t => {
};
});

test.serial.only('replace provisioningHandler', async t => {
await evalBundles(CORE_EVAL_DIR);
// Since the replaceProvisioningHandler does not signal anything to vstorage
// we have no way of knowing if the core eval executed successfully other than
// observing it from the logs. So we just wait for 30 seconds here to make
// sure there's enough time to evaluate the core eval.
await sleep(30000, { log: console.log, setTimeout });
t.pass();
});

test.serial('provision manually', async t => {
// @ts-expect-error casting
const { vstorageKit } = t.context;
Expand Down
20 changes: 13 additions & 7 deletions packages/vats/src/lib-provisioning.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
import { prepareExoClass } from '@agoric/vat-data';
import { Fail } from '@endo/errors';
import { E } from '@endo/far';
import { BridgeHandlerI } from './bridge.js';
import { getInterfaceGuardPayload } from '@endo/patterns';
import { M } from '@agoric/store';
import { PowerFlags } from './walletFlags.js';
import { makeDurableZone } from '@agoric/zone/durable.js';
import { BridgeHandlerI } from './bridge.js';

const BridgeHandlerAdjustedI = M.interface('BridgeHandlerTest', {
...getInterfaceGuardPayload(BridgeHandlerI).methodGuards
});

/**
* @param {import('@agoric/store').MapStore} baggage
*/
export const prepareProvisionBridgeHandler = baggage => {
const makeProvisionBridgeHandler = prepareExoClass(
baggage,
'provisioningHandler',
BridgeHandlerI,
const zone = makeDurableZone(baggage);
const makeProvisionBridgeHandler = zone.exoClass(
'provisioningHandlerDurable',
BridgeHandlerAdjustedI,
(provisioning, provisionWalletBridgeManager) => ({
provisioning,
provisionWalletBridgeManager,
}),
{
async fromBridge(obj) {
const { provisionWalletBridgeManager, provisioning } = this.state;
switch (obj.type) {
switch (obj && obj.type) {
case 'PLEASE_PROVISION': {
const { nickname, address, powerFlags: rawPowerFlags } = obj;
const powerFlags = rawPowerFlags || [];
Expand Down

0 comments on commit 9d066c0

Please sign in to comment.