Skip to content

Commit e826b41

Browse files
committed
chore: improve assertions, add README
Refs: #8863
1 parent cae6929 commit e826b41

File tree

3 files changed

+46
-16
lines changed

3 files changed

+46
-16
lines changed

multichain-testing/test/xcs-swap-anything/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ CHANNEL_INFO=$(shell $(cli-hermes) --json query channels --show-counterparty --c
1616
AGORIC_OSMOSIS_CHANNEL=$(shell echo '$(CHANNEL_INFO)' | jq -r '.channel_a')
1717
OSMOSIS_AGORIC_CHANNEL=$(shell echo '$(CHANNEL_INFO)' | jq -r '.channel_b')
1818

19-
REGISTRY_ADDRESS="osmo1wkwy0xh89ksdgj9hr347dyd2dw7zesmtrue6kfzyml4vdtz6e5wsfdyyaj"
20-
SWAPROUTER_ADDRESS="osmo1hrpna9v7vs3stzyd4z3xf00676kf78zpe2u5ksvljswn2vnjp3ysgnqrud"
21-
SWAP_ADDRESS="osmo1ufs3tlq4umljk0qfe8k5ya0x6hpavn897u2cnf9k0en9jr7qarqq7fzxcr"
19+
REGISTRY_ADDRESS="osmo1nc5tatafv6eyq7llkr2gv50ff9e22mnf70qgjlv737ktmt4eswrqvlx82r"
20+
SWAPROUTER_ADDRESS="osmo14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sq2r9g9"
21+
SWAP_ADDRESS="osmo17p9rzwnnfxcjp32un9ug7yhhzgtkhvl9jfksztgw5uh69wac2pgs5yczr8"
2222

2323
POOL_ASSET_1_DENOM="uosmo"
2424
POOL_ASSET_1_AMOUNT="250000"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Spin up Environment
2+
```sh
3+
cd agoric-sdk/multichain-testing
4+
make start FILE=config.xcs-swap-anything.yaml
5+
make osmosis-xcs-setup
6+
make create-osmosis-pool
7+
8+
## Configure the osmosis registries
9+
cd cd agoric-sdk/multichain-testing/test/xcs-swap-anything
10+
make tx-chain-channel-links
11+
make tx-bec32-prefixes
12+
```
13+
14+
## Run tests
15+
```sh
16+
cd agoric-sdk/multichain-testing
17+
yarn ava test/xcs-swap-anything/swap-anything.test.ts
18+
```

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

+25-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import anyTest from '@endo/ses-ava/prepare-endo.js';
22
import type { TestFn } from 'ava';
3-
import { makeDoOffer } from '../../tools/e2e-tools.js';
4-
import {
5-
commonSetup,
6-
type SetupContextWithWallets,
7-
} from '../support.js';
83
import { AmountMath } from '@agoric/ertp';
4+
import { makeDoOffer } from '../../tools/e2e-tools.js';
5+
import { commonSetup, type SetupContextWithWallets } from '../support.js';
96
import { makeQueryClient } from '../../tools/query.js';
7+
import starshipChainInfo from '../../starship-chain-info.js';
108

119
const test = anyTest as TestFn<SetupContextWithWallets>;
1210

@@ -43,11 +41,11 @@ test('BLD for OSMO, receiver on Agoric', async t => {
4341
});
4442
t.log(`Provisioned Agoric smart wallet for ${agoricAddr}`);
4543

46-
// const osmosisChainId = useChain('osmosis').chain.chain_id;
44+
const osmosisChainId = useChain('osmosis').chain.chain_id;
4745

48-
// const {
49-
// transferChannel: { counterPartyChannelId, channelId },
50-
// } = starshipChainInfo.agoric.connections[osmosisChainId];
46+
const {
47+
transferChannel: { channelId },
48+
} = starshipChainInfo.agoric.connections[osmosisChainId];
5149

5250
const doOffer = makeDoOffer(wdUser);
5351

@@ -72,7 +70,9 @@ test('BLD for OSMO, receiver on Agoric', async t => {
7270
callPipe: [['makeSendInvitation']],
7371
},
7472
offerArgs: {
75-
destAddr: 'osmo1ufs3tlq4umljk0qfe8k5ya0x6hpavn897u2cnf9k0en9jr7qarqq7fzxcr',
73+
// TODO: get the contract address dynamically
74+
destAddr:
75+
'osmo17p9rzwnnfxcjp32un9ug7yhhzgtkhvl9jfksztgw5uh69wac2pgs5yczr8',
7676
receiverAddr: wallets.agoricReceiver,
7777
outDenom: 'uosmo',
7878
slippage: { slippagePercentage: '20', windowSeconds: 10 },
@@ -81,14 +81,26 @@ test('BLD for OSMO, receiver on Agoric', async t => {
8181
proposal: { give: { Send: swapInAmount } },
8282
});
8383

84-
const agoricReceiverBalance = await retryUntilCondition(
84+
const { balances: agoricReceiverBalances } = await retryUntilCondition(
8585
() => queryClient.queryBalances(wallets.agoricReceiver),
8686
({ balances }) => balances.length > balancesBefore.length,
8787
'Deposit reflected in localOrchAccount balance',
8888
);
89-
t.log(agoricReceiverBalance);
89+
t.log(agoricReceiverBalances);
9090

91-
t.pass();
91+
const { hash: expectedHash } = await queryClient.queryDenom(
92+
`transfer/${channelId}`,
93+
'uosmo',
94+
);
95+
96+
t.log('Expected denom hash:', expectedHash);
97+
98+
t.regex(agoricReceiverBalances[0]?.denom, /^ibc/);
99+
t.is(
100+
agoricReceiverBalances[0]?.denom.split('ibc/')[1],
101+
expectedHash,
102+
'got expected ibc denom hash',
103+
);
92104
});
93105

94106
test.after(async t => {

0 commit comments

Comments
 (0)