From ce195aba9862df4e5467e1d955ae81cea67fc245 Mon Sep 17 00:00:00 2001 From: Samuel Siegart Date: Tue, 3 Dec 2024 18:41:58 -0800 Subject: [PATCH] test(fast-usdc): bootstrap test for advancement (#10606) refs https://github.com/Agoric/agoric-sdk/issues/10511 Does *not* count computrons yet. This makes 5 oracles submit evidence to provide a realistic scenario for measurement. --- .../boot/test/fast-usdc/fast-usdc.test.ts | 75 +++++++++++++----- .../fast-usdc/snapshots/fast-usdc.test.ts.md | 8 +- .../snapshots/fast-usdc.test.ts.snap | Bin 1242 -> 1193 bytes .../scripts/fast-usdc/init-fast-usdc.js | 2 - packages/fast-usdc/src/type-guards.js | 2 +- 5 files changed, 58 insertions(+), 29 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..49da38cf01e 100644 --- a/packages/boot/test/fast-usdc/fast-usdc.test.ts +++ b/packages/boot/test/fast-usdc/fast-usdc.test.ts @@ -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, @@ -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'), @@ -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`, 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..1441f49490d 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 @@ -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. @@ -82,10 +82,6 @@ Generated by [AVA](https://avajs.dev). [ [ 'published.fastUsdc.status.0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761702', - 'OBSERVED', - ], - [ - 'published.fastUsdc.status.0xd81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761799', - 'OBSERVED', + 'ADVANCING', ], ] 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..820fa8ddbf3bcfa3c1b40a990a2289fbb9915614 100644 GIT binary patch literal 1193 zcmV;a1XlY&RzVpL2 zz;^)f2LL=thPmcm@U9`(#2mjaFE0Z*2}z0v2-zkuPIr>GSP-Sb15`kk5;7y>sVMeB ztT$sB@J5S85r*f)$XMWmm5q{fNcO=Gyr-=CS-0Zq?IB0Am_TX9q(fFJSv4z6J=cpiAs$;p0NAQ zX1Qz&$KKj(@LJV%N=^-#?>c8|wVJzSyS2)h(pkG!&%~Zji#po6`TlLlR*1)uAILV- zK^&=Jg^VMs--shE8Q1@w9EQxpu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xgtz(uI6J z9B`{==>{yL{Tl+@M}WtQLtD^+GTOcc@Vo_ZzUW#Wacx@w*DQc{impdST<=-{pI87t z6kR7q3S^n{{AvvyR#2KX}gwCdsa8fIc(iPzoeZMPblOTRdr#xx*61 zj`go)w4ZVSPC5XqMcCv>2H^l)aR9CtU8nYVYacj=s+;8vm+Z5{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({