Skip to content

Commit

Permalink
test(fast-usdc): bootstrap test for advancement (#10606)
Browse files Browse the repository at this point in the history
refs #10511

Does *not* count computrons yet.

This makes 5 oracles submit evidence to provide a realistic scenario for measurement.
  • Loading branch information
samsiegart authored Dec 4, 2024
1 parent 3314b25 commit ce195ab
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 29 deletions.
75 changes: 55 additions & 20 deletions packages/boot/test/fast-usdc/fast-usdc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Fail } from '@endo/errors';
import { unmarshalFromVstorage } from '@agoric/internal/src/marshal.js';
import { makeMarshal } from '@endo/marshal';
import { defaultMarshaller } from '@agoric/internal/src/storage-test-utils.js';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import {
makeWalletFactoryContext,
type WalletFactoryTestContext,
Expand Down Expand Up @@ -41,8 +42,6 @@ test.serial(
} = t.context;

const [watcherWallet] = await Promise.all([
wd.provideSmartWallet('agoric144rrhh4m09mh7aaffhm6xy223ym76gve2x7y78'),
wd.provideSmartWallet('agoric19d6gnr9fyp6hev4tlrg87zjrzsd5gzr5qlfq2p'),
wd.provideSmartWallet('agoric19uscwxdac6cf6z7d5e26e0jm0lgwstc47cpll8'),
wd.provideSmartWallet('agoric1krunjcqfrf7la48zrvdfeeqtls5r00ep68mzkr'),
wd.provideSmartWallet('agoric1n4fcxsnkxe4gj6e24naec99hzmc4pjfdccy5nj'),
Expand Down Expand Up @@ -129,26 +128,62 @@ test.serial('writes fee config to vstorage', async t => {
await documentStorageSchema(t, storage, doc);
});

test.serial('writes status updates to vstorage', async t => {
const { walletFactoryDriver: wd, storage } = t.context;
const wallet = await wd.provideSmartWallet(
'agoric144rrhh4m09mh7aaffhm6xy223ym76gve2x7y78',
test.serial('makes usdc advance', async t => {
const { walletFactoryDriver: wd, storage, agoricNamesRemotes } = t.context;
const oracles = await Promise.all([
wd.provideSmartWallet('agoric19uscwxdac6cf6z7d5e26e0jm0lgwstc47cpll8'),
wd.provideSmartWallet('agoric1krunjcqfrf7la48zrvdfeeqtls5r00ep68mzkr'),
wd.provideSmartWallet('agoric1n4fcxsnkxe4gj6e24naec99hzmc4pjfdccy5nj'),
]);
await Promise.all(
oracles.map(wallet =>
wallet.sendOffer({
id: 'claim-oracle-invitation',
invitationSpec: {
source: 'purse',
instance: agoricNamesRemotes.instance.fastUsdc,
description: 'oracle operator invitation',
},
proposal: {},
}),
),
);
const submitMockEvidence = (mockEvidence: CctpTxEvidence) =>
wallet.sendOffer({
id: 'submit-mock-evidence',
invitationSpec: {
source: 'agoricContract',
instancePath: ['fastUsdc'],
callPipe: [['makeTestPushInvitation', [mockEvidence]]],
},
proposal: {},
});
const mockEvidence1 = MockCctpTxEvidences.AGORIC_PLUS_OSMO();
const mockEvidence2 = MockCctpTxEvidences.AGORIC_PLUS_DYDX();

await submitMockEvidence(mockEvidence1);
await submitMockEvidence(mockEvidence2);
// @ts-expect-error it doesnt recognize usdc as a Brand type
const usdc = agoricNamesRemotes.vbankAsset.USDC.brand as Brand<'nat'>;
await oracles[0].sendOffer({
id: 'deposit-lp-0',
invitationSpec: {
source: 'agoricContract',
instancePath: ['fastUsdc'],
callPipe: [['makeDepositInvitation', []]],
},
proposal: {
give: {
USDC: { brand: usdc, value: 150_000_000n },
},
},
});
await eventLoopIteration();

const evidence = MockCctpTxEvidences.AGORIC_PLUS_OSMO();
// TODO - start counting computrons
await Promise.all(
oracles.map(wallet =>
wallet.sendOffer({
id: 'submit-mock-evidence-osmo',
invitationSpec: {
source: 'continuing',
previousOffer: 'claim-oracle-invitation',
invitationMakerName: 'SubmitEvidence',
invitationArgs: [evidence],
},
proposal: {},
}),
),
);
await eventLoopIteration();
// TODO - stop counting computrons

const doc = {
node: `fastUsdc.status`,
Expand Down
8 changes: 2 additions & 6 deletions packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Generated by [AVA](https://avajs.dev).
],
]

## writes status updates to vstorage
## makes usdc advance

> Under "published", the "fastUsdc.status" node is delegated to the statuses of fast USDC transfers identified by their tx hashes.
> The example below illustrates the schema of the data published there.
Expand All @@ -82,10 +82,6 @@ Generated by [AVA](https://avajs.dev).
[
[
'published.fastUsdc.status.0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761702',
'OBSERVED',
],
[
'published.fastUsdc.status.0xd81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761799',
'OBSERVED',
'ADVANCING',
],
]
Binary file modified packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.snap
Binary file not shown.
2 changes: 0 additions & 2 deletions packages/builders/scripts/fast-usdc/init-fast-usdc.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ const configurations = {
},
MAINNET: {
oracles: {
DSRV: 'agoric144rrhh4m09mh7aaffhm6xy223ym76gve2x7y78',
Stakin: 'agoric19d6gnr9fyp6hev4tlrg87zjrzsd5gzr5qlfq2p',
'01node': 'agoric19uscwxdac6cf6z7d5e26e0jm0lgwstc47cpll8',
'Simply Staking': 'agoric1krunjcqfrf7la48zrvdfeeqtls5r00ep68mzkr',
P2P: 'agoric1n4fcxsnkxe4gj6e24naec99hzmc4pjfdccy5nj',
Expand Down
2 changes: 1 addition & 1 deletion packages/fast-usdc/src/type-guards.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const makeProposalShapes = ({ PoolShares, USDC }) => {
/** @type {TypedPattern<USDCProposalShapes['deposit']>} */
const deposit = M.splitRecord(
{ give: { USDC: makeNatAmountShape(USDC, 1n) } },
{ want: { PoolShare: makeNatAmountShape(PoolShares) } },
{ want: M.splitRecord({}, { PoolShare: makeNatAmountShape(PoolShares) }) },
);
/** @type {TypedPattern<USDCProposalShapes['withdraw']>} */
const withdraw = M.splitRecord({
Expand Down

0 comments on commit ce195ab

Please sign in to comment.