Skip to content

Commit

Permalink
fix: minor fixes while debugging purse notifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Nov 27, 2020
1 parent bdebc9e commit bc4992a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/fake-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
importMailbox,
exportMailbox,
} from '@agoric/swingset-vat/src/devices/mailbox';

import anylogger from 'anylogger';

import { launch } from '../launch-chain';
Expand All @@ -14,7 +15,7 @@ import { makeWithQueue } from './vats/queue';

const log = anylogger('fake-chain');

const PRETEND_BLOCK_DELAY = 5;
const PRETEND_BLOCK_DELAY = 2;
const scaleBlockTime = ms => Math.floor(ms / 1000);

async function makeMapStorage(file) {
Expand Down
17 changes: 15 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,20 @@ export default async function start(basedir, argv) {

const agoricCli = require.resolve('.bin/agoric');

// Use the same verbosity as our caller did for us.
let verbosity;
if (process.env.DEBUG === undefined) {
verbosity = '';
} else if (process.env.DEBUG.includes('agoric')) {
verbosity = ' -vv';
} else {
verbosity = ' -v';
}

// Launch the agoric wallet deploys (if any).
exec(
`${agoricCli} deploy --provide=wallet --hostport=${hostport} ${agWalletDeploy}`,
(err, _stdout, stderr) => {
`${agoricCli} deploy${verbosity} --provide=wallet --hostport=${hostport} ${agWalletDeploy}`,
(err, stdout, stderr) => {
if (err) {
console.error(err);
return;
Expand All @@ -399,6 +409,9 @@ export default async function start(basedir, argv) {
// Report the error.
process.stderr.write(stderr);
}
if (stdout) {
process.stdout.write(stdout);
}
},
);
}
1 change: 0 additions & 1 deletion packages/dapp-svelte-wallet/api/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,5 @@ export default async function deployWallet(
const walletURLHandler = walletVat;
await E(http).registerWallet(wallet, walletURLHandler, bridgeURLHandler);
await E(walletVat).setHTTPObject(http);
await E(walletVat).setPresences();
console.log('Deployed Wallet!');
}
3 changes: 3 additions & 0 deletions packages/dapp-svelte-wallet/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
},
"dependencies": {
"@agoric/eventual-send": "^0.12.0",
"@agoric/ertp": "^0.8.0",
"@agoric/notifier": "^0.2.3",
"@agoric/promise-kit": "^0.1.7",
"@agoric/store": "^0.3.1",
"esm": "^3.2.5"
},
Expand Down
5 changes: 3 additions & 2 deletions packages/dapp-svelte-wallet/api/src/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export function buildRootObject(_vatPowers) {
}
}

function setPresences() {
function startSubscriptions() {
// console.debug(`subscribing to walletPurseState`);
// This provokes an immediate update
purseSubscribe(
Expand Down Expand Up @@ -490,13 +490,14 @@ export function buildRootObject(_vatPowers) {
});
}

startSubscriptions();

return harden({
startup,
getWallet,
setHTTPObject,
getCommandHandler,
getBridgeURLHandler,
setPresences,
});
}

Expand Down
4 changes: 2 additions & 2 deletions packages/dapp-svelte-wallet/api/test/test-lib-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async function setupTest() {
* Run a thunk and wait for the notifier to fire.
*
* @param {ERef<Notifier<any>>} notifier
* @param {() => Promise<void>} thunk
* @param {() => Promise<any>} thunk
*/
const waitForUpdate = async (notifier, thunk) => {
const { updateCount } = await E(notifier).getUpdateSince();
Expand Down Expand Up @@ -176,7 +176,7 @@ test('lib-wallet issuer and purse methods', async t => {
moolaBundle.amountMath.make(100),
`deposit successful`,
);
t.is(pursesStateChangeLog.length, 4, `pursesStateChangeLog length`);
t.is(pursesStateChangeLog.length, 6, `pursesStateChangeLog length`);
t.deepEqual(
JSON.parse(pursesStateChangeLog[pursesStateChangeLog.length - 1]),
[
Expand Down

0 comments on commit bc4992a

Please sign in to comment.