Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test of zoe1 offer robustness #31

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ function readInfo(proposalPath: string): ProposalInfo {
const packageJsonPath = path.join('proposals', proposalPath, 'package.json');
const packageJson = fs.readFileSync(packageJsonPath, 'utf-8');
const { agoricProposal } = JSON.parse(packageJson);
// TODO mustMatch a shape
assert(agoricProposal, 'missing agoricProposal in package.json');
const [proposalIdentifier, proposalName] = proposalPath.split(':');
return {
...agoricProposal,
Expand Down
2 changes: 1 addition & 1 deletion debugTestImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To get an interactive shell in the container, use an IDE feature like "Attach Sh
docker exec -ti $(docker ps -q -f ancestor=${name}) bash

And within that shell:
cd /usr/src/proposals/<PROPOSAL_PATH> && ./test.sh
cd /usr/src/proposals/${proposal.proposalIdentifier}:${proposal.proposalName} && ./test.sh

The 'proposals' path is mounted in the container so your edits will appear there.
`,
Expand Down
9 changes: 9 additions & 0 deletions proposals/49:smart-wallet-nft/test.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@ testMinChildren() {
testMinChildren published.boardAux 3

# TODO trade game asset

# Check that gov1's bid from upgrade-10 use is still live
ADDR=$(agd keys show --address gov1 --keyring-backend=test)
agd query vstorage data published.wallet.$ADDR.current --output=json | jq -r ".value|fromjson.values[0]|fromjson.body" | tr "#" " " | jq .liveOffers >liveOffers.json
echo Live offers:
jq <liveOffers.json
grep "bid-" liveOffers.json
# bid-<timestamp> from upgrade-10 and a closeVault-<timestamp> that hasn't completed
test_val $(jq '.|length' <liveOffers.json) 2 "gov1 live offers"
50 changes: 50 additions & 0 deletions proposals/b:zoe1/post.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,57 @@
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';

// 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');
t.is(incarantion, 1);
});

/**
* 1. make a new offer that stays open
* 2. restart the vat-admin vat
* 3. make sure the offer is still open
*/
test('offer stays open after vat-admin restart', async t => {
// XXX consider reusing bid-1701709689406 from upgrade-10
// make an offer that stays open.
console.log('making an offer that stays open');

const openOut = await execAgops(
'inter bid by-price --give 0.01IST --price 30 --from=gov1 --keyring-backend=test',
);
// 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('TODO restarting the vat-admin vat');

// make 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'));
});
6 changes: 0 additions & 6 deletions proposals/b:zoe1/use.sh

This file was deleted.

Loading