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.tsdiffbeforeafterboth--- a/tests/src/xcm/xcmUnique.test.ts
+++ b/tests/src/xcm/xcmUnique.test.ts
@@ -64,7 +64,7 @@
describe_xcm('[XCM] Integration test: Exchanging tokens with Acala', () => {
let alice: IKeyringPair;
let randomAccount: IKeyringPair;
-
+
let balanceUniqueTokenInit: bigint;
let balanceUniqueTokenMiddle: bigint;
let balanceUniqueTokenFinal: bigint;
@@ -74,7 +74,7 @@
let balanceUniqueForeignTokenInit: bigint;
let balanceUniqueForeignTokenMiddle: bigint;
let balanceUniqueForeignTokenFinal: bigint;
-
+
before(async () => {
await usingApi(async (api, privateKeyWrapper) => {
const keyringSr25519 = new Keyring({type: 'sr25519'});
@@ -96,50 +96,50 @@
],
},
};
-
+
const metadata = {
name: 'UNQ',
symbol: 'UNQ',
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;
-
+
[balanceAcalaTokenInit] = 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;
balanceUniqueForeignTokenInit = BigInt(free);
}
},
acalaOptions(),
);
-
+
// Unique 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;
-
+
[balanceUniqueTokenInit] = await getBalance(api, [randomAccount.address]);
});
});
-
+
it('Should connect and send UNQ to Acala', async () => {
-
+
// Unique 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;
-
+
[balanceUniqueTokenMiddle] = await getBalance(api, [randomAccount.address]);
-
+
const unqFees = balanceUniqueTokenInit - balanceUniqueTokenMiddle - TRANSFER_AMOUNT;
console.log('[Unique -> Acala] transaction fees on Unique: %s UNQ', bigIntToDecimals(unqFees));
expect(unqFees > 0n).to.be.true;
});
-
+
// Acala 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;
balanceUniqueForeignTokenMiddle = BigInt(free);
-
+
[balanceAcalaTokenMiddle] = await getBalance(api, [randomAccount.address]);
const acaFees = balanceAcalaTokenInit - balanceAcalaTokenMiddle;
@@ -219,9 +219,9 @@
acalaOptions(),
);
});
-
+
it('Should connect to Acala and send UNQ back', async () => {
-
+
// Acala 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;
-
+
[balanceAcalaTokenFinal] = 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;
balanceUniqueForeignTokenFinal = BigInt(free);
}
-
+
const acaFees = balanceAcalaTokenMiddle - balanceAcalaTokenFinal;
const unqOutcomeTransfer = balanceUniqueForeignTokenMiddle - balanceUniqueForeignTokenFinal;
@@ -277,13 +277,13 @@
// Unique side
await usingApi(async (api) => {
await waitNewBlocks(api, 3);
-
+
[balanceUniqueTokenFinal] = await getBalance(api, [randomAccount.address]);
const actuallyDelivered = balanceUniqueTokenFinal - balanceUniqueTokenMiddle;
expect(actuallyDelivered > 0).to.be.true;
console.log('[Acala -> Unique] actually delivered %s UNQ', bigIntToDecimals(actuallyDelivered));
-
+
const unqFees = TRANSFER_AMOUNT - actuallyDelivered;
console.log('[Acala -> Unique] transaction fees on Unique: %s UNQ', bigIntToDecimals(unqFees));
expect(unqFees == 0n).to.be.true;
@@ -300,7 +300,7 @@
alice = privateKeyWrapper('//Alice');
});
});
-
+
it('Unique rejects tokens from the Relay', async () => {
await usingApi(async (api) => {
const destination = {
tests/src/xcmTransfer.test.tsdiffbeforeafterboth78 let balanceOnKaruraBefore: bigint;78 let balanceOnKaruraBefore: bigint;797980 await usingApi(async (api) => {80 await usingApi(async (api) => {81 const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAsset: 0})).toJSON() as any;81 const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAssetId: 0})).toJSON() as any;82 balanceOnKaruraBefore = free;82 balanceOnKaruraBefore = free;83 }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});83 }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});8484136 await usingApi(async (api) => {136 await usingApi(async (api) => {137 // todo do something about instant sealing, where there might not be any new blocks137 // todo do something about instant sealing, where there might not be any new blocks138 await waitNewBlocks(api, 3);138 await waitNewBlocks(api, 3);139 const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAsset: 0})).toJSON() as any;139 const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAssetId: 0})).toJSON() as any;140 expect(free > balanceOnKaruraBefore).to.be.true;140 expect(free > balanceOnKaruraBefore).to.be.true;141 }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});141 }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});142 });142 });165 };165 };166166167 const id = {167 const id = {168 ForeignAsset: 0,168 ForeignAssetId: 0,169 };169 };170170171 const amount = TRANSFER_AMOUNT;171 const amount = TRANSFER_AMOUNT;