Skip to content

Commit

Permalink
fix(xcm test): hooks for Astar\Shiden
Browse files Browse the repository at this point in the history
  • Loading branch information
PraetorP committed Oct 4, 2023
1 parent f5ed3da commit f1959a0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions tests/src/util/playgrounds/unique.xcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ export class AssetsGroup<T extends ChainHelperBase> extends HelperGroup<T> {
await this.helper.executeExtrinsic(signer, 'api.tx.assets.create', [assetId, admin, minimalBalance], true);
}

async forceCreate(signer: TSigner, assetId: number | bigint, admin: string, minimalBalance: bigint, isSufficient = true) {
await this.helper.executeExtrinsic(signer, 'api.tx.assets.forceCreate', [assetId, admin, isSufficient, minimalBalance], true);
}

async setMetadata(signer: TSigner, assetId: number | bigint, name: string, symbol: string, decimals: number) {
await this.helper.executeExtrinsic(signer, 'api.tx.assets.setMetadata', [assetId, name, symbol, decimals], true);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/xcm/lowLevelXcmQuartz.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ describeXCM('[XCMLL] Integration test: Exchanging tokens with Shiden', () => {
await usingShidenPlaygrounds(shidenUrl, async (helper) => {
if(!(await helper.callRpc('api.query.assets.asset', [QTZ_ASSET_ID_ON_SHIDEN])).toJSON()) {
console.log('1. Create foreign asset and metadata');
await helper.assets.create(
await helper.getSudo().assets.forceCreate(
alice,
QTZ_ASSET_ID_ON_SHIDEN,
alice.address,
Expand Down
2 changes: 1 addition & 1 deletion tests/src/xcm/lowLevelXcmUnique.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ describeXCM('[XCMLL] Integration test: Exchanging tokens with Astar', () => {
await usingAstarPlaygrounds(astarUrl, async (helper) => {
if(!(await helper.callRpc('api.query.assets.asset', [UNQ_ASSET_ID_ON_ASTAR])).toJSON()) {
console.log('1. Create foreign asset and metadata');
await helper.assets.create(
await helper.getSudo().assets.forceCreate(
alice,
UNQ_ASSET_ID_ON_ASTAR,
alice.address,
Expand Down
6 changes: 3 additions & 3 deletions tests/src/xcm/xcmQuartz.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1290,11 +1290,11 @@ describeXCM('[XCM] Integration test: Exchanging tokens with Shiden', () => {
const shidenInitialBalance = 1n * (10n ** SHIDEN_DECIMALS); // 1 SHD, existential deposit required to actually create the account on Shiden
const unitsPerSecond = 500_451_000_000_000_000_000n; // The value is taken from the live Shiden
const qtzToShidenTransferred = 10n * (10n ** QTZ_DECIMALS); // 10 QTZ
const qtzToShidenArrived = 9_999_999_999_088_000_000n; // 9.999 ... QTZ, Shiden takes a commision in foreign tokens
const qtzToShidenArrived = 7_998_196_000_000_000_000n; // 7.99 ... QTZ, Shiden takes a commision in foreign tokens

// Shiden -> Quartz
const qtzFromShidenTransfered = 5n * (10n ** QTZ_DECIMALS); // 5 QTZ
const qtzOnShidenLeft = qtzToShidenArrived - qtzFromShidenTransfered; // 4.999_999_999_088_000_000n QTZ
const qtzOnShidenLeft = qtzToShidenArrived - qtzFromShidenTransfered; // 2.99 ... QTZ

let balanceAfterQuartzToShidenXCM: bigint;

Expand All @@ -1311,7 +1311,7 @@ describeXCM('[XCM] Integration test: Exchanging tokens with Shiden', () => {
await usingShidenPlaygrounds(shidenUrl, async (helper) => {
if(!(await helper.callRpc('api.query.assets.asset', [QTZ_ASSET_ID_ON_SHIDEN])).toJSON()) {
console.log('1. Create foreign asset and metadata');
await helper.assets.create(
await helper.getSudo().assets.forceCreate(
alice,
QTZ_ASSET_ID_ON_SHIDEN,
alice.address,
Expand Down
6 changes: 3 additions & 3 deletions tests/src/xcm/xcmUnique.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1518,11 +1518,11 @@ describeXCM('[XCM] Integration test: Exchanging tokens with Astar', () => {
const astarInitialBalance = 1n * (10n ** ASTAR_DECIMALS); // 1 ASTR, existential deposit required to actually create the account on Astar.
const unitsPerSecond = 9_451_000_000_000_000_000n; // The value is taken from the live Astar
const unqToAstarTransferred = 10n * (10n ** UNQ_DECIMALS); // 10 UNQ
const unqToAstarArrived = 9_999_999_999_088_000_000n; // 9.999 ... UNQ, Astar takes a commision in foreign tokens
const unqToAstarArrived = 9_962_196_000_000_000_000n; // 9.962 ... UNQ, Astar takes a commision in foreign tokens

// Astar -> Unique
const unqFromAstarTransfered = 5n * (10n ** UNQ_DECIMALS); // 5 UNQ
const unqOnAstarLeft = unqToAstarArrived - unqFromAstarTransfered; // 4.999_999_999_088_000_000n UNQ
const unqOnAstarLeft = unqToAstarArrived - unqFromAstarTransfered; // 4.962_219_600_000_000_000n UNQ

let balanceAfterUniqueToAstarXCM: bigint;

Expand All @@ -1539,7 +1539,7 @@ describeXCM('[XCM] Integration test: Exchanging tokens with Astar', () => {
await usingAstarPlaygrounds(astarUrl, async (helper) => {
if(!(await helper.callRpc('api.query.assets.asset', [UNQ_ASSET_ID_ON_ASTAR])).toJSON()) {
console.log('1. Create foreign asset and metadata');
await helper.assets.create(
await helper.getSudo().assets.forceCreate(
alice,
UNQ_ASSET_ID_ON_ASTAR,
alice.address,
Expand Down

0 comments on commit f1959a0

Please sign in to comment.