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 Dec 2, 2024
1 parent 0bbf639 commit 19ae5da
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
28 changes: 26 additions & 2 deletions packages/boot/test/bootstrapTests/orchestration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ import {
makeWalletFactoryContext,
type WalletFactoryTestContext,
} from './walletFactory.js';
import {
insistManagerType,
makeRunPolicyProvider,
} from '../../tools/supports.js';

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

const validatorAddress: CosmosValidatorAddress = {
value: 'cosmosvaloper1test',
Expand All @@ -25,11 +33,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' ? makeRunPolicyProvider() : 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 @@ -105,6 +123,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 @@ -143,6 +162,7 @@ test.serial('stakeAtom - smart wallet', async t => {
agoricNamesRemotes,
bridgeUtils: { flushInboundQueue },
readPublished,
perfTool,
} = t.context;

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

perfTool?.usePolicy(true);
await wd.sendOffer({
id: 'request-account',
invitationSpec: {
Expand All @@ -162,6 +183,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 19ae5da

Please sign in to comment.