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: verify purse balances are updated after smartWallet upgrade #8787

Merged
merged 40 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d06b176
test: verify purse balances are updated after smartWallet upgrade
Chris-Hibbert Feb 9, 2024
d46546d
chore: helpful suggestions from review
Chris-Hibbert Feb 9, 2024
7b59ef4
refactor: testRepairs to Ava test
turadg Feb 9, 2024
2c02ce7
fix(agd): make script more robust
michaelfig Aug 25, 2023
f189969
ci(registry): `set-versions.sh` cwd is already at the target
michaelfig Jan 14, 2024
b050f22
Merge pull request #8256 from Agoric/mfig-tweak-agd
michaelfig Aug 27, 2023
91f32d7
ci(registry): use exact Endo version matches
michaelfig Jan 14, 2024
449b21f
fix(bin-agd): recompile when C++ src changes
michaelfig Jun 29, 2023
1617fee
build(agd): rely on checksums, not timestamps
michaelfig Jan 6, 2024
1e8973b
fix(registry.sh): use `build:types` and `clean:types` if they exist
michaelfig Feb 5, 2024
75b6ad5
build(golang): remove sources when building Docker image
michaelfig Feb 6, 2024
6769b9f
fix(deployment): remove dependency on `HELPER_BINARY`
michaelfig Feb 6, 2024
309f396
Merge pull request #8751 from Agoric/mfig-integration-deps
mergify[bot] Jan 19, 2024
f18c37a
Merge pull request #8715 from Agoric/mfig-build-uses-hashes
mergify[bot] Feb 6, 2024
b960202
chore(a3p): bump synthetic-chain to 0.0.5-2
turadg Feb 8, 2024
4f89742
chore(a3p): bump yarn to 4.1.0
turadg Feb 8, 2024
437a32e
chore(a3p): bump synthetic-chain to 0.0.5-3
turadg Feb 9, 2024
47d053e
ci(integration): fix `agd` wrapper and `Dockerfile.sdk`
michaelfig Feb 7, 2024
f244f9a
chore: remove obsolete issue template
turadg Feb 13, 2024
62a82fd
Merge pull request #8873 from Agoric/ta/bump-a3p
mergify[bot] Feb 9, 2024
9b8632f
ci: delete disabled dapp-fungible-faucet test
turadg Feb 13, 2024
432119c
ci: merge integration branch before endo checkout (#8892)
mhofman Feb 12, 2024
a771135
docs(a3p): UPGRADE NEEDED case
turadg Feb 9, 2024
f604f36
Merge pull request #8899 from Agoric/ta/integration-cleanup
mergify[bot] Feb 13, 2024
50bda55
ci: build sdk in upgrade test for potential proposal uses
mhofman Feb 13, 2024
9b97c03
chore(deps): simplify a3p-integration package
turadg Feb 13, 2024
d1a6683
chore(a3p): bump synthetic-chain to 0.0.6-4
mhofman Feb 13, 2024
448b5e6
test(a3p): restart vats
mhofman Feb 13, 2024
a573d6f
Merge pull request #8801 from Agoric/ta/a3p-coreeval
mergify[bot] Feb 13, 2024
d281be6
fix(a3p-integration): rebuild SDK image automatically
mhofman Feb 15, 2024
78e6d4c
Merge pull request #8907 from Agoric/mhofman/reland-8801
mergify[bot] Feb 13, 2024
2798b83
fixup! fix(a3p-integration): rebuild SDK image automatically
mhofman Feb 18, 2024
2a479eb
docs: detail structure of a3p-integration
mhofman Feb 10, 2024
6fdb83f
Merge pull request #8886 from Agoric/mhofman/clarify-a3p
mergify[bot] Feb 15, 2024
aa952b4
feat(a3p-integration): add core eval in test (#8929)
mhofman Feb 16, 2024
0b2a8a3
fix(a3p): serial test execution (#8940)
mhofman Feb 17, 2024
f6a24a1
Merge branch 'mhofman/cherry-pick-a3p-changes' into 8445-a3p-tests
mhofman Feb 18, 2024
4662b58
chore: rename
Chris-Hibbert Feb 17, 2024
8c4acdf
test: verify purse balances are updated after smartWallet upgrade (#8…
Chris-Hibbert Feb 17, 2024
4c3ecaa
Merge branch 'dev-upgrade-14' into 8445-a3p-tests
mhofman Feb 19, 2024
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
12 changes: 12 additions & 0 deletions a3p-integration/proposals/a:upgrade-14/invite-submission/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
These files enable a test of the walletFactory changes in upgrade-14, by
verifying that upgraded wallets that aren't backed by vbanks can still add
assets, in this case an invitation.

sendInvite is a secondary submission, which is included in ./invite-submission.
The wallet in which we want to deposit the invitation is gov1, whose address
isn't known until run-time. When submitting a proposal using agd.tx(), the
proposal is required to be in a file, so we have to edit a template file
(sendInvite.tpl) to produce the .js file that will be submitted.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(sendInvite.tpl) to produce the .js file that will be submitted.
(sendInvite.template.js) to produce the file that will be submitted.


The core-eval is invoked from the test, which then verifies that the details
were written to vstorage.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// to be replaced before execution
const addr = 'XX_ADDRESS_XX';

// verify that a pre-existing wallet has an invitation purse that is still monitored
const sendInvitation = async powers => {
console.log('sendInvitation start');
// namesByAddress is broken #8113
const {
consume: { namesByAddressAdmin, zoe },
instance: {
consume: { reserve },
},
} = powers;
const pf = E(zoe).getPublicFacet(reserve);
const anInvitation = await E(pf).makeAddCollateralInvitation();

await E(namesByAddressAdmin).reserve(addr);
// don't trigger the namesByAddressAdmin.readonly() bug
const addressAdmin = E(namesByAddressAdmin).lookupAdmin(addr);

await E(addressAdmin).reserve('depositFacet');
const addressHub = E(addressAdmin).readonly();
const addressDepositFacet = E(addressHub).lookup('depositFacet');

await E(addressDepositFacet).receive(anInvitation);
console.log('ADDED an invitation to a purse!');
};

sendInvitation;
4 changes: 4 additions & 0 deletions a3p-integration/proposals/a:upgrade-14/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
source /usr/src/upgrade-test-scripts/env_setup.sh

yarn ava

npm install --global tsx

./testRepairs.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this script would make sense as an Ava test file. probably not worth refactoring at this point tho

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't resist: c45e770

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I adopted that. Thanks. Makes more sense than step().

102 changes: 102 additions & 0 deletions a3p-integration/proposals/a:upgrade-14/testRepairs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/usr/bin/env tsx

import { execFileSync } from 'child_process';
import { readFile, writeFile } from 'fs/promises';

import { makeAgd } from '@agoric/synthetic-chain/src/lib/agd-lib.js';
import {
getUser,
voteLatestProposalAndWait,
} from '@agoric/synthetic-chain/src/lib/commonUpgradeHelpers.js';
import assert from 'assert';

const SUBMISSION_DIR = 'invite-submission';

const staticConfig = {
deposit: '10000000ubld', // 10 BLD
installer: 'gov1', // as in: agd keys show gov1
proposer: 'validator',
collateralPrice: 6, // conservatively low price. TODO: look up
swingstorePath: '~/.agoric/data/agoric/swingstore.sqlite',
};

/** Provide access to the outside world via context. */
const makeContext = async () => {
const config = {
chainId: 'agoriclocal',
...staticConfig,
};

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

return { agd, config };
};

// XXX vestige of Ava
const step = async (name: string, fn: Function) => {
console.log(name);
await fn();
};

const replacePatternInFile = async (fileName, pattern, replacement) => {
const scriptBuffer = await readFile(`${fileName}.template.js`);
const newScript = scriptBuffer.toString().replace(pattern, replacement);
await writeFile(`${fileName}.js`, newScript);
};

await step('verify smartWallet repairs', async () => {
const { agd, config } = await makeContext();
const { chainId, deposit, proposer } = config;
const from = agd.lookup(proposer);

const gov1Address = await getUser('gov1');
await replacePatternInFile(
`${SUBMISSION_DIR}/sendInvite`,
'XX_ADDRESS_XX',
gov1Address,
);

// agd tx gov submit-proposal swingset-core-eval bar.json foo.js
await agd.tx(
[
'gov',
'submit-proposal',
'swingset-core-eval',
`${SUBMISSION_DIR}/sendInvite-permit.json`,
`${SUBMISSION_DIR}/sendInvite.js`,
'--title=sendInvite',
'--description="send an invitation to verify the purse accepts deposits"',
`--deposit=${deposit}`,
'--gas=auto',
'--gas-adjustment=1.2',
'--keyring-backend=test',
],
{ from, chainId, yes: true },
);
await voteLatestProposalAndWait();

// agd query vstorage data published.wallet.$GOV1ADDR.current -o json \
// |& jq '.value | fromjson | .values[0] | fromjson | .body[1:] \
// | fromjson | .purses '
const walletCurrent = await agd.query([
'vstorage',
'data',
`published.wallet.${gov1Address}.current`,
]);

const body = JSON.parse(JSON.parse(walletCurrent.value).values[0]);
const bodyTruncated = JSON.parse(body.body.substring(1));
const invitePurseBalance = bodyTruncated.purses[0].balance;
assert(invitePurseBalance.value[0], 'expecting a non-empty purse');
const description = invitePurseBalance.value[0].description;

assert.equal(
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

This file was deleted.

Loading