@@ -11,6 +11,7 @@ import {
11
11
makeIBCTransferMsg ,
12
12
} from '../../tools/ibc-transfer.js' ;
13
13
import { makeHttpClient } from '../../tools/makeHttpClient.js' ;
14
+ import type { OfferStatus } from '@agoric/smart-wallet/src/offers.js' ;
14
15
import {
15
16
fundRemote ,
16
17
setupXcsContracts ,
@@ -341,6 +342,87 @@ test.serial('BLD for OSMO, receiver on CosmosHub', async t => {
341
342
) ;
342
343
} ) ;
343
344
345
+ test . serial ( 'BLD for OSMO, receiver chain not registered to XCS, should throw' , async t => {
346
+ const {
347
+ wallets,
348
+ provisionSmartWallet,
349
+ vstorageClient,
350
+ retryUntilCondition,
351
+ useChain,
352
+ } = t . context ;
353
+
354
+ // Provision the Agoric smart wallet
355
+ const agoricAddr = wallets . agoricSender ;
356
+ const wdUser = await provisionSmartWallet ( agoricAddr , {
357
+ BLD : 1000n ,
358
+ IST : 1000n ,
359
+ } ) ;
360
+ t . log ( `Provisioned Agoric smart wallet for ${ agoricAddr } ` ) ;
361
+
362
+ const apiUrl = await useChain ( 'agoric' ) . getRestEndpoint ( ) ;
363
+ const queryClient = makeQueryClient ( apiUrl ) ;
364
+
365
+ const brands = await vstorageClient . queryData ( 'published.agoricNames.brand' ) ;
366
+ const bldBrand = Object . fromEntries ( brands ) . BLD ;
367
+ const swapInAmount = AmountMath . make ( bldBrand , 125n ) ;
368
+ const { balance : bldBalanceBefore } = await queryClient . queryBalance (
369
+ agoricAddr ,
370
+ 'ubld' ,
371
+ ) ;
372
+
373
+ // Send swap offer
374
+ const makeAccountOfferId = `swap-ubld-uosmo-${ Date . now ( ) } ` ;
375
+ const updates = wdUser . offers . executeOffer ( {
376
+ id : makeAccountOfferId ,
377
+ invitationSpec : {
378
+ source : 'agoricContract' ,
379
+ instancePath : [ contractName ] ,
380
+ callPipe : [ [ 'makeSendInvitation' ] ] ,
381
+ } ,
382
+ offerArgs : {
383
+ // TODO: get the contract address dynamically
384
+ destAddr :
385
+ 'osmo17p9rzwnnfxcjp32un9ug7yhhzgtkhvl9jfksztgw5uh69wac2pgs5yczr8' ,
386
+ receiverAddr : 'noble/noble1foo' ,
387
+ outDenom : 'uosmo' ,
388
+ slippage : { slippagePercentage : '20' , windowSeconds : 10 } ,
389
+ onFailedDelivery : 'do_nothing' ,
390
+ } ,
391
+ proposal : { give : { Send : swapInAmount } } ,
392
+ } ) ;
393
+
394
+ const {
395
+ // @ts -expect-error types
396
+ value : {
397
+ status : { error : errorMsg } ,
398
+ } ,
399
+ } = await retryUntilCondition (
400
+ // Prevent test from hanging when no new values are coming from updates.next()
401
+ ( ) =>
402
+ Promise . race ( [
403
+ updates . next ( ) ,
404
+ new Promise ( resolve =>
405
+ setTimeout ( async ( ) => {
406
+ await updates . return ( ) ;
407
+ resolve ( 'Done' ) ;
408
+ } , 5000 ) ,
409
+ ) ,
410
+ ] ) ,
411
+ ( result : { value : { updated : string ; status : OfferStatus } } ) => {
412
+ return result . value . status . error !== undefined ;
413
+ } ,
414
+ 'Offer result did not fail as expect ed' ,
415
+ ) ;
416
+
417
+ const { balance : bldBalanceAfter } = await queryClient . queryBalance (
418
+ agoricAddr ,
419
+ 'ubld' ,
420
+ ) ;
421
+
422
+ t . deepEqual ( bldBalanceBefore , bldBalanceAfter ) ;
423
+ t . regex ( errorMsg , / ^ E r r o r : I B C T r a n s f e r f a i l e d / ) ;
424
+ } ) ;
425
+
344
426
/**
345
427
* UNTIL https://github.com/Agoric/BytePitchPartnerEng/issues/51, we are skipping this
346
428
* until the ticket above is done
0 commit comments