Skip to content

Commit

Permalink
test(zoe1): opening and closing a bid
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Dec 6, 2023
1 parent 03e77b6 commit 441da90
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
41 changes: 37 additions & 4 deletions proposals/b:zoe1/post.test.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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'));
});
5 changes: 0 additions & 5 deletions upgrade-test-scripts/lib/cliHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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 $({
Expand Down

0 comments on commit 441da90

Please sign in to comment.