Skip to content

Commit

Permalink
first mvp
Browse files Browse the repository at this point in the history
  • Loading branch information
Ad96el committed May 31, 2024
1 parent 482a23d commit d6c3f03
Show file tree
Hide file tree
Showing 15 changed files with 534 additions and 307 deletions.
4 changes: 2 additions & 2 deletions integration-tests/chopsticks/src/helper/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export const xtokens = {
},
}),
transfer:
(token: any, amount: any, dest: (dest: any) => any, weight: any = 'Unlimited') =>
({ api }: { api: ApiPromise }, acc: any) =>
(token: any, dest: (dest: any) => any, weight: any = 'Unlimited') =>
({ api }: { api: ApiPromise }, acc: any, amount: any) =>
api.tx.xTokens.transfer(token, amount, dest(acc), weight),
}

Expand Down
8 changes: 7 additions & 1 deletion integration-tests/chopsticks/src/network/polkadot/hydraDx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import { SetupOption } from '@acala-network/chopsticks-testing'
import { initialBalanceHDX, initialBalanceKILT, toNumber } from '../../helper/utils.js'

/// Options used to create the HydraDx context
export const getSetupOptions = (blockNumber: number | undefined = undefined) =>
export const getSetupOptions = (
blockNumber: number | undefined = undefined,
wasmOverride: string | undefined = undefined
) =>
({
endpoint: process.env.HYDRADX_WS || ['wss://hydradx-rpc.dwellir.com', 'wss://rpc.hydradx.cloud'],
db: './db/hydradx.db.sqlite',
port: toNumber(process.env.HYDRADX_PORT) || 9001,
blockNumber,
wasmOverride,
}) as SetupOption

export const kiltTokenId = 28
Expand Down Expand Up @@ -39,6 +43,8 @@ export function assignKiltTokensToAccounts(addr: string[], balance: bigint = ini
}
}

export const KILTLocation = { Concrete: { parents: 1, interior: { X1: [{ Parachain: 2086 }] } } }

/// HydraDX ParaId
export const paraId = 2034

Expand Down
29 changes: 23 additions & 6 deletions integration-tests/chopsticks/src/network/polkadot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,28 @@ import * as PolkadotConfig from './relay.js'
import * as HydraDxConfig from './hydraDx.js'
import { ChainConfigs } from '../types.js'

const BLOCK_NUMBER_SPIRITNET = 5_000_000
const BLOCK_NUMBER_HYDRADX_POLKADOT = 4_000_000
function getEnvVariable(name: string): number {
const value = process.env[name]
if (value === undefined) {
throw new Error(`Environment variable ${name} is not set.`)
}
return Number(value)
}

