From 441da909af633b93a2f62878b7dbc03f9ee3a5e0 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 27 Nov 2023 14:24:07 -0800 Subject: [PATCH] test(zoe1): opening and closing a bid --- proposals/b:zoe1/post.test.js | 41 ++++++++++++++++++++++++--- upgrade-test-scripts/lib/cliHelper.js | 5 ---- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/proposals/b:zoe1/post.test.js b/proposals/b:zoe1/post.test.js index c62568e3..5fbed5e2 100644 --- a/proposals/b:zoe1/post.test.js +++ b/proposals/b:zoe1/post.test.js @@ -1,6 +1,19 @@ import test from 'ava'; +import { execaCommand } from 'execa'; +import { + agops, + agopsLocation, +} from '../../upgrade-test-scripts/lib/cliHelper.js'; import { getIncarnation } from '../../upgrade-test-scripts/lib/vat-status.js'; -import { agops } from '../../upgrade-test-scripts/lib/cliHelper.js'; + +// TODO migrate into common +/** + * + * @param {string} argvStr + */ +export const execAgops = async argvStr => { + return execaCommand(`${agopsLocation} ${argvStr}`); +}; test(`Zoe vat was upgraded`, async t => { const incarantion = await getIncarnation('zoe'); @@ -15,11 +28,31 @@ test(`Zoe vat was upgraded`, async t => { test('offer stays open after vat-admin restart', async t => { // make an offer that stays open console.log('making an offer that stays open'); - agops.inter('bid by-price --give 1IST --price 30 --from gov1'.split(' ')); + + const openOut = await agops.inter( + ...'bid by-price --give 0.01IST --price 30 --from=gov1 --keyring-backend=test'.split( + ' ', + ), + ); + // example: + // {"timestamp":"2023-11-27T21:43:28Z","height":"1081","offerId":"bid-1701121408756","txhash":"BC23D861CC21C8E5BBF58D135CBB3152DF1CA0904AEF23DA1DD8AD52474AAC20"} + // {"id":"bid-1701121408756","price":"30 IST/ATOM","give":{"Bid":"0.01 IST"},"maxBuy":"1000000 ATOM","result":"Your bid has been accepted"} + const lines = openOut.split('\n'); + const offer = JSON.parse(lines[1]); + t.is(offer.result, 'Your bid has been accepted'); + + // get the id so we can track specifically that ID + console.log('opened bid with offer', offer); + // agd query vstorage data published.wallet.agoric1yjw9dm77gp6zdjulnhqcftuh42nr56czsy2v2u.current --output=json | jq -r ".value|fromjson.values[0]|fromjson.body" | tr "#" " " |jq ".liveOffers|length" // restart the vat-admin vat - console.log('restarting the vat-admin vat'); + console.log('TODO restarting the vat-admin vat'); // make sure the offer is still open - console.log('making sure the offer is still open'); + console.log('canceling bid, to confirm it was still open'); + const cancel = await execAgops( + `inter bid cancel ${offer.id} --from=gov1 --keyring-backend=test`, + ); + t.false(cancel.stderr.includes('not in live offer ids:')); + t.true(cancel.stderr.includes('is no longer live')); }); diff --git a/upgrade-test-scripts/lib/cliHelper.js b/upgrade-test-scripts/lib/cliHelper.js index 39c2329d..cb3c3adf 100644 --- a/upgrade-test-scripts/lib/cliHelper.js +++ b/upgrade-test-scripts/lib/cliHelper.js @@ -81,7 +81,6 @@ export const { stdout: agopsLocation } = await $({ cwd: '/usr/src/agoric-sdk', })`yarn bin agops`; -// TODO use a proxy instead of repeating every command name export const agops = { vaults: async (...params) => { const newParams = ['vaults', ...params]; @@ -112,10 +111,6 @@ export const agops = { const newParams = ['auctioneer', ...params]; return executeCommand(agopsLocation, newParams); }, - inter: async (...params) => { - const newParams = ['inter', ...params]; - return executeCommand(agopsLocation, newParams); - }, }; export const { stdout: bundleSourceLocation } = await $({