Skip to content

Commit

Permalink
test: demo SWINGSET_WORKER_TYPE, computron count
Browse files Browse the repository at this point in the history
in a couple tests:

$ cd agoric-sdk/packages/boot
$ SWINGSET_WORKER_TYPE=xsnap yarn test test/bootstrapTests/price-feed-replace.test.ts
...
  ✔ setupVaults; run updatePriceFeeds proposals (1m 27.6s)
    ℹ setPrice computrons 65536531n

$ SWINGSET_WORKER_TYPE=xsnap yarn test test/bootstrapTests/orchestration.test.ts
...
  ✔ stakeAtom - smart wallet (13.8s)
    ℹ makeAccount computrons 15231491n
  • Loading branch information
dckc committed Nov 22, 2024
1 parent d002646 commit 5e4e8e9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
25 changes: 23 additions & 2 deletions packages/boot/test/bootstrapTests/orchestration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ import {
makeWalletFactoryContext,
type WalletFactoryTestContext,
} from './walletFactory.js';
import { insistManagerType, makePolicyProvider } from '../../tools/supports.js';

const test: TestFn<WalletFactoryTestContext> = anyTest;
const test: TestFn<
WalletFactoryTestContext & {
perfTool?: ReturnType<typeof makePolicyProvider>;
}
> = anyTest;

const validatorAddress: CosmosValidatorAddress = {
value: 'cosmosvaloper1test',
Expand All @@ -22,11 +27,21 @@ const validatorAddress: CosmosValidatorAddress = {

const ATOM_DENOM = 'uatom';

const {
SLOGFILE: slogFile,
SWINGSET_WORKER_TYPE: defaultManagerType = 'local',
} = process.env;

test.before(async t => {
t.context = await makeWalletFactoryContext(
insistManagerType(defaultManagerType);
const perfTool =
defaultManagerType === 'xsnap' ? makePolicyProvider() : undefined;
const ctx = await makeWalletFactoryContext(
t,
'@agoric/vm-config/decentral-itest-orchestration-config.json',
{ slogFile, defaultManagerType, perfTool },
);
t.context = { ...ctx, perfTool };
});
test.after.always(t => t.context.shutdown?.());

Expand Down Expand Up @@ -100,6 +115,7 @@ test.skip('stakeOsmo - queries', async t => {
buildProposal,
evalProposal,
runUtils: { EV },
perfTool,
} = t.context;
await evalProposal(
buildProposal('@agoric/builders/scripts/orchestration/init-stakeOsmo.js'),
Expand Down Expand Up @@ -138,6 +154,7 @@ test.serial('stakeAtom - smart wallet', async t => {
agoricNamesRemotes,
bridgeUtils: { flushInboundQueue },
readPublished,
perfTool,
} = t.context;

await evalProposal(
Expand All @@ -148,6 +165,7 @@ test.serial('stakeAtom - smart wallet', async t => {
'agoric1testStakAtom',
);

perfTool?.usePolicy(true);
await wd.sendOffer({
id: 'request-account',
invitationSpec: {
Expand All @@ -157,6 +175,9 @@ test.serial('stakeAtom - smart wallet', async t => {
},
proposal: {},
});
perfTool && t.log('makeAccount computrons', perfTool.totalCount());
perfTool?.usePolicy(false);

await flushInboundQueue();
t.like(wd.getCurrentWalletRecord(), {
offerToPublicSubscriberPaths: [
Expand Down
4 changes: 4 additions & 0 deletions packages/boot/test/bootstrapTests/price-feed-replace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ test.serial('setupVaults; run updatePriceFeeds proposals', async t => {
setupVaults,
governanceDriver: gd,
readPublished,
perfTool,
} = t.context;

await setupVaults(collateralBrandKey, managerIndex, setup);
Expand All @@ -74,7 +75,10 @@ test.serial('setupVaults; run updatePriceFeeds proposals', async t => {
roundId: 1n,
});

perfTool && perfTool.usePolicy(true);
await priceFeedDrivers[collateralBrandKey].setPrice(15.99);
perfTool && t.log('setPrice computrons', perfTool.totalCount());
perfTool && perfTool.usePolicy(false);

t.like(readPublished('priceFeed.ATOM-USD_price_feed.latestRound'), {
roundId: 2n,
Expand Down

0 comments on commit 5e4e8e9

Please sign in to comment.