Skip to content

Commit

Permalink
test(quickSend): initial computron performance measurement
Browse files Browse the repository at this point in the history
We're not measuing a particularly relevant workload: this is the
watcher accepting the invitation (and the contract setting up
accounts).

The more performance-relevant workloads are user advance and
settlement.
  • Loading branch information
dckc committed Oct 19, 2024
1 parent 897bd4a commit a365328
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions packages/boot/test/bootstrapTests/quickSend.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,52 @@ import {
type WalletFactoryTestContext,
} from './walletFactory.js';
import { WalletFactoryDriver } from '../../tools/drivers.js';
import { computronCounter } from '../../tools/computron-counter.js';

const test: TestFn<WalletFactoryTestContext> = anyTest;
const makeMeter = () => {
const beansPer = 100n;
// see https://cosgov.org/agoric?msgType=parameterChangeProposal&network=main
const mainParams = {
blockComputeLimit: 65_000_000n * beansPer,
vatCreation: 300_000n * beansPer,
xsnapComputron: beansPer,
};

let metering = false;
let policy;

const meter = harden({
makeRunPolicy: () => {
policy = metering ? computronCounter(mainParams) : undefined;
return policy;
},
setMetering: x => (metering = x),
getValue: () => policy.remainingBeans(),
});
return meter;
};

const test: TestFn<
WalletFactoryTestContext & { meter: ReturnType<typeof makeMeter> }
> = anyTest;

test.before('bootstrap', async t => {
t.context = await makeWalletFactoryContext(
const meter = makeMeter();
const ctx = await makeWalletFactoryContext(
t,
'@agoric/vm-config/decentral-itest-orchestration-config.json',
{ defaultManagerType: 'xsnap', meter },
);
t.context = { ...ctx, meter };

// TODO: handle creating watcher smart wallet _after_ deploying contract
await t.context.walletFactoryDriver.provideSmartWallet('agoric1watcher');
});
test.after.always(t => t.context.shutdown?.());

test.serial('deploy contract', async t => {
await t.context.walletFactoryDriver.provideSmartWallet('agoric1watcher');

const {
agoricNamesRemotes,
evalProposal,
Expand All @@ -40,7 +71,7 @@ type SmartWallet = Awaited<
>;

test.serial('accept watcher invitation', async t => {
const { agoricNamesRemotes } = t.context;
const { agoricNamesRemotes, meter } = t.context;

const william = async (sw: SmartWallet) => {
await sw.executeOffer({
Expand All @@ -62,5 +93,8 @@ test.serial('accept watcher invitation', async t => {
const wd =
await t.context.walletFactoryDriver.provideSmartWallet('agoric1watcher');

t.log('start metering');
meter.setMetering(true);
await william(wd);
t.log('metered cost (beans)', meter.getValue());
});

0 comments on commit a365328

Please sign in to comment.