-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: a docker test for the zoe/zcf upgrade
- Loading branch information
1 parent
606ad23
commit bb381af
Showing
6 changed files
with
150 additions
and
1 deletion.
There are no files selected for viewing
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
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
...-test/upgrade-test-scripts/agoric-upgrade-11/zoe-full-upgrade/prober-contract-bundle.json
Large diffs are not rendered by default.
Oops, something went wrong.
114 changes: 114 additions & 0 deletions
114
...pgrade-test/upgrade-test-scripts/agoric-upgrade-11/zoe-full-upgrade/zcf-upgrade-script.js
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,114 @@ | ||
// to turn on ts-check: | ||
import { E } from '@endo/far'; | ||
|
||
const PROBER_BUNDLE_ID = | ||
'b1-746e2e9b141928ccee0cd5e0aca730128d9e9552b9cf585db7c6c7729d675f8c88822d2e067413a80c4d122ba2526158447089f44578af85211c05371e287e42'; | ||
const ZCF_BUNDLE_ID = | ||
'b1-8674abc9a8de561c4a33fb475b87be75708cd901c37931fd5ac1f40d3ee99937a459a6ca7b4a8b7907512626caf98c125f22c15384826e37dfc899dc0bf2a63a'; | ||
const ZOE_BUNDLE_ID = | ||
'b1-68963663488ee6d178293b559b9d902cea1857dddac257f08540cb9748647d0218a991ce02cf9f61e1e49cca3979b20473103a7fee509cf808de43e323afab54'; | ||
|
||
console.info('zoe upgrade: evaluating script'); | ||
|
||
const sub = (a, v) => { | ||
return { brand: a.brand, value: a.value - v }; | ||
}; | ||
|
||
const probeReallocation = async (value, payment, creatorFacet, zoe) => { | ||
const stagingInv = await E(creatorFacet).makeProbeStagingInvitation(); | ||
|
||
const stagingSeat = await E(zoe).offer( | ||
stagingInv, | ||
{ give: { Ducats: value } }, | ||
{ Ducats: payment }, | ||
); | ||
const helperPayments = await E(stagingSeat).getPayouts(); | ||
|
||
const helperInv = await E(creatorFacet).makeProbeHelperInvitation(); | ||
const helperSeat = await E(zoe).offer( | ||
helperInv, | ||
{ give: { Ducats: sub(value, 1n) } }, | ||
{ Ducats: helperPayments.Ducats }, | ||
); | ||
const internalPayments = await E(helperSeat).getPayouts(); | ||
|
||
const internalInv = await E(creatorFacet).makeProbeInternalInvitation(); | ||
const internalSeat = await E(zoe).offer( | ||
internalInv, | ||
{ give: { Ducats: sub(value, 2n) } }, | ||
{ Ducats: internalPayments.Ducats }, | ||
); | ||
const leftoverPayments = await E(internalSeat).getPayouts(); | ||
|
||
return { | ||
stagingResult: await E(stagingSeat).getOfferResult(), | ||
helperResult: await E(helperSeat).getOfferResult(), | ||
internalResult: await E(internalSeat).getOfferResult(), | ||
leftoverPayments, | ||
}; | ||
}; | ||
|
||
/** | ||
* Test a full upgrade of Zzoe and ZCF. | ||
* This will include a change to Zoe's code, and a call to Zoe to change the ZCF | ||
* code that will get used for new and upgraded contracts. | ||
*/ | ||
const upgradeZoeAndZcf = async powers => { | ||
console.info('upgradeZoeAndZcf'); | ||
const { | ||
consume: { vatStore, vatAdminSvc, zoe }, | ||
} = powers; | ||
|
||
const installation = await E(zoe).installBundleID(PROBER_BUNDLE_ID); | ||
const { creatorFacet, adminFacet: proberAdminFacet } = await E( | ||
zoe, | ||
).startInstance(installation); | ||
|
||
const issuers = await E(zoe).getIssuers( | ||
( | ||
await E(zoe).startInstance(installation) | ||
).instance, | ||
); | ||
const brands = await E(zoe).getBrands( | ||
( | ||
await E(zoe).startInstance(installation) | ||
).instance, | ||
); | ||
|
||
const faucetInv = await E(creatorFacet).makeFaucetInvitation(); | ||
const seat = await E(zoe).offer(faucetInv); | ||
const payoutDucats = await E(seat).getPayout('Ducats'); | ||
const initialAmount = await E(issuers.Ducats).getAmountOf(payoutDucats); | ||
|
||
// CHECK BEHAVIOR BEFORE UPGRADE //////////////////// | ||
const result1 = probeReallocation( | ||
initialAmount, | ||
payoutDucats, | ||
creatorFacet, | ||
zoe, | ||
); | ||
console.info(result1); | ||
|
||
const newZoeBundleCap = await E(vatAdminSvc).getBundleCap(ZOE_BUNDLE_ID); | ||
const { adminNode, zoeRoot } = await E(vatStore).get('zoe'); | ||
console.info('restartZoe', { adminNode, newZoeBundleCap, zoeRoot }); | ||
|
||
const result = await E(adminNode).upgrade(newZoeBundleCap, {}); | ||
|
||
const zoeConfigFacet = await E(zoeRoot).getZoeConfigFacet(); | ||
await E(zoeConfigFacet).updateZcfBundleId(ZCF_BUNDLE_ID); | ||
console.info('restartZoe', { result }); | ||
|
||
await E(proberAdminFacet).upgradeContract(PROBER_BUNDLE_ID); | ||
|
||
// CHECK BEHAVIOR AFTER UPGRADE //////////////////// | ||
const result2 = probeReallocation( | ||
initialAmount, | ||
payoutDucats, | ||
creatorFacet, | ||
zoe, | ||
); | ||
console.info(result2); | ||
}; | ||
|
||
upgradeZoeAndZcf; |
30 changes: 30 additions & 0 deletions
30
...e-test/upgrade-test-scripts/agoric-upgrade-11/zoe-full-upgrade/zoe-full-upgrade-driver.sh
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,30 @@ | ||
#!/bin/bash | ||
|
||
. ./upgrade-test-scripts/env_setup.sh | ||
|
||
set -euo pipefail | ||
|
||
here='upgrade-test-scripts/agoric-upgrade-11/zoe-upgrade' | ||
|
||
for f in "$dir"/*.json; do | ||
agd tx swingset install-bundle "@$f" \ | ||
--from gov1 --keyring-backend=test --gas=auto \ | ||
--chain-id=agoriclocal -bblock --yes | ||
done | ||
|
||
|
||
|
||
agd --chain-id=agoriclocal \ | ||
tx gov submit-proposal swingset-core-eval \ | ||
${here}/zoe-upgrade-permit.json ${here}/zoe-upgrade-script.js \ | ||
--title="Zoe Upgrade" --description="zoe upgrade test" \ | ||
--deposit=10000000ubld \ | ||
--gas=auto --gas-adjustment=1.2 \ | ||
--yes -o json --from=validator --keyring-backend=test -b block | ||
|
||
agd --chain-id=agoriclocal query gov proposals --output json | \ | ||
jq -c '.proposals[] | [.proposal_id,.voting_end_time,.status]'; | ||
|
||
voteLatestProposalAndWait | ||
|
||
# then tes some stuff??? |