-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: verify purse balances are updated after smartWallet upgrade
- Loading branch information
1 parent
e052586
commit 929c333
Showing
9 changed files
with
180 additions
and
35 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
a3p-integration/proposals/a:upgrade-14/invite-submission/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
This core-eval installs upgrades for the wallet and Zoe. This test verifies 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. | ||
|
||
The core-eval is invoked from the test, which then verifies that the details | ||
were written to vstore. |
1 change: 1 addition & 0 deletions
1
a3p-integration/proposals/a:upgrade-14/invite-submission/sendInvite-permit.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
true |
29 changes: 29 additions & 0 deletions
29
a3p-integration/proposals/a:upgrade-14/invite-submission/sendInvite.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,7 @@ | |
source /usr/src/upgrade-test-scripts/env_setup.sh | ||
|
||
yarn ava | ||
|
||
npm install --global tsx | ||
|
||
./testRepairs.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/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 replaceAddressInFile = async (string, fileName, replacement) => { | ||
const scriptBuffer = await readFile(`${SUBMISSION_DIR}/${fileName}.tpl`); | ||
|
||
const newScript = scriptBuffer.toString().replace(string, replacement); | ||
await writeFile(`${SUBMISSION_DIR}/${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 replaceAddressInFile('XX_ADDRESS_XX', 'sendInvite', 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'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/bash | ||
|
||
# UNTIl this is upstream https://github.com/Agoric/agoric-3-proposals/issues/40 | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters