-
Notifications
You must be signed in to change notification settings - Fork 208
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
Changes from 2 commits
d06b176
d46546d
7b59ef4
2c02ce7
f189969
b050f22
91f32d7
449b21f
1617fee
1e8973b
75b6ad5
6769b9f
309f396
f18c37a
b960202
4f89742
437a32e
47d053e
f244f9a
62a82fd
9b8632f
432119c
a771135
f604f36
50bda55
9b97c03
d1a6683
448b5e6
a573d6f
d281be6
78e6d4c
2798b83
2a479eb
6fdb83f
aa952b4
0b2a8a3
f6a24a1
4662b58
8c4acdf
4c3ecaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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. | ||
|
||
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; |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't resist: c45e770 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I adopted that. Thanks. Makes more sense than |
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'); | ||
}); |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.