export const chainConfigs: ChainConfigs = {
spiritnet: { config: SpiritnetConfig.getSetupOptions, blockNumber: BLOCK_NUMBER_SPIRITNET, name: 'spiritnet' },
hydraDx: { config: HydraDxConfig.getSetupOptions, blockNumber: BLOCK_NUMBER_HYDRADX_POLKADOT, name: 'hydradx' },
polkadot: { config: PolkadotConfig.getSetupOptions, blockNumber: BLOCK_NUMBER_HYDRADX_POLKADOT, name: 'polkadot' },
export const all: ChainConfigs = {
spiritnet: {
config: SpiritnetConfig.getSetupOptions,
blockNumber: getEnvVariable('SPIRITNET_BLOCK_NUMBER'),
name: 'spiritnet',
},
hydraDx: {
config: HydraDxConfig.getSetupOptions,
blockNumber: getEnvVariable('HYDRADX_BLOCK_NUMBER'),
name: 'hydradx',
},
polkadot: {
config: PolkadotConfig.getSetupOptions,
blockNumber: getEnvVariable('POLKADOT_BLOCK_NUMBER'),
name: 'polkadot',
},
}
6 changes: 5 additions & 1 deletion integration-tests/chopsticks/src/network/polkadot/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import type { SetupOption } from '@acala-network/chopsticks-testing'
import { initialBalanceDOT, toNumber } from '../../helper/utils.js'

/// Options used to create the HydraDx context
export const getSetupOptions = (blockNumber: number | undefined = undefined) =>
export const getSetupOptions = (
blockNumber: number | undefined = undefined,
wasmOverride: string | undefined = undefined
) =>
({
endpoint: process.env.POLKADOT_WS || [
'wss://rpc.polkadot.io',
Expand All @@ -13,6 +16,7 @@ export const getSetupOptions = (blockNumber: number | undefined = undefined) =>
db: './db/polkadot.db.sqlite',
port: toNumber(process.env.POLKADOT_PORT) || 9000,
blockNumber,
wasmOverride,
}) as SetupOption

/// Assigns the native tokens to an accounts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import { SetupOption } from '@acala-network/chopsticks-testing'
import { initialBalanceKILT, toNumber } from '../../helper/utils.js'

/// Options used to create the Spiritnet context
export const getSetupOptions = (blockNumber: number | undefined = undefined) =>
export const getSetupOptions = (
blockNumber: number | undefined = undefined,
wasmOverride: string | undefined = undefined
) =>
({
endpoint: process.env.SPIRITNET_WS || 'wss://kilt-rpc.dwellir.com',
db: './db/spiritnet.db.sqlite',
port: toNumber(process.env.SPIRITNET_PORT) || 9002,
wasmOverride,
blockNumber,
}) as SetupOption

Expand Down
5 changes: 3 additions & 2 deletions integration-tests/chopsticks/src/network/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import type { SetupOption, setupContext } from '@acala-network/chopsticks-testin
export type Config = Awaited<ReturnType<typeof setupContext>>

export interface Chain {
config: (blockNumber?: number | undefined) => SetupOption
blockNumber: number
config: (blockNumber?: number, wasmOverride?: string) => SetupOption
blockNumber?: number
wasmOverride?: string
name: string
}

Expand Down
1 change: 1 addition & 0 deletions integration-tests/chopsticks/src/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export async function shutDownNetwork(chains: Config[]) {
}

export async function setupNetwork(relayChain: SetupOption, sender: SetupOption, receiver: SetupOption) {
await setTimeout(50)
const relayChainContext = await setupContext(relayChain)
const senderChainContext = await setupContext(sender)
const receiverChainContext = await setupContext(receiver)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Limited Reserve Transfers > Kilt -> HydraDx at block > receiver events "currencies" 1`] = `
[
{
"data": {
"amount": "(rounded 1000000000000000)",
"currencyId": 28,
"who": "7MZG43idRmdg8VSt5BS9mVJeBhhxxt5y55hCsMpoKp5xFQX2",
},
"method": "Deposited",
"section": "currencies",
},
{
"data": {
"amount": "(rounded 4100000000000)",
"currencyId": 28,
"who": "7L53bUTBopuwFt3mKUfmkzgGLayYa1Yvn1hAg9v5UMrQzTfh",
},
"method": "Deposited",
"section": "currencies",
},
]
`;

exports[`Limited Reserve Transfers > Kilt -> HydraDx at block > receiver events "tokens" 1`] = `
[
{
"data": {
"amount": "(rounded 1000000000000000)",
"currencyId": 28,
"who": "7MZG43idRmdg8VSt5BS9mVJeBhhxxt5y55hCsMpoKp5xFQX2",
},
"method": "Endowed",
"section": "tokens",
},
{
"data": {
"amount": "(rounded 1000000000000000)",
"currencyId": 28,
"who": "7MZG43idRmdg8VSt5BS9mVJeBhhxxt5y55hCsMpoKp5xFQX2",
},
"method": "Deposited",
"section": "tokens",
},
{
"data": {
"amount": "(rounded 4100000000000)",
"currencyId": 28,
"who": "7L53bUTBopuwFt3mKUfmkzgGLayYa1Yvn1hAg9v5UMrQzTfh",
},
"method": "Deposited",
"section": "tokens",
},
]
`;

exports[`Limited Reserve Transfers > Kilt -> HydraDx at block > receiver events "xcmpQueue" 1`] = `
[
{
"data": {
"messageHash": "(hash)",
"messageId": "(hash)",
"weight": {
"proofSize": 0,
"refTime": 400000000,
},
},
"method": "Success",
"section": "xcmpQueue",
},
]
`;

exports[`Limited Reserve Transfers > Kilt -> HydraDx at block > sender events "polkadotXcm" 1`] = `
[
{
"data": {
"outcome": {
"Complete": {
"proofSize": 0,
"refTime": 400000000,
},
},
},
"method": "Attempted",
"section": "polkadotXcm",
},
]
`;

exports[`Limited Reserve Transfers > Kilt -> HydraDx at block > sender events "xcmpQueue" 1`] = `
[
{
"data": {
"messageHash": "(hash)",
},
"method": "XcmpMessageSent",
"section": "xcmpQueue",
},
]
`;

exports[`Limited Reserve Transfers > Kilt -> HydraDx at block > sender events {"section":"balances","method":"Withdraw"} 1`] = `
[
{
"data": {
"amount": "(rounded 170000000000)",
"who": "4seWojfEHrk5YKPahdErazQ3CWEHZYi6NV4gKz5AaejWbRPJ",
},
"method": "Withdraw",
"section": "balances",
},
]
`;

exports[`Limited Reserve Transfers > Kilt -> HydraDx live status > receiver events "xcmpQueue" 1`] = `
[
{
"data": {
"messageHash": "(hash)",
"messageId": "(hash)",
"weight": {
"proofSize": 0,
"refTime": 400000000,
},
},
"method": "Success",
"section": "xcmpQueue",
},
]
`;

exports[`Limited Reserve Transfers > Kilt -> HydraDx live status > sender events "polkadotXcm" 1`] = `
[
{
"data": {
"outcome": {
"Complete": {
"proofSize": 0,
"refTime": 400000000,
},
},
},
"method": "Attempted",
"section": "polkadotXcm",
},
]
`;

exports[`Limited Reserve Transfers > Kilt -> HydraDx live status > sender events "xcmpQueue" 1`] = `
[
{
"data": {
"messageHash": "(hash)",
},
"method": "XcmpMessageSent",
"section": "xcmpQueue",
},
]
`;

This file was deleted.

Loading

0 comments on commit d6c3f03

Please sign in to comment.