Skip to content

Commit

Permalink
improve globalSetup
Browse files Browse the repository at this point in the history
  • Loading branch information
vklachkov committed Nov 15, 2024
1 parent ae7ac7f commit 53c1eda
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions js-packages/test-utils/globalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ const {dirname} = makeNames(import.meta.url);
const globalSetup = async (): Promise<void> => {
await usingPlaygrounds(async (helper, privateKey) => {
try {
// 1. Wait node producing blocks
await helper.wait.newBlocks(1, 600_000);
// 1. Wait node producing blocks

Check failure on line 16 in js-packages/test-utils/globalSetup.ts

View workflow job for this annotation

GitHub Actions / codestyle / yarn_eslint

Expected indentation of 6 spaces but found 7
console.log('Wait node producing blocks...')

Check failure on line 17 in js-packages/test-utils/globalSetup.ts

View workflow job for this annotation

GitHub Actions / codestyle / yarn_eslint

Expected indentation of 6 spaces but found 7

Check failure on line 17 in js-packages/test-utils/globalSetup.ts

View workflow job for this annotation

GitHub Actions / codestyle / yarn_eslint

Missing semicolon
await helper.wait.newBlocks(1, 600_000);

Check failure on line 18 in js-packages/test-utils/globalSetup.ts

View workflow job for this annotation

GitHub Actions / codestyle / yarn_eslint

Expected indentation of 6 spaces but found 7

// 2. Create donors for test files
await fundFilenamesWithRetries(3)
Expand Down Expand Up @@ -63,17 +64,22 @@ const fundFilenames = async () => {
const oneToken = helper.balance.getOneTokenNominal();
const alice = await privateKey('//Alice');
const nonce = await helper.chain.getNonce(alice.address);
const filenames = await getFiles(path.resolve(dirname, '../tests'));

const filenames = await getFiles(path.resolve(dirname, '..'));

Check failure on line 68 in js-packages/test-utils/globalSetup.ts

View workflow job for this annotation

GitHub Actions / codestyle / yarn_eslint

Expected indentation of 4 spaces but found 5
const filteredFilenames = filenames.filter((f) => {

Check failure on line 69 in js-packages/test-utils/globalSetup.ts

View workflow job for this annotation

GitHub Actions / codestyle / yarn_eslint

Expected indentation of 4 spaces but found 5
return f.endsWith('.test.ts') || f.endsWith('seqtest.ts') || f.includes('.outdated');

Check failure on line 70 in js-packages/test-utils/globalSetup.ts

View workflow job for this annotation

GitHub Actions / codestyle / yarn_eslint

Expected indentation of 6 spaces but found 7
});

Check failure on line 71 in js-packages/test-utils/globalSetup.ts

View workflow job for this annotation

GitHub Actions / codestyle / yarn_eslint

Expected indentation of 4 spaces but found 5

// batching is actually undesireable, it takes away the time while all the transactions actually succeed
const batchSize = 300;
let balanceGrantedCounter = 0;
for(let b = 0; b < filenames.length; b += batchSize) {
for(let b = 0; b < filteredFilenames.length; b += batchSize) {
const tx: Promise<boolean>[] = [];
let batchBalanceGrantedCounter = 0;
for(let i = 0; i < batchSize && b + i < filenames.length; i++) {
const f = filenames[b + i];
if(!f.endsWith('.test.ts') && !f.endsWith('seqtest.ts') || f.includes('.outdated')) continue;

for(let i = 0; batchBalanceGrantedCounter < batchSize && b + i < filteredFilenames.length; i++) {
const f = filteredFilenames[b + i];

const account = await privateKey({filename: f, ignoreFundsPresence: true});
const aliceBalance = await helper.balance.getSubstrate(account.address);

Expand Down

0 comments on commit 53c1eda

Please sign in to comment.