From 5e4e8e980624b78645ca3d112d7b95b512fd5791 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Tue, 29 Oct 2024 13:39:24 -0500 Subject: [PATCH] test: demo SWINGSET_WORKER_TYPE, computron count MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../test/bootstrapTests/orchestration.test.ts | 25 +++++++++++++++++-- .../bootstrapTests/price-feed-replace.test.ts | 4 +++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/boot/test/bootstrapTests/orchestration.test.ts b/packages/boot/test/bootstrapTests/orchestration.test.ts index a4f0f3dadfa..74740ac2939 100644 --- a/packages/boot/test/bootstrapTests/orchestration.test.ts +++ b/packages/boot/test/bootstrapTests/orchestration.test.ts @@ -11,8 +11,13 @@ import { makeWalletFactoryContext, type WalletFactoryTestContext, } from './walletFactory.js'; +import { insistManagerType, makePolicyProvider } from '../../tools/supports.js'; -const test: TestFn = anyTest; +const test: TestFn< + WalletFactoryTestContext & { + perfTool?: ReturnType; + } +> = anyTest; const validatorAddress: CosmosValidatorAddress = { value: 'cosmosvaloper1test', @@ -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?.()); @@ -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'), @@ -138,6 +154,7 @@ test.serial('stakeAtom - smart wallet', async t => { agoricNamesRemotes, bridgeUtils: { flushInboundQueue }, readPublished, + perfTool, } = t.context; await evalProposal( @@ -148,6 +165,7 @@ test.serial('stakeAtom - smart wallet', async t => { 'agoric1testStakAtom', ); + perfTool?.usePolicy(true); await wd.sendOffer({ id: 'request-account', invitationSpec: { @@ -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: [ diff --git a/packages/boot/test/bootstrapTests/price-feed-replace.test.ts b/packages/boot/test/bootstrapTests/price-feed-replace.test.ts index 4e583fce1da..3e7876b694c 100644 --- a/packages/boot/test/bootstrapTests/price-feed-replace.test.ts +++ b/packages/boot/test/bootstrapTests/price-feed-replace.test.ts @@ -64,6 +64,7 @@ test.serial('setupVaults; run updatePriceFeeds proposals', async t => { setupVaults, governanceDriver: gd, readPublished, + perfTool, } = t.context; await setupVaults(collateralBrandKey, managerIndex, setup); @@ -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,