-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "test: drop or clean-up old Tests"
This reverts commit 6189733.
- Loading branch information
Showing
5 changed files
with
221 additions
and
0 deletions.
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
8 changes: 8 additions & 0 deletions
8
a3p-integration/proposals/a:upgrade-next/priceFeed-follower-auction.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import test from 'ava'; | ||
import { getDetailsMatchingVats } from './vatDetails.js'; | ||
|
||
test('new auction vat', async t => { | ||
const details = await getDetailsMatchingVats('auctioneer'); | ||
// This query matches both the auction and its governor, so 2*2 | ||
t.is(Object.keys(details).length, 4); | ||
}); |
27 changes: 27 additions & 0 deletions
27
a3p-integration/proposals/a:upgrade-next/probeZcfBundleCap.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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import test from 'ava'; | ||
|
||
import { | ||
evalBundles, | ||
getIncarnation, | ||
getVatDetails, | ||
} from '@agoric/synthetic-chain'; | ||
|
||
const SUBMISSION_DIR = 'probe-submission'; | ||
|
||
test('upgrade Zoe to verify ZcfBundleCap endures', async t => { | ||
await null; | ||
t.assert((await getIncarnation('zoe')) === 1, 'zoe incarnation must be one'); | ||
|
||
// Before the test, the Wallet Factory should be using the legacy ZCF | ||
const detailsBefore = await getVatDetails('walletFactory'); | ||
t.true(detailsBefore.incarnation >= 2, 'wf incarnation must be >= 2'); | ||
|
||
await evalBundles(SUBMISSION_DIR); | ||
|
||
const detailsAfter = await getVatDetails('walletFactory'); | ||
t.is( | ||
detailsAfter.incarnation, | ||
detailsBefore.incarnation + 2, | ||
'wf incarnation must increase by 2', | ||
); | ||
}); |
51 changes: 51 additions & 0 deletions
51
a3p-integration/proposals/a:upgrade-next/provisioning.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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// @ts-check | ||
|
||
import test from 'ava'; | ||
import { readFile, writeFile } from 'node:fs/promises'; | ||
|
||
import { | ||
getIncarnation, | ||
getUser, | ||
evalBundles, | ||
waitForBlock, | ||
agoric, | ||
} from '@agoric/synthetic-chain'; | ||
|
||
const SUBMISSION_DIR = 'provisioning-test-submission'; | ||
|
||
/** | ||
* @param {string} fileName base file name without .tjs extension | ||
* @param {Record<string, string>} replacements | ||
*/ | ||
const replaceTemplateValuesInFile = async (fileName, replacements) => { | ||
let script = await readFile(`${fileName}.tjs`, 'utf-8'); | ||
for (const [template, value] of Object.entries(replacements)) { | ||
script = script.replaceAll(`{{${template}}}`, value); | ||
} | ||
await writeFile(`${fileName}.js`, script); | ||
}; | ||
|
||
test.serial(`provisioning vat was upgraded`, async t => { | ||
const incarnation = await getIncarnation('provisioning'); | ||
|
||
t.is(incarnation, 1); | ||
}); | ||
|
||
test.serial(`send invitation via namesByAddress`, async t => { | ||
const addr = await getUser('gov1'); | ||
|
||
await replaceTemplateValuesInFile(`${SUBMISSION_DIR}/send-script`, { | ||
ADDRESS: addr, | ||
}); | ||
|
||
await evalBundles(SUBMISSION_DIR); | ||
|
||
await waitForBlock(2); // enough time for invitation to arrive? | ||
const update = await agoric.follow('-lF', `:published.wallet.${addr}`); | ||
t.is(update.updated, 'balance'); | ||
t.notDeepEqual(update.currentAmount.value, []); | ||
t.log('balance value', update.currentAmount.value); | ||
t.log('balance brand', update.currentAmount.brand); | ||
// XXX agoric follow returns brands as strings | ||
t.regex(update.currentAmount.brand, /Invitation/); | ||
}); |
134 changes: 134 additions & 0 deletions
134
a3p-integration/proposals/a:upgrade-next/upgradeVaults.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 |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import test from 'ava'; | ||
|
||
import { | ||
agops, | ||
ATOM_DENOM, | ||
getISTBalance, | ||
getVatDetails, | ||
openVault, | ||
USER1ADDR, | ||
} from '@agoric/synthetic-chain'; | ||
|
||
import { | ||
addOraclesForBrand, | ||
bankSend, | ||
BID_OFFER_ID, | ||
checkForOracle, | ||
createBid, | ||
getLiveOffers, | ||
getPriceQuote, | ||
pushPrices, | ||
} from './agd-tools.js'; | ||
import { getDetailsMatchingVats } from './vatDetails.js'; | ||
|
||
const checkPriceFeedVatsUpdated = async t => { | ||
const atomDetails = await getVatDetails('ATOM-USD_price_feed'); | ||
// both the original and the new ATOM vault are incarnation 0 | ||
t.is(atomDetails.incarnation, 0); | ||
const stAtomDetails = await getVatDetails('stATOM'); | ||
t.is(stAtomDetails.incarnation, 0); | ||
const stOsmoDetails = await getVatDetails('stOSMO'); | ||
t.is(stOsmoDetails.incarnation, 0); | ||
const stTiaDetails = await getVatDetails('stTIA'); | ||
t.is(stTiaDetails.incarnation, 0); | ||
await Promise.all([ | ||
checkForOracle(t, 'ATOM'), | ||
checkForOracle(t, 'stATOM'), | ||
checkForOracle(t, 'stTIA'), | ||
checkForOracle(t, 'stOSMO'), | ||
checkForOracle(t, 'stkATOM'), | ||
]); | ||
}; | ||
|
||
const oraclesByBrand = new Map(); | ||
|
||
const tryPushPrices = async t => { | ||
// There are no old prices for the other currencies. | ||
const atomOutPre = await getPriceQuote('ATOM'); | ||
t.is(atomOutPre, '+12010000'); | ||
|
||
t.log('adding oracle for each brand'); | ||
await addOraclesForBrand('ATOM', oraclesByBrand); | ||
await addOraclesForBrand('stATOM', oraclesByBrand); | ||
await addOraclesForBrand('stTIA', oraclesByBrand); | ||
await addOraclesForBrand('stOSMO', oraclesByBrand); | ||
await addOraclesForBrand('stkATOM', oraclesByBrand); | ||
|
||
t.log('pushing new prices'); | ||
await pushPrices(11.2, 'ATOM', oraclesByBrand); | ||
await pushPrices(11.3, 'stTIA', oraclesByBrand); | ||
await pushPrices(11.4, 'stATOM', oraclesByBrand); | ||
await pushPrices(11.5, 'stOSMO', oraclesByBrand); | ||
await pushPrices(11.6, 'stkATOM', oraclesByBrand); | ||
|
||
t.log('awaiting new quotes'); | ||
const atomOut = await getPriceQuote('ATOM'); | ||
t.is(atomOut, '+11200000'); | ||
const tiaOut = await getPriceQuote('stTIA'); | ||
t.is(tiaOut, '+11300000'); | ||
const stAtomOut = await getPriceQuote('stATOM'); | ||
t.is(stAtomOut, '+11400000'); | ||
const osmoOut = await getPriceQuote('stOSMO'); | ||
t.is(osmoOut, '+11500000'); | ||
const stkAtomOut = await getPriceQuote('stkATOM'); | ||
t.is(stkAtomOut, '+11600000'); | ||
}; | ||
|
||
const createNewBid = async t => { | ||
await createBid('20', USER1ADDR, BID_OFFER_ID); | ||
const liveOffer = await getLiveOffers(USER1ADDR); | ||
t.true(liveOffer[0].includes(BID_OFFER_ID)); | ||
}; | ||
|
||
const openMarginalVault = async t => { | ||
let user1IST = await getISTBalance(USER1ADDR); | ||
await bankSend(USER1ADDR, `20000000${ATOM_DENOM}`); | ||
const currentVaults = await agops.vaults('list', '--from', USER1ADDR); | ||
|
||
t.log('opening a vault'); | ||
await openVault(USER1ADDR, 5, 10); | ||
user1IST += 5; | ||
const istBalanceAfterVaultOpen = await getISTBalance(USER1ADDR); | ||
t.is(istBalanceAfterVaultOpen, user1IST); | ||
|
||
const activeVaultsAfter = await agops.vaults('list', '--from', USER1ADDR); | ||
t.log(currentVaults, activeVaultsAfter); | ||
t.true( | ||
activeVaultsAfter.length > currentVaults.length, | ||
`vaults count should increase, ${activeVaultsAfter.length}, ${currentVaults.length}`, | ||
); | ||
}; | ||
|
||
const triggerAuction = async t => { | ||
await pushPrices(5.2, 'ATOM', oraclesByBrand); | ||
|
||
const atomOut = await getPriceQuote('ATOM'); | ||
t.is(atomOut, '+5200000'); | ||
}; | ||
|
||
const makeNewAuctionVat = async t => { | ||
const details = await getDetailsMatchingVats('auctioneer'); | ||
// This query matches both the auction and its governor, so double the count | ||
t.true(Object.keys(details).length > 2); | ||
}; | ||
|
||
// test.serial() isn't guaranteed to run tests in order, so we run the intended tests here | ||
test('liquidation post upgrade', async t => { | ||
t.log('starting upgrade vaults test'); | ||
await checkPriceFeedVatsUpdated(t); | ||
|
||
t.log('starting pushPrices'); | ||
await tryPushPrices(t); | ||
|
||
t.log('create a new Bid for the auction'); | ||
await createNewBid(t); | ||
|
||
t.log('open a marginal vault'); | ||
await openMarginalVault(t); | ||
|
||
t.log('trigger Auction'); | ||
await triggerAuction(t); | ||
|
||
t.log('make new auction'); | ||
await makeNewAuctionVat(t); | ||
}); |