Skip to content

Commit

Permalink
Moving mocha types to external file
Browse files Browse the repository at this point in the history
  • Loading branch information
tsenovilla committed Nov 5, 2024
1 parent d9956d5 commit f5fc96b
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 64 deletions.
66 changes: 66 additions & 0 deletions e2e-tests/tests/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { Suite } from "mocha";
import { MultiAddress, AccountId } from "@polkadot/types/interfaces";
import { XcmVersionedLocation, StagingXcmV3MultiLocation } from "@polkadot/types/lookup";
import { KeyringPair } from "@polkadot/keyring/types";
import { ApiPromise } from "@polkadot/api";
import { ethers } from "ethers";
import Web3 from "web3";

type assetHubItems = {
accounts: {
alice: AccountId;
bob: AccountId;
charlie: AccountId;
dave: AccountId;
eve: AccountId;
ferdie: AccountId;
};
multiAddresses: {
alice: MultiAddress;
bob: MultiAddress;
charlie: MultiAddress;
dave: MultiAddress;
eve: MultiAddress;
ferdie: MultiAddress;
laosSA: MultiAddress;
};
laosSA: string;
laosLocation: XcmVersionedLocation;
laosAsset: StagingXcmV3MultiLocation;
relayChainLocation: XcmVersionedLocation;
relayAsset: StagingXcmV3MultiLocation;
};

type laosItems = {
assetHubLocation: XcmVersionedLocation;
relayChainLocation: XcmVersionedLocation;
};

type substratePairs = {
alice: KeyringPair;
bob: KeyringPair;
charlie: KeyringPair;
dave: KeyringPair;
eve: KeyringPair;
ferdie: KeyringPair;
};

type ethereumPairs = {
alith: KeyringPair;
baltathar: KeyringPair;
faith: KeyringPair;
};

type describeContext = {
web3: Web3;
ethersjs: ethers.JsonRpcProvider;
networks: { laos: ApiPromise; assetHub: ApiPromise; relaychain: ApiPromise };
};

export interface CustomSuiteContext extends Suite {
context: describeContext;
substratePairs: substratePairs;
ethereumPairs: ethereumPairs;
laosItems: laosItems;
assetHubItems: assetHubItems;
}
66 changes: 2 additions & 64 deletions e2e-tests/tests/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ethers } from "ethers";
import Contract from "web3-eth-contract";
import Web3 from "web3";
import { JsonRpcResponse } from "web3-core-helpers";
Expand All @@ -18,21 +17,19 @@ import {
LAOS_PARA_ID,
ASSET_HUB_PARA_ID,
} from "./config";
import { CustomSuiteContext } from "./types";
import BN from "bn.js";
import { expect } from "chai";
import { Suite } from "mocha";
import "@polkadot/api-augment";

import { ApiPromise, HttpProvider } from "@polkadot/api";
import { bnToU8a, stringToU8a } from "@polkadot/util";
import { encodeAddress } from "@polkadot/util-crypto";
import { AssetIdV3, DoubleEncodedCall, EventRecord, XcmOriginKind } from "@polkadot/types/interfaces";
import { XcmVersionedXcm, XcmVersionedLocation, StagingXcmV3MultiLocation } from "@polkadot/types/lookup";
import { XcmVersionedXcm } from "@polkadot/types/lookup";
import { Keyring } from "@polkadot/api";
import { KeyringPair } from "@polkadot/keyring/types";

import { MultiAddress, AccountId } from "@polkadot/types/interfaces";

import debug from "debug";

require("events").EventEmitter.prototype._maxListeners = 100;
Expand Down Expand Up @@ -60,65 +57,6 @@ export async function customRequest(web3: Web3, method: string, params: any[]) {
});
}

type assetHubItems = {
accounts: {
alice: AccountId;
bob: AccountId;
charlie: AccountId;
dave: AccountId;
eve: AccountId;
ferdie: AccountId;
};
multiAddresses: {
alice: MultiAddress;
bob: MultiAddress;
charlie: MultiAddress;
dave: MultiAddress;
eve: MultiAddress;
ferdie: MultiAddress;
laosSA: MultiAddress;
};
laosSA: string;
laosLocation: XcmVersionedLocation;
laosAsset: StagingXcmV3MultiLocation;
relayChainLocation: XcmVersionedLocation;
relayAsset: StagingXcmV3MultiLocation;
};

type laosItems = {
assetHubLocation: XcmVersionedLocation;
relayChainLocation: XcmVersionedLocation;
};

type substratePairs = {
alice: KeyringPair;
bob: KeyringPair;
charlie: KeyringPair;
dave: KeyringPair;
eve: KeyringPair;
ferdie: KeyringPair;
};

type ethereumPairs = {
alith: KeyringPair;
baltathar: KeyringPair;
faith: KeyringPair;
};

type describeContext = {
web3: Web3;
ethersjs: ethers.JsonRpcProvider;
networks: { laos: ApiPromise; assetHub: ApiPromise; relaychain: ApiPromise };
};

interface CustomSuiteContext extends Suite {
context: describeContext;
substratePairs: substratePairs;
ethereumPairs: ethereumPairs;
laosItems: laosItems;
assetHubItems: assetHubItems;
}

export function describeWithExistingNode(
title: string,
cb: () => void,
Expand Down

0 comments on commit f5fc96b

Please sign in to comment.