From 76ac3e4ab99fcfee8d35fd9bc279c4a0b8e04658 Mon Sep 17 00:00:00 2001 From: Samuel Siegart Date: Mon, 2 Dec 2024 15:20:06 -0800 Subject: [PATCH] test(fast-usdc): bootstrap test for advancement --- .../boot/test/fast-usdc/fast-usdc.test.ts | 92 +++++++++++++++--- .../fast-usdc/snapshots/fast-usdc.test.ts.md | 16 ++- .../snapshots/fast-usdc.test.ts.snap | Bin 1242 -> 1286 bytes packages/fast-usdc/src/type-guards.js | 2 +- 4 files changed, 94 insertions(+), 16 deletions(-) diff --git a/packages/boot/test/fast-usdc/fast-usdc.test.ts b/packages/boot/test/fast-usdc/fast-usdc.test.ts index e13f95849e7..822397141fa 100644 --- a/packages/boot/test/fast-usdc/fast-usdc.test.ts +++ b/packages/boot/test/fast-usdc/fast-usdc.test.ts @@ -13,6 +13,7 @@ import { makeWalletFactoryContext, type WalletFactoryTestContext, } from '../bootstrapTests/walletFactory.js'; +import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js'; const test: TestFn = anyTest; @@ -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`, diff --git a/packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.md b/packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.md index f953f9ea514..4443dde49e2 100644 --- a/packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.md +++ b/packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.md @@ -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', diff --git a/packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.snap b/packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.snap index 9489b8bc7ff297097930bdd8547b32b0ecc731b5..701eb14de7a6f49b502e00011487a8e9b78f0451 100644 GIT binary patch literal 1286 zcmV+h1^N0xRzV>rB=00000000B+R!ff?MG&r<8Sgr~8+N1Q0wSo{1LBcgX1p1%7dT+N3yLBV zvPl+@kfNUH8hf(i8LPYPILaxAU%&~3K;&`dfH=T~Kfp^uAYOtCM@|R{fslgGj305v zn++y8nFEFcoBl|-R`p6P^jlujhC zQ>bFzQjJ8biOq^&32lGv^^G!1&PJtDao26PQa)VTuq)M^@98Y5gQJ`8Uxj>z{3H%S z+2lG*V%5)(v19gYNvtLJ^?xTv5%(zS{(U+YB-!FnUyFyBZV+4CL1v3AP6V+~F+ma4 zxh9d8Oln@Im?V!Fj|Iz)xuja;he7D~YAZ}DEs>e+vs`I*`s8{otG(r!Qw?I&<;_+^ z%%dnd$HF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fw3}#{pxU7+uQN7 zzB^=Q53szmAY-#Qw~{1OC-GcYeodH>`sdf)a`@@*EQhY_?6VslXlh%U)n+!qU<>>| z7QmCe1)wz7ZN=Ix(M`VJ62QAdOTcykpb7vl9<&H7BhhENz)3_s5NrDe0Nm~g_1-(7 zjP{BAGY0`~6ddgXm&cpCERXJ?7u-%*^MbJIxqeV}d1di*xD@&>551+DSEV2nzF+mk zVznxwS`aM;x$*uH~Ar3y!&c1YE{rsi%wTB=h{t=nw<-N)D+WY>2 z?cL?FPj7b}Nad{=4Zdr% { /** @type {TypedPattern} */ const deposit = M.splitRecord( { give: { USDC: makeNatAmountShape(USDC, 1n) } }, - { want: { PoolShare: makeNatAmountShape(PoolShares) } }, + { want: M.splitRecord({}, { PoolShare: makeNatAmountShape(PoolShares) }) }, ); /** @type {TypedPattern} */ const withdraw = M.splitRecord({