Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: set registries to NPM for AssetTransferApi #363

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/AssetTransferApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ const mockSubmittableExt = mockSystemApi.registry.createType(
'0xfc041f0801010100411f0100010100c224aad9c6f3bbd784120e9fceee5bfd22a62c69144ee673f76d6a34d280de160104000002043205040091010000000000',
) as SubmittableExtrinsic<'promise', ISubmittableResult>;

const systemAssetsApi = new AssetTransferApi(adjustedMockSystemApi, 'statemine', 2);
const relayAssetsApi = new AssetTransferApi(adjustedMockRelayApi, 'kusama', 2);
const moonriverAssetsApi = new AssetTransferApi(adjustedMockMoonriverParachainApi, 'moonriver', 2);
const systemAssetsApi = new AssetTransferApi(adjustedMockSystemApi, 'statemine', 2, { registryType: 'NPM' });
const relayAssetsApi = new AssetTransferApi(adjustedMockRelayApi, 'kusama', 2, { registryType: 'NPM' });
const moonriverAssetsApi = new AssetTransferApi(adjustedMockMoonriverParachainApi, 'moonriver', 2, {
registryType: 'NPM',
});

describe('AssetTransferAPI', () => {
describe('establishDirection', () => {
Expand Down Expand Up @@ -421,6 +423,7 @@ describe('AssetTransferAPI', () => {
};
const mockSystemAssetsApi = new AssetTransferApi(adjustedMockSystemApi, 'statemine', 2, {
injectedRegistry,
registryType: 'NPM',
});

expect(mockSystemAssetsApi.opts.injectedRegistry).toStrictEqual(injectedRegistry);
Expand Down
10 changes: 7 additions & 3 deletions src/createXcmTypes/util/getAssetId.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getAssetId } from './getAssetId';
describe('getAssetId', () => {
describe('Statemine', () => {
const registry = new Registry('statemine', {});
const systemAssetsApi = new AssetTransferApi(adjustedMockSystemApi, 'statemine', 2);
const systemAssetsApi = new AssetTransferApi(adjustedMockSystemApi, 'statemine', 2, { registryType: 'NPM' });
it('Should correctly return the integer assetId when given a valid native system chain token symbol', async () => {
const expected = '10';

Expand Down Expand Up @@ -53,7 +53,9 @@ describe('getAssetId', () => {

describe('Bifrost', () => {
const registry = new Registry('bifrost', {});
const bifrostAssetsApi = new AssetTransferApi(adjustedMockBifrostParachainApi, 'bifrost', 2);
const bifrostAssetsApi = new AssetTransferApi(adjustedMockBifrostParachainApi, 'bifrost', 2, {
registryType: 'NPM',
});

it('Should correctly return the xcAsset multilocation when given a valid asset symbol', async () => {
const expected = '{"v1":{"parents":1,"interior":{"x2":[{"parachain":2023},{"palletInstance":10}]}}}';
Expand All @@ -72,7 +74,9 @@ describe('getAssetId', () => {

describe('Moonriver', () => {
const registry = new Registry('moonriver', {});
const moonriverAssetsApi = new AssetTransferApi(adjustedMockMoonriverParachainApi, 'bifrost', 2);
const moonriverAssetsApi = new AssetTransferApi(adjustedMockMoonriverParachainApi, 'bifrost', 2, {
registryType: 'NPM',
});

it('Should correctly return the xcAsset integer assetId when given a valid xcAsset symbol', async () => {
const expected = '42259045809535163221576417993425387648';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { adjustedMockMoonriverParachainApi } from '../../testHelpers/adjustedMoc
import { getXcAssetMultiLocationByAssetId } from './getXcAssetMultiLocationByAssetId';

const bifrostRegistry = new Registry('bifrost', {});
const bifrostApi = new AssetTransferApi(adjustedMockBifrostParachainApi, 'bifrost', 3);
const bifrostApi = new AssetTransferApi(adjustedMockBifrostParachainApi, 'bifrost', 3, { registryType: 'NPM' });

const moonriverRegistry = new Registry('moonriver', {});
const moonriverApi = new AssetTransferApi(adjustedMockMoonriverParachainApi, 'moonriver', 2);
const moonriverApi = new AssetTransferApi(adjustedMockMoonriverParachainApi, 'moonriver', 2, { registryType: 'NPM' });

describe('getXcAssetMultiLocationByAssetId', () => {
describe('Bifrost', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/errors/checkLocalTxInput/checkLocalTxInput.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('checkLocalTxInput', () => {
const registry = new Registry('statemine', {});
const specName = 'statemine';

const systemAssetsApi = new AssetTransferApi(adjustedMockSystemApi, 'statemine', 2);
const systemAssetsApi = new AssetTransferApi(adjustedMockSystemApi, 'statemine', 2, { registryType: 'NPM' });

it('Should correctly return Balances with an empty assetIds', async () => {
const res = await checkLocalTxInput(systemAssetsApi.api, [], ['10000'], specName, registry, 2, false, false);
Expand Down
4 changes: 3 additions & 1 deletion src/errors/checkXcmTxInputs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import {
CheckXTokensPalletOriginIsNonForeignAssetTx,
} from './checkXcmTxInputs';

const parachainAssetsApi = new AssetTransferApi(adjustedMockMoonriverParachainApi, 'moonriver', 2);
const parachainAssetsApi = new AssetTransferApi(adjustedMockMoonriverParachainApi, 'moonriver', 2, {
registryType: 'NPM',
});
const runTests = async (tests: Test[]) => {
for (const test of tests) {
const [specName, testInputs, direction, errorMessage] = test;
Expand Down
4 changes: 2 additions & 2 deletions src/integrationTests/AssetsTransferApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { adjustedMockRelayApi } from '../testHelpers/adjustedMockRelayApi';
import { adjustedMockSystemApi } from '../testHelpers/adjustedMockSystemApi';
import type { Format, TxResult } from '../types';

const relayAssetsApi = new AssetTransferApi(adjustedMockRelayApi, 'kusama', 2);
const systemAssetsApi = new AssetTransferApi(adjustedMockSystemApi, 'statemine', 2);
const relayAssetsApi = new AssetTransferApi(adjustedMockRelayApi, 'kusama', 2, { registryType: 'NPM' });
const systemAssetsApi = new AssetTransferApi(adjustedMockSystemApi, 'statemine', 2, { registryType: 'NPM' });

describe('AssetTransferApi Integration Tests', () => {
describe('createTransferTransaction', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/integrationTests/parachains/bifrost.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { paraTransferMultiassets as bifrostTransferMultiassets } from '../util';
import { paraTransferMultiassetWithFee as bifrostTransferMultiassetWithFee } from '../util';
import { paraTeleportNativeAsset as bifrsotTeleportNativeAsset } from '../util';

const bifrostATA = new AssetTransferApi(adjustedMockBifrostParachainApi, 'bifrost', 2);
const bifrostATA = new AssetTransferApi(adjustedMockBifrostParachainApi, 'bifrost', 2, { registryType: 'NPM' });

describe('Bifrost', () => {
describe('ParaToPara', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/integrationTests/parachains/moonriver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { paraTransferMultiassets as moonriverTransferMultiassets } from '../util
import { paraTransferMultiassetWithFee as moonriverTransferMultiassetWithFee } from '../util';
import { paraTeleportNativeAsset as moonriverTeleportNativeAsset } from '../util';

const moonriverATA = new AssetTransferApi(adjustedMockMoonriverParachainApi, 'moonriver', 2);
const moonriverATA = new AssetTransferApi(adjustedMockMoonriverParachainApi, 'moonriver', 2, { registryType: 'NPM' });

describe('Moonriver', () => {
describe('ParaToPara', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/util/getFeeAssetItemIndex.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ type Test = [
];

describe('getFeeAssetItemIndex', () => {
const systemAssetsApi = new AssetTransferApi(adjustedMockSystemApi, 'statemine', 2);
const relayAssetsApi = new AssetTransferApi(adjustedMockRelayApi, 'kusama', 2);
const systemAssetsApi = new AssetTransferApi(adjustedMockSystemApi, 'statemine', 2, { registryType: 'NPM' });
const relayAssetsApi = new AssetTransferApi(adjustedMockRelayApi, 'kusama', 2, { registryType: 'NPM' });
const registry = new Registry('statemine', {});

it('Should select and return the index of the correct multiassets when given their token symbols', async () => {
Expand Down