difftreelog
test fix pallet-tokens field name change
in: master
4 files changed
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -63,14 +63,14 @@
export async function isQuartz(): Promise<boolean> {
return usingApi(async api => {
const chain = await api.rpc.system.chain();
-
+
return chain.eq('QUARTZ');
});
}
let modulesNames: any;
export function getModuleNames(api: ApiPromise): string[] {
- if (typeof modulesNames === 'undefined')
+ if (typeof modulesNames === 'undefined')
modulesNames = api.runtimeMetadata.asLatest.pallets.map(m => m.name.toString().toLowerCase());
return modulesNames;
}
@@ -304,7 +304,7 @@
export function getCreateItemsResult(events: EventRecord[]): CreateItemResult[] {
const results: CreateItemResult[] = [];
-
+
const genericResult = getGenericResult<CreateItemResult[]>(events, 'common', 'ItemCreated', (data) => {
const collectionId = parseInt(data[0].toString(), 10);
const itemId = parseInt(data[1].toString(), 10);
@@ -329,15 +329,15 @@
export function getCreateItemResult(events: EventRecord[]): CreateItemResult {
const genericResult = getGenericResult(events, 'common', 'ItemCreated', (data) => data.map(function(value) { return value.toJSON(); }));
-
- if (genericResult.data == null)
+
+ if (genericResult.data == null)
return {
success: genericResult.success,
collectionId: 0,
itemId: 0,
amount: 0,
};
- else
+ else
return {
success: genericResult.success,
collectionId: genericResult.data[0] as number,
@@ -349,7 +349,7 @@
export function getDestroyItemsResult(events: EventRecord[]): DestroyItemResult[] {
const results: DestroyItemResult[] = [];
-
+
const genericResult = getGenericResult<DestroyItemResult[]>(events, 'common', 'ItemDestroyed', (data) => {
const collectionId = parseInt(data[0].toString(), 10);
const itemId = parseInt(data[1].toString(), 10);
@@ -1151,9 +1151,9 @@
expect(blockNumber).to.be.greaterThan(0);
const scheduleTx = api.tx.scheduler.scheduleNamed( // schedule
scheduledId,
- expectedBlockNumber,
- repetitions > 1 ? [period, repetitions] : null,
- 0,
+ expectedBlockNumber,
+ repetitions > 1 ? [period, repetitions] : null,
+ 0,
{Value: operationTx as any},
);
@@ -1178,13 +1178,13 @@
expect(blockNumber).to.be.greaterThan(0);
const scheduleTx = api.tx.scheduler.scheduleNamed( // schedule
scheduledId,
- expectedBlockNumber,
- repetitions <= 1 ? null : [period, repetitions],
- 0,
+ expectedBlockNumber,
+ repetitions <= 1 ? null : [period, repetitions],
+ 0,
{Value: operationTx as any},
);
- //const events =
+ //const events =
await expect(submitTransactionExpectFailAsync(sender, scheduleTx)).to.be.rejected;
//expect(getGenericResult(events).success).to.be.false;
});
@@ -1248,7 +1248,7 @@
const transferTx = api.tx.balances.transfer(recipient.address, amount);
const balanceBefore = await getFreeBalance(recipient);
-
+
await scheduleExpectSuccess(transferTx, sender, blockSchedule, scheduledId, period, repetitions);
expect(await getFreeBalance(recipient)).to.be.equal(balanceBefore);
tests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth--- a/tests/src/xcm/xcmQuartz.test.ts
+++ b/tests/src/xcm/xcmQuartz.test.ts
@@ -64,7 +64,7 @@
describe_xcm('[XCM] Integration test: Exchanging tokens with Karura', () => {
let alice: IKeyringPair;
let randomAccount: IKeyringPair;
-
+
let balanceQuartzTokenInit: bigint;
let balanceQuartzTokenMiddle: bigint;
let balanceQuartzTokenFinal: bigint;
@@ -74,7 +74,7 @@
let balanceQuartzForeignTokenInit: bigint;
let balanceQuartzForeignTokenMiddle: bigint;
let balanceQuartzForeignTokenFinal: bigint;
-
+
before(async () => {
await usingApi(async (api, privateKeyWrapper) => {
const keyringSr25519 = new Keyring({type: 'sr25519'});
@@ -96,50 +96,50 @@
],
},
};
-
+
const metadata = {
name: 'QTZ',
symbol: 'QTZ',
decimals: 18,
minimalBalance: 1,
};
-
+
const tx = api.tx.assetRegistry.registerForeignAsset(destination, metadata);
const sudoTx = api.tx.sudo.sudo(tx as any);
const events = await submitTransactionAsync(alice, sudoTx);
const result = getGenericResult(events);
expect(result.success).to.be.true;
-
+
const tx1 = api.tx.balances.transfer(randomAccount.address, 10000000000000n);
const events1 = await submitTransactionAsync(alice, tx1);
const result1 = getGenericResult(events1);
expect(result1.success).to.be.true;
-
+
[balanceKaruraTokenInit] = await getBalance(api, [randomAccount.address]);
{
- const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;
+ const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAssetId: 0})).toJSON() as any;
balanceQuartzForeignTokenInit = BigInt(free);
}
},
karuraOptions(),
);
-
+
// Quartz side
await usingApi(async (api) => {
const tx0 = api.tx.balances.transfer(randomAccount.address, 10n * TRANSFER_AMOUNT);
const events0 = await submitTransactionAsync(alice, tx0);
const result0 = getGenericResult(events0);
expect(result0.success).to.be.true;
-
+
[balanceQuartzTokenInit] = await getBalance(api, [randomAccount.address]);
});
});
-
+
it('Should connect and send QTZ to Karura', async () => {
-
+
// Quartz side
await usingApi(async (api) => {
-
+
const destination = {
V0: {
X2: [
@@ -150,7 +150,7 @@
],
},
};
-
+
const beneficiary = {
V0: {
X1: {
@@ -161,7 +161,7 @@
},
},
};
-
+
const assets = {
V1: [
{
@@ -177,32 +177,32 @@
},
],
};
-
+
const feeAssetItem = 0;
-
+
const weightLimit = {
Limited: 5000000000,
};
-
+
const tx = api.tx.polkadotXcm.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);
const events = await submitTransactionAsync(randomAccount, tx);
const result = getGenericResult(events);
expect(result.success).to.be.true;
-
+
[balanceQuartzTokenMiddle] = await getBalance(api, [randomAccount.address]);
-
+
const qtzFees = balanceQuartzTokenInit - balanceQuartzTokenMiddle - TRANSFER_AMOUNT;
console.log('[Quartz -> Karura] transaction fees on Quartz: %s QTZ', bigIntToDecimals(qtzFees));
expect(qtzFees > 0n).to.be.true;
});
-
+
// Karura side
await usingApi(
async (api) => {
await waitNewBlocks(api, 3);
- const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;
+ const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAssetId: 0})).toJSON() as any;
balanceQuartzForeignTokenMiddle = BigInt(free);
-
+
[balanceKaruraTokenMiddle] = await getBalance(api, [randomAccount.address]);
const karFees = balanceKaruraTokenInit - balanceKaruraTokenMiddle;
@@ -219,9 +219,9 @@
karuraOptions(),
);
});
-
+
it('Should connect to Karura and send QTZ back', async () => {
-
+
// Karura side
await usingApi(
async (api) => {
@@ -241,24 +241,24 @@
},
},
};
-
+
const id = {
- ForeignAsset: 0,
+ ForeignAssetId: 0,
};
const destWeight = 50000000;
-
+
const tx = api.tx.xTokens.transfer(id as any, TRANSFER_AMOUNT, destination, destWeight);
const events = await submitTransactionAsync(randomAccount, tx);
const result = getGenericResult(events);
expect(result.success).to.be.true;
-
+
[balanceKaruraTokenFinal] = await getBalance(api, [randomAccount.address]);
{
- const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;
+ const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAssetId: 0})).toJSON() as any;
balanceQuartzForeignTokenFinal = BigInt(free);
}
-
+
const karFees = balanceKaruraTokenMiddle - balanceKaruraTokenFinal;
const qtzOutcomeTransfer = balanceQuartzForeignTokenMiddle - balanceQuartzForeignTokenFinal;
@@ -277,13 +277,13 @@
// Quartz side
await usingApi(async (api) => {
await waitNewBlocks(api, 3);
-
+
[balanceQuartzTokenFinal] = await getBalance(api, [randomAccount.address]);
const actuallyDelivered = balanceQuartzTokenFinal - balanceQuartzTokenMiddle;
expect(actuallyDelivered > 0).to.be.true;
console.log('[Karura -> Quartz] actually delivered %s QTZ', bigIntToDecimals(actuallyDelivered));
-
+
const qtzFees = TRANSFER_AMOUNT - actuallyDelivered;
console.log('[Karura -> Quartz] transaction fees on Quartz: %s QTZ', bigIntToDecimals(qtzFees));
expect(qtzFees == 0n).to.be.true;
@@ -300,7 +300,7 @@
alice = privateKeyWrapper('//Alice');
});
});
-
+
it('Quartz rejects tokens from the Relay', async () => {
await usingApi(async (api) => {
const destination = {
tests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth117 117118 [balanceAcalaTokenInit] = await getBalance(api, [randomAccount.address]);118 [balanceAcalaTokenInit] = await getBalance(api, [randomAccount.address]);119 {119 {120 const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;120 const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAssetId: 0})).toJSON() as any;121 balanceUniqueForeignTokenInit = BigInt(free);121 balanceUniqueForeignTokenInit = BigInt(free);122 }122 }123 },123 },200 await usingApi(200 await usingApi(201 async (api) => {201 async (api) => {202 await waitNewBlocks(api, 3);202 await waitNewBlocks(api, 3);203 const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;203 const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAssetId: 0})).toJSON() as any;204 balanceUniqueForeignTokenMiddle = BigInt(free);204 balanceUniqueForeignTokenMiddle = BigInt(free);205 205206 [balanceAcalaTokenMiddle] = await getBalance(api, [randomAccount.address]);206 [balanceAcalaTokenMiddle] = await getBalance(api, [randomAccount.address]);243 };243 };244 244245 const id = {245 const id = {246 ForeignAsset: 0,246 ForeignAssetId: 0,247 };247 };248248249 const destWeight = 50000000;249 const destWeight = 50000000;255 255256 [balanceAcalaTokenFinal] = await getBalance(api, [randomAccount.address]);256 [balanceAcalaTokenFinal] = await getBalance(api, [randomAccount.address]);257 {257 {258 const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;258 const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAssetId: 0})).toJSON() as any;259 balanceUniqueForeignTokenFinal = BigInt(free);259 balanceUniqueForeignTokenFinal = BigInt(free);260 }260 }261 261tests/src/xcmTransfer.test.tsdiffbeforeafterboth--- a/tests/src/xcmTransfer.test.ts
+++ b/tests/src/xcmTransfer.test.ts
@@ -78,7 +78,7 @@
let balanceOnKaruraBefore: bigint;
await usingApi(async (api) => {
- const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAsset: 0})).toJSON() as any;
+ const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAssetId: 0})).toJSON() as any;
balanceOnKaruraBefore = free;
}, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});
@@ -136,7 +136,7 @@
await usingApi(async (api) => {
// todo do something about instant sealing, where there might not be any new blocks
await waitNewBlocks(api, 3);
- const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAsset: 0})).toJSON() as any;
+ const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAssetId: 0})).toJSON() as any;
expect(free > balanceOnKaruraBefore).to.be.true;
}, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});
});
@@ -165,7 +165,7 @@
};
const id = {
- ForeignAsset: 0,
+ ForeignAssetId: 0,
};
const amount = TRANSFER_AMOUNT;