Skip to content

Commit

Permalink
refactor: vm-config for orchestration
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jun 10, 2024
1 parent 5913d8f commit 5d4b6fd
Show file tree
Hide file tree
Showing 7 changed files with 301 additions and 32 deletions.
21 changes: 8 additions & 13 deletions packages/boot/test/bootstrapTests/lca.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import {

const test: TestFn<WalletFactoryTestContext> = anyTest;

test.before(async t => (t.context = await makeWalletFactoryContext(t)));
test.before(async t => {
t.context = await makeWalletFactoryContext(
t,
'@agoric/vm-config/decentral-itest-orchestration-config.json',
);
});
test.after.always(t => t.context.shutdown?.());

test.serial('stakeBld', async t => {
Expand All @@ -22,21 +27,11 @@ test.serial('stakeBld', async t => {
evalProposal,
refreshAgoricNamesRemotes,
} = t.context;
// TODO move into a vm-config for u15
await evalProposal(
buildProposal('@agoric/builders/scripts/vats/init-localchain.js'),
);

// start-stakeBld depends on this. Sanity check in case the context changes.
const { BLD } = agoricNamesRemotes.brand;
BLD || Fail`BLD missing from agoricNames`;
// TODO instead use orchestration vm-config
await evalProposal(
buildProposal('@agoric/builders/scripts/vats/init-localchain.js'),
);
// for chainInfo
await evalProposal(
buildProposal('@agoric/builders/scripts/vats/init-orchestration.js'),
);

await evalProposal(
buildProposal('@agoric/builders/scripts/orchestration/init-stakeBld.js'),
);
Expand Down
24 changes: 9 additions & 15 deletions packages/boot/test/bootstrapTests/orchestration.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import type { TestFn } from 'ava';

import { Fail } from '@agoric/assert';
import { AmountMath } from '@agoric/ertp';
import type { Instance } from '@agoric/zoe/src/zoeService/utils.js';
import { M, matches } from '@endo/patterns';
import type { CosmosValidatorAddress } from '@agoric/orchestration';
import type { start as startStakeAtom } from '@agoric/orchestration/src/examples/stakeAtom.contract.js';
import type { Instance } from '@agoric/zoe/src/zoeService/utils.js';
import { M, matches } from '@endo/patterns';
import type { TestFn } from 'ava';
import {
makeWalletFactoryContext,
type WalletFactoryTestContext,
} from './walletFactory.ts';

const test: TestFn<WalletFactoryTestContext> = anyTest;

test.before(async t => (t.context = await makeWalletFactoryContext(t)));
test.before(async t => {
t.context = await makeWalletFactoryContext(
t,
'@agoric/vm-config/decentral-itest-orchestration-config.json',
);
});
test.after.always(t => t.context.shutdown?.());

/**
Expand Down Expand Up @@ -44,10 +48,6 @@ test.serial('stakeAtom - repl-style', async t => {
evalProposal,
runUtils: { EV },
} = t.context;
// TODO move into a vm-config for future agoric-upgrade
await evalProposal(
buildProposal('@agoric/builders/scripts/vats/init-orchestration.js'),
);
await evalProposal(
buildProposal('@agoric/builders/scripts/orchestration/init-stakeAtom.js'),
);
Expand All @@ -58,12 +58,6 @@ test.serial('stakeAtom - repl-style', async t => {
).lookup('instance', 'stakeAtom');
t.truthy(instance, 'stakeAtom instance is available');

const cosmosChainInfo = await EV(agoricNames).lookup('chain', 'cosmos');
t.like(cosmosChainInfo, {
chainId: 'cosmoshub-4',
stakingTokens: [{ denom: 'uatom' }],
});

const zoe: ZoeService = await EV.vat('bootstrap').consumeItem('zoe');
const publicFacet = await EV(zoe).getPublicFacet(instance);
t.truthy(publicFacet, 'stakeAtom publicFacet is available');
Expand Down
150 changes: 150 additions & 0 deletions packages/boot/test/bootstrapTests/snapshots/orchestration.test.ts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# Snapshot report for `test/bootstrapTests/orchestration.test.ts`

The actual snapshot is saved in `orchestration.test.ts.snap`.

Generated by [AVA](https://avajs.dev).

## config

> Snapshot 1
[
[
'agoric',
{
chainId: 'agoriclocal',
connections: {
cosmoslocal: {
client_id: '07-tendermint-3',
counterparty: {
client_id: '07-tendermint-2',
connection_id: 'connection-1',
prefix: {
key_prefix: '',
},
},
delay_period: 0n,
id: 'connection-1',
state: 3,
transferChannel: {
channelId: 'channel-1',
counterPartyChannelId: 'channel-1',
counterPartyPortId: 'transfer',
ordering: 1,
portId: 'transfer',
state: 3,
version: 'ics20-1',
},
versions: [
{
features: [
'',
'',
],
identifier: '',
},
],
},
osmosislocal: {
client_id: '07-tendermint-2',
counterparty: {
client_id: '07-tendermint-2',
connection_id: 'connection-1',
prefix: {
key_prefix: '',
},
},
delay_period: 0n,
id: 'connection-0',
state: 3,
transferChannel: {
channelId: 'channel-0',
counterPartyChannelId: 'channel-1',
counterPartyPortId: 'transfer',
ordering: 1,
portId: 'transfer',
state: 3,
version: 'ics20-1',
},
versions: [
{
features: [
'',
'',
],
identifier: '',
},
],
},
},
ibcHooksEnabled: true,
icaEnabled: true,
icqEnabled: true,
pfmEnabled: true,
},
],
[
'celestia',
{
chainId: 'celestia',
connections: {},
ibcHooksEnabled: true,
icaEnabled: true,
icqEnabled: true,
pfmEnabled: true,
stakingTokens: [
{
denom: 'utia',
},
],
},
],
[
'cosmos',
{
chainId: 'cosmoslocal',
connections: {},
ibcHooksEnabled: true,
icaEnabled: true,
icqEnabled: true,
pfmEnabled: true,
stakingTokens: [
{
denom: 'uatom',
},
],
},
],
[
'osmosis',
{
chainId: 'osmosislocal',
connections: {},
ibcHooksEnabled: true,
icaEnabled: true,
icqEnabled: true,
pfmEnabled: true,
stakingTokens: [
{
denom: 'uosmo',
},
],
},
],
[
'stride',
{
chainId: 'stride-1',
connections: {},
ibcHooksEnabled: true,
icaEnabled: true,
icqEnabled: true,
pfmEnabled: true,
stakingTokens: [
{
denom: 'ustride',
},
],
},
],
]
Binary file not shown.
7 changes: 5 additions & 2 deletions packages/boot/test/bootstrapTests/walletFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import { makeWalletFactoryDriver } from '../../tools/drivers.ts';

const { Fail } = assert;

export const makeWalletFactoryContext = async t => {
export const makeWalletFactoryContext = async (
t,
configSpecifier = '@agoric/vm-config/decentral-main-vaults-config.json',
) => {
const swingsetTestKit = await makeSwingsetTestKit(
t.log,
'bundles/walletFactory',
{
configSpecifier: '@agoric/vm-config/decentral-main-vaults-config.json',
configSpecifier,
},
);

Expand Down
129 changes: 129 additions & 0 deletions packages/vm-config/decentral-itest-orchestration-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
"$comment": "This SwingSet config file (see loadSwingsetConfigFile) is designed to bring up vats to test Orchestration. Comapre with decentral-itest-vaults-config.json.",
"bootstrap": "bootstrap",
"defaultReapInterval": 1000,
"coreProposals": [
"@agoric/builders/scripts/vats/init-core.js",
"@agoric/builders/scripts/vats/init-network.js",
"@agoric/builders/scripts/vats/init-localchain.js",
"@agoric/builders/scripts/vats/init-transfer.js",
"@agoric/builders/scripts/vats/init-orchestration.js",
{
"module": "@agoric/builders/scripts/inter-protocol/init-core.js",
"entrypoint": "defaultProposalBuilder",
"args": [
{
"econCommitteeOptions": {
"committeeSize": 3
},
"referencedUi": "bafybeidvpbtlgefi3ptuqzr2fwfyfjqfj6onmye63ij7qkrb4yjxekdh3e",
"minInitialPoolLiquidity": "0"
}
]
},
{
"module": "@agoric/builders/scripts/inter-protocol/add-collateral-core.js",
"entrypoint": "defaultProposalBuilder",
"args": [
{
"interestRateValue": 1000,
"interchainAssetOptions": {
"denom": "ibc/toyatom",
"decimalPlaces": 6,
"initialPrice": 12.34,
"keyword": "ATOM",
"oracleBrand": "ATOM",
"proposedName": "ATOM"
}
}
]
},
{
"module": "@agoric/builders/scripts/inter-protocol/add-collateral-core.js",
"entrypoint": "psmProposalBuilder",
"args": [
{
"anchorOptions": {
"denom": "ibc/toyusdc",
"decimalPlaces": 6,
"keyword": "USDC_axl",
"proposedName": "USD Coin"
}
}
]
},
{
"$comment": "XXX orchesration works without oracles but some test setup dependency fails to resolve without this",
"module": "@agoric/builders/scripts/inter-protocol/price-feed-core.js",
"entrypoint": "defaultProposalBuilder",
"args": [
{
"AGORIC_INSTANCE_NAME": "ATOM-USD price feed",
"oracleAddresses": [
"@PRIMARY_ADDRESS@",
"agoric1dy0yegdsev4xvce3dx7zrz2ad9pesf5svzud6y"
],
"IN_BRAND_LOOKUP": [
"agoricNames",
"oracleBrand",
"ATOM"
],
"IN_BRAND_DECIMALS": 6,
"OUT_BRAND_LOOKUP": [
"agoricNames",
"oracleBrand",
"USD"
],
"OUT_BRAND_DECIMALS": 4
}
]
}
],
"vats": {
"bootstrap": {
"sourceSpec": "@agoric/vats/src/core/boot-chain.js",
"creationOptions": {
"critical": true
}
}
},
"bundles": {
"agoricNames": {
"sourceSpec": "@agoric/vats/src/vat-agoricNames.js"
},
"bank": {
"sourceSpec": "@agoric/vats/src/vat-bank.js"
},
"board": {
"sourceSpec": "@agoric/vats/src/vat-board.js"
},
"bridge": {
"sourceSpec": "@agoric/vats/src/vat-bridge.js"
},
"centralSupply": {
"sourceSpec": "@agoric/vats/src/centralSupply.js"
},
"mintHolder": {
"sourceSpec": "@agoric/vats/src/mintHolder.js"
},
"priceAuthority": {
"sourceSpec": "@agoric/vats/src/vat-priceAuthority.js"
},
"provisionPool": {
"sourceSpec": "@agoric/inter-protocol/src/provisionPool.js"
},
"provisioning": {
"sourceSpec": "@agoric/vats/src/vat-provisioning.js"
},
"walletFactory": {
"sourceSpec": "@agoric/smart-wallet/src/walletFactory.js"
},
"zcf": {
"sourceSpec": "@agoric/zoe/contractFacet.js"
},
"zoe": {
"sourceSpec": "@agoric/vats/src/vat-zoe.js"
}
},
"defaultManagerType": "xs-worker"
}
Loading

0 comments on commit 5d4b6fd

Please sign in to comment.