Skip to content

Commit 10f25dd

Browse files
committed
fix: format fixes
1 parent 822c4a6 commit 10f25dd

File tree

1 file changed

+85
-80
lines changed

1 file changed

+85
-80
lines changed

multichain-testing/test/xcs-swap-anything/swap-anything.test.ts

+85-80
Original file line numberDiff line numberDiff line change
@@ -342,86 +342,91 @@ test.serial('BLD for OSMO, receiver on CosmosHub', async t => {
342342
);
343343
});
344344

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, /^Error: IBC Transfer failed/);
424-
});
345+
test.serial(
346+
'BLD for OSMO, receiver chain not registered to XCS, should throw',
347+
async t => {
348+
const {
349+
wallets,
350+
provisionSmartWallet,
351+
vstorageClient,
352+
retryUntilCondition,
353+
useChain,
354+
} = t.context;
355+
356+
// Provision the Agoric smart wallet
357+
const agoricAddr = wallets.agoricSender;
358+
const wdUser = await provisionSmartWallet(agoricAddr, {
359+
BLD: 1000n,
360+
IST: 1000n,
361+
});
362+
t.log(`Provisioned Agoric smart wallet for ${agoricAddr}`);
363+
364+
const apiUrl = await useChain('agoric').getRestEndpoint();
365+
const queryClient = makeQueryClient(apiUrl);
366+
367+
const brands = await vstorageClient.queryData(
368+
'published.agoricNames.brand',
369+
);
370+
const bldBrand = Object.fromEntries(brands).BLD;
371+
const swapInAmount = AmountMath.make(bldBrand, 125n);
372+
const { balance: bldBalanceBefore } = await queryClient.queryBalance(
373+
agoricAddr,
374+
'ubld',
375+
);
376+
377+
// Send swap offer
378+
const makeAccountOfferId = `swap-ubld-uosmo-${Date.now()}`;
379+
const updates = wdUser.offers.executeOffer({
380+
id: makeAccountOfferId,
381+
invitationSpec: {
382+
source: 'agoricContract',
383+
instancePath: [contractName],
384+
callPipe: [['makeSendInvitation']],
385+
},
386+
offerArgs: {
387+
// TODO: get the contract address dynamically
388+
destAddr:
389+
'osmo17p9rzwnnfxcjp32un9ug7yhhzgtkhvl9jfksztgw5uh69wac2pgs5yczr8',
390+
receiverAddr: 'noble/noble1foo',
391+
outDenom: 'uosmo',
392+
slippage: { slippagePercentage: '20', windowSeconds: 10 },
393+
onFailedDelivery: 'do_nothing',
394+
},
395+
proposal: { give: { Send: swapInAmount } },
396+
});
397+
398+
const {
399+
// @ts-expect-error types
400+
value: {
401+
status: { error: errorMsg },
402+
},
403+
} = await retryUntilCondition(
404+
// Prevent test from hanging when no new values are coming from updates.next()
405+
() =>
406+
Promise.race([
407+
updates.next(),
408+
new Promise(resolve =>
409+
setTimeout(async () => {
410+
await updates.return();
411+
resolve('Done');
412+
}, 5000),
413+
),
414+
]),
415+
(result: { value: { updated: string; status: OfferStatus } }) => {
416+
return result.value.status.error !== undefined;
417+
},
418+
'Offer result did not fail as expect ed',
419+
);
420+
421+
const { balance: bldBalanceAfter } = await queryClient.queryBalance(
422+
agoricAddr,
423+
'ubld',
424+
);
425+
426+
t.deepEqual(bldBalanceBefore, bldBalanceAfter);
427+
t.regex(errorMsg, /^Error: IBC Transfer failed/);
428+
},
429+
);
425430

426431
/**
427432
* UNTIL https://github.com/Agoric/BytePitchPartnerEng/issues/51, we are skipping this

0 commit comments

Comments
 (0)