@@ -1155,3 +1155,73 @@ test('uses transfer for Noble bech32', async t => {
11551155 ] ,
11561156 ] ) ;
11571157} ) ;
1158+
1159+ test ( 'Advance Fails on transfer to Noble' , async t => {
1160+ const {
1161+ bootstrap : { storage } ,
1162+ extensions : {
1163+ services : { advancer, feeTools } ,
1164+ helpers : { inspectBorrowerFacetCalls, inspectLogs, inspectNotifyCalls } ,
1165+ mocks : { mockPoolAccount, resolveLocalTransferV, resolveWithdrawToSeatV } ,
1166+ } ,
1167+ brands : { usdc } ,
1168+ } = t . context ;
1169+
1170+ const evidence = MockCctpTxEvidences . AGORIC_PLUS_NOBLE ( ) ;
1171+ void advancer . handleTransactionEvent ( { evidence, risk : { } } ) ;
1172+
1173+ // pretend borrow and deposit to LCA succeed
1174+ resolveLocalTransferV ( ) ;
1175+ await eventLoopIteration ( ) ;
1176+
1177+ t . deepEqual (
1178+ storage . getDeserialized ( `fun.txns.${ evidence . txHash } ` ) ,
1179+ [
1180+ { evidence, status : PendingTxStatus . Observed } ,
1181+ { status : PendingTxStatus . Advancing } ,
1182+ ] ,
1183+ 'tx is Advancing' ,
1184+ ) ;
1185+
1186+ mockPoolAccount . transferVResolver . reject ( new Error ( 'simulated error' ) ) ;
1187+ await eventLoopIteration ( ) ;
1188+
1189+ t . deepEqual ( inspectLogs ( ) , [
1190+ [
1191+ 'decoded EUD: cosmos:noble-1:noble1u2l9za2wa7wvffhtekgyuvyvum06lwhqxfyr5d' ,
1192+ ] ,
1193+ [ 'Advance failed' , Error ( 'simulated error' ) ] ,
1194+ ] ) ;
1195+
1196+ // We expect to see an `AdvancedFailed` update, but that is now Settler's job.
1197+ // but we can ensure it's called
1198+ t . like ( inspectNotifyCalls ( ) , [
1199+ [
1200+ {
1201+ txHash : evidence . txHash ,
1202+ forwardingAddress : evidence . tx . forwardingAddress ,
1203+ fullAmount : usdc . make ( evidence . tx . amount ) ,
1204+ destination : `${ decodeAddressHook ( evidence . aux . recipientAddress ) . query . EUD } ` ,
1205+ } ,
1206+ false , // this indicates transfer failed
1207+ ] ,
1208+ ] ) ;
1209+
1210+ // simulate withdrawing `advanceAmount` from PoolAccount to tmpReturnSeat
1211+ resolveWithdrawToSeatV ( ) ;
1212+ await eventLoopIteration ( ) ;
1213+ const { returnToPool } = inspectBorrowerFacetCalls ( ) ;
1214+ t . is (
1215+ returnToPool . length ,
1216+ 1 ,
1217+ 'returnToPool is called after ibc transfer fails' ,
1218+ ) ;
1219+ t . deepEqual (
1220+ returnToPool [ 0 ] ,
1221+ [
1222+ Far ( 'MockZCFSeat' , { exit : theExit } ) ,
1223+ usdc . make ( 930999999n ) , // 300000000n net of fees
1224+ ] ,
1225+ 'same amount borrowed is returned to LP' ,
1226+ ) ;
1227+ } ) ;
0 commit comments