Skip to content

Commit

Permalink
test: wait for vstorage update; more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Jan 31, 2024
1 parent 2534ab9 commit 5e98f9f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
42 changes: 28 additions & 14 deletions a3p-integration/proposals/a:upgrade-14/testRepairs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { agoric } from '@agoric/synthetic-chain/src/lib/cliHelper.js';
import {
getUser,
voteLatestProposalAndWait,
waitForBlock,
} from '@agoric/synthetic-chain/src/lib/commonUpgradeHelpers.js';
import { dbTool } from '@agoric/synthetic-chain/src/lib/vat-status.js';
import { type WebCache } from '@agoric/synthetic-chain/src/lib/webAsset.js';
Expand Down Expand Up @@ -143,8 +144,8 @@ await step('verify smartWallet repairs', async () => {
'submit-proposal',
'swingset-core-eval',
...evalPaths,
'--title=t',
'--description=d',
'--title=sendInvite',
'--description="send an invitation to verify the purse accepts deposits"',
`--deposit=${deposit}`,
'--gas=auto',
'--gas-adjustment=1.2',
Expand All @@ -158,21 +159,34 @@ await step('verify smartWallet repairs', async () => {
// agd query vstorage data published.wallet.$GOV1ADDR.current -o json \
// |& jq '.value | fromjson | .values[0] | fromjson | .body[1:] \
// | fromjson | .purses '
const resulta = await agd.query([
'vstorage',
'data',
`published.wallet.${gov1Address}.current`,
]);
console.log(resulta);

const resultb = JSON.parse(resulta.value);
const resultc = JSON.parse(resultb.values[0]);
const resultd = JSON.parse(resultc.body.substring(1));
console.log(`purse.balance: `, resultd.purses[0].balance);

let description = 'fail';
for (let i = 0; i < 10; i += 1) {
// eslint-disable-next-line no-await-in-loop
const resulta = await agd.query([
'vstorage',
'data',
`published.wallet.${gov1Address}.current`,
]);
console.log(resulta);

const resultb = JSON.parse(resulta.value);
const resultc = JSON.parse(resultb.values[0]);
const resultd = JSON.parse(resultc.body.substring(1));
console.log(`purse.balance: `, resultd.purses[0].balance);
if (resultd.purses[0].balance.value[0]) {
description = resultd.purses[0].balance.value[0].description;
break;
}
console.log(`waiting for purse update`, i);
waitForBlock(50);
}

assert.equal(
resultd.purses[0].balance.value[0].description,
description,
'Add Collateral',
'invitation purse should not be empty',
);

console.log('✅ invitation purse is not empty');
});
5 changes: 0 additions & 5 deletions a3p-integration/proposals/a:upgrade-14/use.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/bin/bash

source /usr/src/upgrade-test-scripts/env_setup.sh

# UNTIL this is upstream https://github.com/Agoric/agoric-3-proposals/issues/40
# Set to zero so tests don't have to pay gas (we're not testing that)
sed --in-place=.bak s/'minimum-gas-prices = ""'/'minimum-gas-prices = "0ubld,0uist"'/ ~/.agoric/config/app.toml

# wait for wallet repairs
waitForBlock 20
2 changes: 1 addition & 1 deletion packages/smart-wallet/src/smartWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ export const prepareSmartWallet = (baggage, shared) => {
const { invitationPurse, address } = state;

const brandToPurses = getBrandToPurses(walletPurses, self);
trace(`Found ${brandToPurses.values()} purse(s) for ${address}`);
trace(`Found purse(s) for ${address}`);
for (const purses of brandToPurses.values()) {
for (const record of purses) {
void helper.watchPurse(record.purse);
Expand Down

0 comments on commit 5e98f9f

Please sign in to comment.