-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: complete agoric11 and move to agoric12
- Loading branch information
Showing
10 changed files
with
269 additions
and
159 deletions.
There are no files selected for viewing
96 changes: 2 additions & 94 deletions
96
packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/actions.mjs
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,95 +1,3 @@ | ||
import { agd, agops, bundleSource } from "../cliHelper.mjs"; | ||
import { ATOM_DENOM, CHAINID, GOV1ADDR, SDK_ROOT, VALIDATORADDR } from "../constants.mjs"; | ||
import { promises as fs } from 'fs'; | ||
import { openVault, voteLatestProposalAndWait } from './upgradeHelpers.mjs' | ||
import * as path from "path"; | ||
import { dirname } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import { $ } from 'execa'; | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
||
export const installBundles = async (bundlesData) => { | ||
const bundleIds = {}; | ||
await agd.tx("bank", "send", "validator", GOV1ADDR, `12340000000${ATOM_DENOM}`, "--from", VALIDATORADDR, "--chain-id", CHAINID, "--keyring-backend", "test", "--yes"); | ||
await openVault(GOV1ADDR, 10000, 2000); | ||
|
||
for (const bundleData of bundlesData) { | ||
const bundleFilePath = await bundleSource(bundleData.filePath, bundleData.name) | ||
|
||
const bundleJSONData = await fs.readFile( | ||
bundleFilePath, | ||
'binary', | ||
); | ||
|
||
const bundle = JSON.parse(bundleJSONData); | ||
bundleIds[bundleData.name] = bundle.endoZipBase64Sha512; | ||
|
||
await agd.tx("swingset", "install-bundle", `@${bundleFilePath}`, "--from", GOV1ADDR, "--keyring-backend=test", "--gas=auto", "--chain-id", CHAINID, "-bblock", "--yes"); | ||
} | ||
|
||
return bundleIds; | ||
} | ||
|
||
export const runProber = async (bundleId) => { | ||
const proberScriptPath = path.join(__dirname, "zoe-full-upgrade", "run-prober-script.js"); | ||
const proberUpgradePermitPath = path.join(__dirname, "zoe-full-upgrade", "zcf-upgrade-permit.json"); | ||
const filePath = await prepForCoreEval(proberScriptPath, { PROBER_BUNDLE_ID: `b1-${bundleId}` }) | ||
await agd.tx( | ||
"gov", | ||
"submit-proposal", | ||
"swingset-core-eval", | ||
proberUpgradePermitPath, | ||
filePath, | ||
`--title="Run Prober"`, | ||
`--description="run prober"`, | ||
"--deposit=10000000ubld", | ||
"--from", | ||
VALIDATORADDR, | ||
"--keyring-backend=test", | ||
"--gas=auto", | ||
"--gas-adjustment=1.2", | ||
"--chain-id", | ||
CHAINID, | ||
"-bblock", | ||
"--yes"); | ||
|
||
return voteLatestProposalAndWait(); | ||
} | ||
|
||
export const runZcfUpgrade = async (zcfBundleId, zoeBundleId) => { | ||
const zcfScriptPath = path.join(__dirname, "zoe-full-upgrade", "zcf-upgrade-script.js"); | ||
const zcfUpgradePermitPath = path.join(__dirname, "zoe-full-upgrade", "zcf-upgrade-permit.json"); | ||
const filePath = await prepForCoreEval(zcfScriptPath, { ZCF_BUNDLE_ID: `b1-${zcfBundleId}`, ZOE_BUNDLE_ID: `b1-${zoeBundleId}` }) | ||
await agd.tx( | ||
"gov", | ||
"submit-proposal", | ||
"swingset-core-eval", | ||
zcfUpgradePermitPath, | ||
filePath, | ||
`--title="Run Prober"`, | ||
`--description="run prober"`, | ||
"--deposit=10000000ubld", | ||
"--from", | ||
VALIDATORADDR, | ||
"--keyring-backend=test", | ||
"--gas=auto", | ||
"--gas-adjustment=1.2", | ||
"--chain-id", | ||
CHAINID, | ||
"-bblock", | ||
"--yes"); | ||
|
||
return voteLatestProposalAndWait(); | ||
} | ||
|
||
export const prepForCoreEval = async (filePath, constants) => { | ||
let sourceFileData = await fs.readFile(filePath, 'binary'); | ||
|
||
for (const constant in constants) { | ||
sourceFileData = sourceFileData.replace(`##${constant}##`, constants[constant]); | ||
} | ||
|
||
const newFilePath = `/tmp/${path.basename(filePath)}`; | ||
await fs.writeFile(newFilePath, sourceFileData); | ||
return newFilePath; | ||
} | ||
await $({ inherit: false })`agd start --log_level warn` |
65 changes: 12 additions & 53 deletions
65
packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/actions.test.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 |
---|---|---|
@@ -1,64 +1,23 @@ | ||
import test from 'ava'; | ||
|
||
import { adjustVault, closeVault, getUser, openVault } from './upgradeHelpers.mjs'; | ||
import { agd, agoric, agops, bundleSource } from '../cliHelper.mjs'; | ||
import { GOV1ADDR, SDK_ROOT } from '../constants.mjs'; | ||
import { installBundles, runZcfUpgrade, runProber } from './actions.mjs'; | ||
|
||
test.before(async t => { | ||
const bundlesData = [ | ||
{ | ||
name: "Zcf-upgrade", | ||
filePath: `${SDK_ROOT}/packages/zoe/src/contractFacet/vatRoot.js` | ||
}, | ||
{ | ||
name: "Zoe-upgrade", | ||
filePath: `${SDK_ROOT}/packages/vats/src/vat-zoe.js` | ||
}, | ||
{ | ||
name: "prober-contract", | ||
filePath: `${SDK_ROOT}/packages/boot/test/bootstrapTests/zcfProbe.js` | ||
}, | ||
] | ||
|
||
t.context.bundleIds = await installBundles(bundlesData); | ||
}); | ||
import { adjustVault, closeVault, openVault } from './upgradeHelpers.mjs'; | ||
import { agoric, agops } from '../cliHelper.mjs'; | ||
import { GOV1ADDR } from '../constants.mjs'; | ||
|
||
test.serial('Open Vaults', async t => { | ||
const currentVaults = await agops.vaults('list', '--from', GOV1ADDR); | ||
t.is(currentVaults.length, 3); | ||
t.is(currentVaults.length, 2); | ||
|
||
await openVault(GOV1ADDR, 7, 11); | ||
await adjustVault(GOV1ADDR, 'vault4', { giveMinted: 1.5 }); | ||
await adjustVault(GOV1ADDR, 'vault4', { giveCollateral: 2.0 }); | ||
await closeVault(GOV1ADDR, 'vault4', 5.75); | ||
await adjustVault(GOV1ADDR, 'vault3', { giveMinted: 1.5 }); | ||
await adjustVault(GOV1ADDR, 'vault3', { giveCollateral: 2.0 }); | ||
await closeVault(GOV1ADDR, 'vault3', 5.75); | ||
|
||
const vault4 = await agoric.follow( | ||
const vault3 = await agoric.follow( | ||
'-lF', | ||
':published.vaultFactory.managers.manager0.vaults.vault4', | ||
':published.vaultFactory.managers.manager0.vaults.vault3', | ||
); | ||
t.is(vault4.vaultState, 'closed'); | ||
t.is(vault4.locked.value, '0'); | ||
t.is(vault4.debtSnapshot.debt.value, '0'); | ||
}); | ||
|
||
test.serial("Run Prober (first time)", async t => { | ||
await runProber(t.context.bundleIds["prober-contract"]) | ||
const data = await agd.query("vstorage", "data", "published.prober-asid9a"); | ||
const value = JSON.parse(data.value); | ||
t.is(value.values[0], "false"); | ||
}); | ||
|
||
test.serial("Upgrade Zoe and ZCF", async t => { | ||
await runZcfUpgrade(t.context.bundleIds["Zcf-upgrade"], t.context.bundleIds["Zoe-upgrade"]) | ||
|
||
t.pass() | ||
}); | ||
|
||
test.serial("Run Prober (second time)", async t => { | ||
await runProber(t.context.bundleIds["prober-contract"]) | ||
|
||
const data = await agd.query("vstorage", "data", "published.prober-asid9a"); | ||
const value = JSON.parse(data.value); | ||
t.is(value.values[0], "true"); | ||
t.is(vault3.vaultState, 'closed'); | ||
t.is(vault3.locked.value, '0'); | ||
t.is(vault3.debtSnapshot.debt.value, '0'); | ||
}); |
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
6 changes: 2 additions & 4 deletions
6
packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/post.test.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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import test from 'ava'; | ||
import { main } from './vat-status.mjs'; | ||
|
||
test(`Verify Zoe vat incarnatin`, async t => { | ||
const incarantion = await main("zoe"); | ||
t.is(incarantion, 1) | ||
test(`Replace me`, async t => { | ||
t.pass() | ||
}); |
8 changes: 1 addition & 7 deletions
8
packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/pre.test.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
95 changes: 95 additions & 0 deletions
95
packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/actions.mjs
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,95 @@ | ||
import { agd, agops, bundleSource } from "../cliHelper.mjs"; | ||
import { ATOM_DENOM, CHAINID, GOV1ADDR, SDK_ROOT, VALIDATORADDR } from "../constants.mjs"; | ||
import { promises as fs } from 'fs'; | ||
import { openVault, voteLatestProposalAndWait } from '../coreUpgradeHelpers.mjs' | ||
import * as path from "path"; | ||
import { dirname } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
||
export const installBundles = async (bundlesData) => { | ||
const bundleIds = {}; | ||
await agd.tx("bank", "send", "validator", GOV1ADDR, `12340000000${ATOM_DENOM}`, "--from", VALIDATORADDR, "--chain-id", CHAINID, "--keyring-backend", "test", "--yes"); | ||
await openVault(GOV1ADDR, 10000, 2000); | ||
|
||
for (const bundleData of bundlesData) { | ||
const bundleFilePath = await bundleSource(bundleData.filePath, bundleData.name) | ||
|
||
const bundleJSONData = await fs.readFile( | ||
bundleFilePath, | ||
'binary', | ||
); | ||
|
||
const bundle = JSON.parse(bundleJSONData); | ||
bundleIds[bundleData.name] = bundle.endoZipBase64Sha512; | ||
|
||
await agd.tx("swingset", "install-bundle", `@${bundleFilePath}`, "--from", GOV1ADDR, "--keyring-backend=test", "--gas=auto", "--chain-id", CHAINID, "-bblock", "--yes"); | ||
} | ||
|
||
return bundleIds; | ||
} | ||
|
||
export const runProber = async (bundleId) => { | ||
const proberScriptPath = path.join(__dirname, "zoe-full-upgrade", "run-prober-script.js"); | ||
const proberUpgradePermitPath = path.join(__dirname, "zoe-full-upgrade", "zcf-upgrade-permit.json"); | ||
const filePath = await prepForCoreEval(proberScriptPath, { PROBER_BUNDLE_ID: `b1-${bundleId}` }) | ||
await agd.tx( | ||
"gov", | ||
"submit-proposal", | ||
"swingset-core-eval", | ||
proberUpgradePermitPath, | ||
filePath, | ||
`--title="Run Prober"`, | ||
`--description="run prober"`, | ||
"--deposit=10000000ubld", | ||
"--from", | ||
VALIDATORADDR, | ||
"--keyring-backend=test", | ||
"--gas=auto", | ||
"--gas-adjustment=1.2", | ||
"--chain-id", | ||
CHAINID, | ||
"-bblock", | ||
"--yes"); | ||
|
||
return voteLatestProposalAndWait(); | ||
} | ||
|
||
export const runZcfUpgrade = async (zcfBundleId, zoeBundleId) => { | ||
const zcfScriptPath = path.join(__dirname, "zoe-full-upgrade", "zcf-upgrade-script.js"); | ||
const zcfUpgradePermitPath = path.join(__dirname, "zoe-full-upgrade", "zcf-upgrade-permit.json"); | ||
const filePath = await prepForCoreEval(zcfScriptPath, { ZCF_BUNDLE_ID: `b1-${zcfBundleId}`, ZOE_BUNDLE_ID: `b1-${zoeBundleId}` }) | ||
await agd.tx( | ||
"gov", | ||
"submit-proposal", | ||
"swingset-core-eval", | ||
zcfUpgradePermitPath, | ||
filePath, | ||
`--title="Run Prober"`, | ||
`--description="run prober"`, | ||
"--deposit=10000000ubld", | ||
"--from", | ||
VALIDATORADDR, | ||
"--keyring-backend=test", | ||
"--gas=auto", | ||
"--gas-adjustment=1.2", | ||
"--chain-id", | ||
CHAINID, | ||
"-bblock", | ||
"--yes"); | ||
|
||
return voteLatestProposalAndWait(); | ||
} | ||
|
||
export const prepForCoreEval = async (filePath, constants) => { | ||
let sourceFileData = await fs.readFile(filePath, 'binary'); | ||
|
||
for (const constant in constants) { | ||
sourceFileData = sourceFileData.replace(`##${constant}##`, constants[constant]); | ||
} | ||
|
||
const newFilePath = `/tmp/${path.basename(filePath)}`; | ||
await fs.writeFile(newFilePath, sourceFileData); | ||
return newFilePath; | ||
} |
Oops, something went wrong.