@@ -23,6 +23,7 @@ import { commonSetup } from './supports.js';
23
23
import type { FastUsdcTerms } from '../src/fast-usdc.contract.js' ;
24
24
import { makeFeeTools } from '../src/utils/fees.js' ;
25
25
import type { PoolMetrics } from '../src/types.js' ;
26
+ import { addressTools } from '../src/utils/address.js' ;
26
27
27
28
const dirname = path . dirname ( new URL ( import . meta. url ) . pathname ) ;
28
29
@@ -52,6 +53,14 @@ const startContract = async (
52
53
const { zoe, bundleAndInstall } = await setUpZoeForTest ( {
53
54
setJig : jig => {
54
55
jig . chainHub . registerChain ( 'osmosis' , fetchedChainInfo . osmosis ) ;
56
+ jig . chainHub . registerChain ( 'agoric' , fetchedChainInfo . agoric ) ;
57
+ // TODO #10445 register noble<>agoric and noble<>osmosis instead
58
+ // for PFM routing. also will need to call `registerAsset`
59
+ jig . chainHub . registerConnection (
60
+ fetchedChainInfo . agoric . chainId ,
61
+ fetchedChainInfo . osmosis . chainId ,
62
+ fetchedChainInfo . agoric . connections [ 'osmosis-1' ] ,
63
+ ) ;
55
64
} ,
56
65
} ) ;
57
66
const installation : Installation < StartFn > =
@@ -69,26 +78,6 @@ const startContract = async (
69
78
return { ...startKit , zoe } ;
70
79
} ;
71
80
72
- // FIXME this makeTestPushInvitation forces evidence, which triggers advancing,
73
- // which doesn't yet work
74
- test . skip ( 'advancing' , async t => {
75
- const common = await commonSetup ( t ) ;
76
-
77
- const { publicFacet, zoe } = await startContract ( common ) ;
78
-
79
- const e1 = await E ( MockCctpTxEvidences . AGORIC_PLUS_DYDX ) ( ) ;
80
-
81
- const inv = await E ( publicFacet ) . makeTestPushInvitation ( e1 ) ;
82
- // the invitation maker itself pushes the evidence
83
-
84
- // the offer is still safe to make
85
- const seat = await E ( zoe ) . offer ( inv ) ;
86
- t . is (
87
- await E ( seat ) . getOfferResult ( ) ,
88
- 'inert; nothing should be expected from this offer' ,
89
- ) ;
90
- } ) ;
91
-
92
81
test ( 'oracle operators have closely-held rights to submit evidence of CCTP transactions' , async t => {
93
82
const common = await commonSetup ( t ) ;
94
83
const { creatorFacet, zoe } = await startContract ( common ) ;
@@ -551,3 +540,85 @@ test('baggage', async t => {
551
540
const tree = inspectMapStore ( contractBaggage ) ;
552
541
t . snapshot ( tree , 'contract baggage after start' ) ;
553
542
} ) ;
543
+
544
+ test ( 'advancing happy path' , async t => {
545
+ const common = await commonSetup ( t ) ;
546
+ const {
547
+ brands : { usdc } ,
548
+ commonPrivateArgs,
549
+ utils : { inspectLocalBridge, inspectBankBridge, transmitTransferAck } ,
550
+ } = common ;
551
+
552
+ const { instance, publicFacet, zoe } = await startContract ( common ) ;
553
+ const terms = await E ( zoe ) . getTerms ( instance ) ;
554
+ const { subscriber } = E . get (
555
+ E . get ( E ( publicFacet ) . getPublicTopics ( ) ) . poolMetrics ,
556
+ ) ;
557
+ const feeTools = makeFeeTools ( commonPrivateArgs . feeConfig ) ;
558
+ const { makeLP, purseOf } = makeLpTools ( t , common , {
559
+ publicFacet,
560
+ subscriber,
561
+ terms,
562
+ zoe,
563
+ } ) ;
564
+
565
+ const evidence = await E ( MockCctpTxEvidences . AGORIC_PLUS_OSMO ) ( ) ;
566
+
567
+ // seed pool with funds
568
+ const alice = makeLP ( 'Alice' , purseOf ( evidence . tx . amount ) ) ;
569
+ await alice . deposit ( evidence . tx . amount ) ;
570
+
571
+ // the invitation maker itself pushes the evidence
572
+ const inv = await E ( publicFacet ) . makeTestPushInvitation ( evidence ) ;
573
+ const seat = await E ( zoe ) . offer ( inv ) ;
574
+ t . is (
575
+ await E ( seat ) . getOfferResult ( ) ,
576
+ 'inert; nothing should be expected from this offer' ,
577
+ ) ;
578
+
579
+ // calculate advance net of fees
580
+ const expectedAdvance = feeTools . calculateAdvance (
581
+ usdc . make ( evidence . tx . amount ) ,
582
+ ) ;
583
+ t . log ( 'Expecting to observe advance of' , expectedAdvance ) ;
584
+
585
+ await eventLoopIteration ( ) ; // let Advancer do work
586
+
587
+ // advance sent from PoolSeat to PoolAccount
588
+ t . deepEqual ( inspectBankBridge ( ) . at ( - 1 ) , {
589
+ amount : String ( expectedAdvance . value ) ,
590
+ denom : 'ibc/usdconagoric' ,
591
+ recipient : 'agoric1fakeLCAAddress' ,
592
+ type : 'VBANK_GIVE' ,
593
+ } ) ;
594
+
595
+ // ibc transfer sent over localChain bridge
596
+ const localBridgeMsg = inspectLocalBridge ( ) . at ( - 1 ) ;
597
+ const ibcTransferMsg = localBridgeMsg . messages [ 0 ] ;
598
+ t . is ( ibcTransferMsg [ '@type' ] , '/ibc.applications.transfer.v1.MsgTransfer' ) ;
599
+
600
+ const expectedReceiver = addressTools . getQueryParams (
601
+ evidence . aux . recipientAddress ,
602
+ ) . EUD ;
603
+ t . is ( ibcTransferMsg . receiver , expectedReceiver , 'sent to correct address' ) ;
604
+ t . deepEqual ( ibcTransferMsg . token , {
605
+ amount : String ( expectedAdvance . value ) ,
606
+ denom : 'ibc/usdconagoric' ,
607
+ } ) ;
608
+
609
+ // TODO #10445 expect PFM memo
610
+ t . is ( ibcTransferMsg . memo , '' , 'TODO expecting PFM memo' ) ;
611
+
612
+ // TODO #10445 expect routing through noble, not osmosis
613
+ t . is (
614
+ ibcTransferMsg . sourceChannel ,
615
+ fetchedChainInfo . agoric . connections [ 'osmosis-1' ] . transferChannel . channelId ,
616
+ 'TODO expecting routing through Noble' ,
617
+ ) ;
618
+
619
+ await transmitTransferAck ( ) ;
620
+ // Nothing we can check here, unless we want to inspect calls to `trace`.
621
+ // `test/exos/advancer.test.ts` covers calls to `log: LogFn` with mocks.
622
+ // This is still helpful to call, so we can observe "Advance transfer
623
+ // fulfilled" in the test output.
624
+ } ) ;
0 commit comments