-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connectHorizontal open any channel (#689)
* connectHorizontal open any channel * filter itself
- Loading branch information
1 parent
654a530
commit e23208c
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/e2e/src/__snapshots__/connect-horizontal.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`connectHorizontal > connectHorizontal opens channel > system events 1`] = ` | ||
[ | ||
{ | ||
"data": { | ||
"messageHash": "(hash)", | ||
}, | ||
"method": "XcmpMessageSent", | ||
"section": "xcmpQueue", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`connectHorizontal > connectHorizontal opens channel > system events 2`] = ` | ||
[ | ||
{ | ||
"data": { | ||
"error": "TooExpensive", | ||
"messageHash": "(hash)", | ||
"weight": { | ||
"proofSize": 0, | ||
"refTime": 600000000, | ||
}, | ||
}, | ||
"method": "Fail", | ||
"section": "xcmpQueue", | ||
}, | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { connectHorizontal } from '@acala-network/chopsticks-core/xcm/horizontal.js' | ||
import { describe, it } from 'vitest' | ||
|
||
import { checkSystemEvents, setupContext, testingPairs } from './helper.js' | ||
import networks from './networks.js' | ||
|
||
describe('connectHorizontal', () => { | ||
it('connectHorizontal opens channel', async () => { | ||
const { alice } = testingPairs() | ||
const acala = await networks.acala({ blockNumber: 5729464 }) | ||
await acala.dev.setStorage({ | ||
System: { | ||
Account: [[[alice.address], { providers: 1, data: { free: 1000e12 } }]], | ||
}, | ||
}) | ||
const zeitgeist = await setupContext({ | ||
endpoint: 'wss://zeitgeist-rpc.dwellir.com', | ||
blockNumber: 5084336, | ||
db: !process.env.RUN_TESTS_WITHOUT_DB ? 'e2e-tests-db.sqlite' : undefined, | ||
}) | ||
|
||
await connectHorizontal({ | ||
2000: acala.chain, | ||
2092: zeitgeist.chain, | ||
}) | ||
|
||
await acala.dev.newBlock() | ||
await zeitgeist.dev.newBlock() | ||
|
||
// This tx will be sent to Zeitgeist and fail but it's fine for this test as we only want to test the connection | ||
await acala.api.tx.xTokens | ||
.transfer( | ||
{ | ||
Token: 'ACA', | ||
}, | ||
1e12, | ||
{ | ||
V3: { | ||
parents: 1, | ||
interior: { | ||
X2: [ | ||
{ | ||
Parachain: 2092, | ||
}, | ||
{ | ||
AccountId32: { | ||
id: alice.addressRaw, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
{ | ||
Unlimited: null, | ||
}, | ||
) | ||
.signAndSend(alice) | ||
|
||
await acala.dev.newBlock() | ||
await checkSystemEvents(acala, 'xcmpQueue', 'XcmpMessageSent').toMatchSnapshot() | ||
|
||
await zeitgeist.dev.newBlock() | ||
await checkSystemEvents(zeitgeist, 'xcmpQueue', 'Fail').toMatchSnapshot() | ||
|
||
await acala.teardown() | ||
await zeitgeist.teardown() | ||
}) | ||
}) |