Skip to content

Commit

Permalink
test(a3p): create a3p test for replace electorate core eval (#10241)
Browse files Browse the repository at this point in the history
closes: #10138 
closes: #10185 
closes: #10258
## Description

A3P tests for the replace electorate core eval. also adds the replace-electorate-core.js script to upgrade.go since it will now be a part of the chain halting upgrade

new tests are as follows:
- adds new `n:replace-electorate` which tests for acceptance of new invitations
- adds params governance proposal and voting tests to `z:acceptance`

### Security Considerations


### Scaling Considerations


### Documentation Considerations


### Testing Considerations


### Upgrade Considerations
  • Loading branch information
mergify[bot] authored Oct 24, 2024
2 parents 91a5ada + f406d25 commit a67502b
Show file tree
Hide file tree
Showing 22 changed files with 697 additions and 98 deletions.
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/
19 changes: 19 additions & 0 deletions a3p-integration/proposals/n:upgrade-next/acceptInvites.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env node
import '@endo/init';
import { agops, GOV1ADDR, GOV2ADDR } from '@agoric/synthetic-chain';
import { GOV4ADDR } from './agoric-tools.js';

// New GOV4 account to be added
const addresses = [GOV1ADDR, GOV2ADDR, GOV4ADDR];

await Promise.all(
addresses.map((addr, idx) =>
agops.ec('committee', '--send-from', addr, '--voter', `${idx}`),
),
);

await Promise.all(
addresses.map(addr =>
agops.ec('charter', '--send-from', addr, '--name', 'econCommitteeCharter'),
),
);
20 changes: 20 additions & 0 deletions a3p-integration/proposals/n:upgrade-next/addGov4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import '@endo/init';
import { execFileSync } from 'node:child_process';
import { makeAgd } from './synthetic-chain-excerpt.js';
import { GOV4ADDR } from './agoric-tools.js';

const agd = makeAgd({ execFileSync }).withOpts({ keyringBackend: 'test' });

agd.keys.add(
'gov4',
'smile unveil sketch gaze length bulb goddess street case exact table fetch robust chronic power choice endorse toward pledge dish access sad illegal dance',
);

agd.tx(
['swingset', 'provision-one', 'faucet_provision', GOV4ADDR, 'SMART_WALLET'],
{
chainId: 'agoriclocal',
from: 'validator',
yes: true,
},
);
33 changes: 33 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,33 @@
import { queryVstorage } from '@agoric/synthetic-chain';
import { makeMarshal, Remotable } from '@endo/marshal';

export const GOV4ADDR = 'agoric1c9gyu460lu70rtcdp95vummd6032psmpdx7wdy';

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
35 changes: 35 additions & 0 deletions a3p-integration/proposals/n:upgrade-next/replaceElectorate.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import test from 'ava';
import '@endo/init';
import { GOV1ADDR, GOV2ADDR } from '@agoric/synthetic-chain';
import { passStyleOf } from '@endo/marshal';
import { GOV4ADDR, queryVstorageFormatted } from './agoric-tools.js';

const governanceAddresses = [GOV4ADDR, GOV2ADDR, GOV1ADDR];

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);

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

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');
}
});
2 changes: 2 additions & 0 deletions a3p-integration/proposals/n:upgrade-next/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

GLOBIGNORE=initial.test.js

yarn ava ./replaceElectorate.test.js

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

Expand Down
7 changes: 7 additions & 0 deletions a3p-integration/proposals/n:upgrade-next/use.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Exit when any command fails
set -uxeo pipefail

node ./addGov4
./acceptInvites.js
Loading

0 comments on commit a67502b

Please sign in to comment.