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

Fraz/test changes a3p #10281

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
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: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ jobs:
run: yarn build
working-directory: a3p-integration
- name: run proposals tests
run: yarn test
run: yarn test -m z:acceptance
working-directory: a3p-integration
- name: collect all core eval scripts
# Core eval scripts will be copied under /tmp/core_eval_scripts directory
Expand Down
1 change: 1 addition & 0 deletions a3p-integration/proposals/n:upgrade-next/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ add-OLIVES/
upgrade-bank/
upgrade-provisionPool/
upgrade-orch-core/
replace-electorate/
12 changes: 12 additions & 0 deletions a3p-integration/proposals/n:upgrade-next/acceptInvites.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env node

import { agops, GOV1ADDR } from '@agoric/synthetic-chain';

await agops.ec('committee', '--send-from', GOV1ADDR);
await agops.ec(
'charter',
'--send-from',
GOV1ADDR,
'--name',
'econCommitteeCharter',
);
31 changes: 31 additions & 0 deletions a3p-integration/proposals/n:upgrade-next/agoric-tools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { queryVstorage } from '@agoric/synthetic-chain';
import { makeMarshal, Remotable } from '@endo/marshal';

const slotToRemotable = (_slotId, iface = 'Remotable') =>
Remotable(iface, undefined, {
getBoardId: () => _slotId,
});

// /** @param {BoardRemote | object} val */
const boardValToSlot = val => {
if ('getBoardId' in val) {
return val.getBoardId();
}
throw Error(`unknown obj in boardSlottingMarshaller.valToSlot ${val}`);
};

const boardSlottingMarshaller = slotToVal => {
return makeMarshal(boardValToSlot, slotToVal, {
serializeBodyFormat: 'smallcaps',
});
};

export const marshaller = boardSlottingMarshaller(slotToRemotable);

export const queryVstorageFormatted = async (path, index = -1) => {
const data = await queryVstorage(path);

const formattedData = JSON.parse(data.value);
const formattedDataAtIndex = JSON.parse(formattedData.values.at(index));
return marshaller.fromCapData(formattedDataAtIndex);
};
5 changes: 4 additions & 1 deletion a3p-integration/proposals/n:upgrade-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
"vats/upgrade-bank.js upgrade-bank",
"vats/upgrade-provisionPool.js upgrade-provisionPool",
"testing/add-LEMONS.js add-LEMONS",
"testing/add-OLIVES.js add-OLIVES"
"testing/add-OLIVES.js add-OLIVES",
"inter-protocol/replace-electorate-core.js replace-electorate A3P_INTEGRATION"
],
"type": "Software Upgrade Proposal"
},
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"@agoric/synthetic-chain": "^0.3.0",
"@endo/init": "^1.1.5",
"@endo/marshal": "^1.5.4",
"ava": "^5.3.1",
"better-sqlite3": "^9.6.0",
"execa": "^9.3.1"
Expand Down
2 changes: 2 additions & 0 deletions a3p-integration/proposals/n:upgrade-next/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ set -uxeo pipefail
# actions are executed in the previous chain software, and the effects are
# persisted so they can be used in the steps after the upgrade is complete,
# such as in the "use" or "test" steps, or further proposal layers.

echo "FRAZZZZZ"
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import test from 'ava';
import '@endo/init';
import { GOV1ADDR, evalBundles, waitForBlock } from '@agoric/synthetic-chain';
import { passStyleOf } from '@endo/marshal';
import { queryVstorageFormatted } from './agoric-tools.js';

const UPGRADE_PP_DIR = 'replace-electorate';

test.skip('what', async t => {
await evalBundles(UPGRADE_PP_DIR);
await waitForBlock(2);
t.pass();
});

test.serial('should be able to view the new accepted invitations', async t => {
const instance = await queryVstorageFormatted(
`published.agoricNames.instance`,
);
const instances = Object.fromEntries(instance);

const wallet = await queryVstorageFormatted(
`published.wallet.${GOV1ADDR}.current`,
);
const usedInvitations = wallet.offerToUsedInvitation.map(v => v[1]);

const totalCharterInvitations = usedInvitations.filter(
v => v.value[0].description === 'charter member invitation',
).length;

t.is(totalCharterInvitations, 2);

const totalCommitteeInvitations = usedInvitations.filter(v =>
v.value[0].description.startsWith('Voter'),
).length;
t.is(totalCommitteeInvitations, 2);

const charterInvitation = usedInvitations.find(
v =>
v.value[0].instance.getBoardId() ===
instances.econCommitteeCharter.getBoardId(),
);
t.is(passStyleOf(charterInvitation), 'copyRecord');

const committeeInvitation = usedInvitations.find(
v =>
v.value[0].instance.getBoardId() ===
instances.economicCommittee.getBoardId(),
);
t.is(passStyleOf(committeeInvitation), 'copyRecord');
});
9 changes: 5 additions & 4 deletions a3p-integration/proposals/n:upgrade-next/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

GLOBIGNORE=initial.test.js

# test the state right after upgrade
yarn ava initial.test.js
yarn ava ./replaceElectorate.test.js
# # test the state right after upgrade
# yarn ava initial.test.js

# test more, in ways that changes system state
yarn ava ./*.test.js
# # test more, in ways that changes system state
# yarn ava ./*.test.js
6 changes: 6 additions & 0 deletions a3p-integration/proposals/n:upgrade-next/use.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# Exit when any command fails
set -uxeo pipefail

./acceptInvites.js
Loading
Loading