Skip to content

Commit

Permalink
test(fast-usdc): bootstrap test for advancement
Browse files Browse the repository at this point in the history
  • Loading branch information
samsiegart committed Dec 2, 2024
1 parent cf56e91 commit 76ac3e4
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 16 deletions.
92 changes: 78 additions & 14 deletions packages/boot/test/fast-usdc/fast-usdc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
makeWalletFactoryContext,
type WalletFactoryTestContext,
} from '../bootstrapTests/walletFactory.js';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';

Check failure on line 16 in packages/boot/test/fast-usdc/fast-usdc.test.ts

View workflow job for this annotation

GitHub Actions / lint-primary

`@agoric/internal/src/testing-utils.js` import should occur before import of `../bootstrapTests/walletFactory.js`

const test: TestFn<WalletFactoryTestContext> = anyTest;

Expand Down Expand Up @@ -134,21 +135,84 @@ test.serial('writes status updates to vstorage', async t => {
const wallet = await wd.provideSmartWallet(
'agoric144rrhh4m09mh7aaffhm6xy223ym76gve2x7y78',
);
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 wallet.sendOffer({
id: `submit-mock-evidence-dydx`,
invitationSpec: {
source: 'agoricContract',
instancePath: ['fastUsdc'],
callPipe: [
['makeTestPushInvitation', [MockCctpTxEvidences.AGORIC_PLUS_DYDX()]],
],
},
proposal: {},
});

await submitMockEvidence(mockEvidence1);
await submitMockEvidence(mockEvidence2);
const doc = {
node: `fastUsdc.status`,
owner: `the statuses of fast USDC transfers identified by their tx hashes`,
};
await documentStorageSchema(t, storage, doc);
});

test.serial('makes usdc advance', async t => {
const { walletFactoryDriver: wd, storage, agoricNamesRemotes } = t.context;
const oracles = await Promise.all([
wd.provideSmartWallet('agoric144rrhh4m09mh7aaffhm6xy223ym76gve2x7y78'),
wd.provideSmartWallet('agoric19d6gnr9fyp6hev4tlrg87zjrzsd5gzr5qlfq2p'),
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: {},
}),
),
);
await eventLoopIteration();

const usdc = agoricNamesRemotes.vbankAsset.USDC.brand;
await oracles[0].sendOffer({
id: 'deposit-lp-0',
invitationSpec: {
source: 'agoricContract',
instancePath: ['fastUsdc'],
callPipe: [['makeDepositInvitation', []]],
},
proposal: {
give: {
// @ts-expect-error it doesnt recognize usdc as a Brand type
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
16 changes: 15 additions & 1 deletion packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,23 @@ Generated by [AVA](https://avajs.dev).
[
[
'published.fastUsdc.status.0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761702',
'published.fastUsdc.status.0xd81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761799',
'OBSERVED',
],
]

## 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.
>
> See also board marshalling conventions (_to appear_).
[
[
'published.fastUsdc.status.0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761702',
'ADVANCING',
],
[
'published.fastUsdc.status.0xd81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761799',
'OBSERVED',
Expand Down
Binary file modified packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.snap
Binary file not shown.
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 76ac3e4

Please sign in to comment.