From 7c35a498361647691355c1ff8d9cb1312e208b8f Mon Sep 17 00:00:00 2001 From: Szegoo Date: Tue, 7 May 2024 16:48:44 +0200 Subject: [PATCH] all good but unpaid execution? --- e2e_tests/package.json | 2 +- e2e_tests/region-transfer/index.ts | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/e2e_tests/package.json b/e2e_tests/package.json index d80e8490..d8878058 100644 --- a/e2e_tests/package.json +++ b/e2e_tests/package.json @@ -12,7 +12,7 @@ "dependencies": { "@polkadot/api": "^11.0.2", "@polkadot/keyring": "^12.6.2", - "coretime-utils": "^0.3.0", + "coretime-utils": "^0.3.2", "typescript": "^5.4.5" } } diff --git a/e2e_tests/region-transfer/index.ts b/e2e_tests/region-transfer/index.ts index 7c5d6766..9f6df1a7 100644 --- a/e2e_tests/region-transfer/index.ts +++ b/e2e_tests/region-transfer/index.ts @@ -2,7 +2,7 @@ import { ApiPromise, WsProvider, Keyring } from "@polkadot/api"; import { CONFIG, INITIAL_PRICE, UNIT, CORE_COUNT } from "../consts"; import { submitExtrinsic, sleep, transferRelayAssetToRegionX, setupRelayAsset } from "../common"; import { KeyringPair } from "@polkadot/keyring/types"; -import { CoreMask, getEncodedRegionId, Id, RegionId } from "coretime-utils"; +import { getEncodedRegionId, Id, RegionId, voidMask } from "coretime-utils"; import assert from 'node:assert'; async function run(_nodeName: any, networkInfo: any, _jsArgs: any) { @@ -33,6 +33,7 @@ async function run(_nodeName: any, networkInfo: any, _jsArgs: any) { await submitExtrinsic(alice, coretimeApi.tx.sudo.sudo(setBalanceCall), {}); const regionId = await purchaseRegion(coretimeApi, alice); + if(!regionId) throw new Error("RegionId not found"); const receiverKeypair = new Keyring(); receiverKeypair.addFromAddress(alice.address); @@ -81,7 +82,7 @@ async function run(_nodeName: any, networkInfo: any, _jsArgs: any) { const regions = (await regionXApi.query.regions.regions.entries()); assert.equal(regions.length, 1); - assert.deepStrictEqual(regions[0][0].toHuman(), [{ begin: '34', core: '0', mask: "0xffffffffffffffffffff" }]); + assert.deepStrictEqual(regions[0][0].toHuman(), [regionId]); assert.deepStrictEqual(regions[0][1].toHuman(), { owner: alice.address, record: 'Pending' }); const reserveTransferToCoretime = regionXApi.tx.polkadotXcm.limitedReserveTransferAssets( @@ -168,8 +169,8 @@ async function startSales(coretimeApi: ApiPromise, signer: KeyringPair): Promise return submitExtrinsic(signer, sudo, {}); } -async function purchaseRegion(coretimeApi: ApiPromise, buyer: KeyringPair): Promise { - const callTx = async (resolve: (regionId: RegionId) => void) => { +async function purchaseRegion(coretimeApi: ApiPromise, buyer: KeyringPair): Promise { + const callTx = async (resolve: (regionId: RegionId | null) => void) => { const purchase = coretimeApi.tx.broker.purchase(INITIAL_PRICE * 2); const unsub = await purchase.signAndSend(buyer, async (result: any) => { if (result.status.isInBlock) { @@ -183,18 +184,18 @@ async function purchaseRegion(coretimeApi: ApiPromise, buyer: KeyringPair): Prom return new Promise(callTx); } -async function getRegionId(coretimeApi: ApiPromise): Promise { +async function getRegionId(coretimeApi: ApiPromise): Promise { const events: any = await coretimeApi.query.system.events(); for (const record of events) { const { event } = record; if (event.section === "broker" && event.method === "Purchased") { const data = event.data[1].toHuman(); - return { begin: data.begin, core: data.core, mask: new CoreMask(data.mask) } + return data; } } - return { begin: 0, core: 0, mask: CoreMask.voidMask() }; + return null; } export { run };