Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Jul 29, 2024
1 parent f98bbd8 commit 1adc9b0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
6 changes: 6 additions & 0 deletions e2e_tests/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,14 @@ const getFreeBalance = async (api: ApiPromise, address: string): Promise<bigint>
return BigInt(free);
};

function log(message: string) {
// Green log.
console.log('\x1b[32m%s\x1b[0m', message);
}

export {
RELAY_ASSET_ID,
log,
setupRelayAsset,
sleep,
openHrmpChannel,
Expand Down
14 changes: 12 additions & 2 deletions e2e_tests/order/processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { KeyringPair } from '@polkadot/keyring/types';
import { getEncodedRegionId, RegionId } from 'coretime-utils';
import assert from 'node:assert';
import {
log,
openHrmpChannel,
RELAY_ASSET_ID,
setupRelayAsset,
Expand Down Expand Up @@ -33,31 +34,40 @@ async function run(nodeName: string, networkInfo: any, _jsArgs: any) {
const alice = keyring.addFromUri('//Alice');
const bob = keyring.addFromUri('//Bob');

const txSetCoretimeXcmVersion = coretimeApi.tx.polkadotXcm.forceDefaultXcmVersion([3]);
const txSetRelayXcmVersion = rococoApi.tx.xcmPallet.forceDefaultXcmVersion([3]);
await submitExtrinsic(alice, coretimeApi.tx.sudo.sudo(txSetCoretimeXcmVersion), {});
const txSetCoretimeXcmVersion = coretimeApi.tx.polkadotXcm.forceDefaultXcmVersion([3]);
log('Setting XCM version: ');
await submitExtrinsic(alice, rococoApi.tx.sudo.sudo(txSetRelayXcmVersion), {});
await submitExtrinsic(alice, coretimeApi.tx.sudo.sudo(txSetCoretimeXcmVersion), {});

log('Setting up relay asset: ');
await setupRelayAsset(regionXApi, alice, 500n * UNIT);

log('Opening HRMP: ');
await openHrmpChannel(alice, rococoApi, 1005, 2000);
await openHrmpChannel(alice, rococoApi, 2000, 1005);
log('Adding ISMP: ');
await ismpAddParachain(alice, regionXApi);

// Needed for fee payment
// Alice has relay tokens on Coretime chain by default, so no need to send there.
log('Transfering rc token to RegionX:');
await transferRelayAssetToPara(UNIT, 2000, rococoApi, alice);

// 1. A region is listed on sale
log('Configuring coretime chain:');
await configureBroker(coretimeApi, alice);
log('Starting sales:');
await startSales(coretimeApi, alice);

log('Giving alice balance on Coretime chain:');
const txSetBalance = coretimeApi.tx.balances.forceSetBalance(alice.address, 1000n * UNIT);
await submitExtrinsic(alice, coretimeApi.tx.sudo.sudo(txSetBalance), {});

const regionId = await purchaseRegion(coretimeApi, alice);
if (!regionId) throw new Error('RegionId not found');

log('Transferring region to RegionX');
await transferRegionToRegionX(coretimeApi, regionXApi, alice, regionId);

// 2. An order is created
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@polkadot/api": "^11.0.2",
"@polkadot/api": "^11.2.1",
"@polkadot/keyring": "^12.6.2",
"@polkadot/util": "^12.6.2",
"@polkadot/util-crypto": "^12.6.2",
Expand Down

0 comments on commit 1adc9b0

Please sign in to comment.