From b82fcab9d2780690cd212b62183a02373b297188 Mon Sep 17 00:00:00 2001 From: Pablo Labarta Date: Fri, 20 Sep 2024 09:41:24 -0300 Subject: [PATCH 01/10] make it easier & less verbose to reproduce --- test/suites/smoke/test-polkadot-decoding.ts | 172 +++++++++++--------- 1 file changed, 99 insertions(+), 73 deletions(-) diff --git a/test/suites/smoke/test-polkadot-decoding.ts b/test/suites/smoke/test-polkadot-decoding.ts index bcdb8b3061..b4e705c677 100644 --- a/test/suites/smoke/test-polkadot-decoding.ts +++ b/test/suites/smoke/test-polkadot-decoding.ts @@ -6,7 +6,9 @@ import { ApiPromise } from "@polkadot/api"; import { fail } from "assert"; // Change the following line to reproduce a particular case -const STARTING_KEY_OVERRIDE = null; +const STARTING_KEY_OVERRIDE = ""; +const MODULE_NAME = ""; +const FN_NAME = ""; const pageSize = (process.env.PAGE_SIZE && parseInt(process.env.PAGE_SIZE)) || 500; @@ -62,81 +64,105 @@ describeSuite({ title: "should be decodable", timeout: ONE_HOURS, test: async function () { - let currentStartKey = ""; - const modules = Object.keys(paraApi.query); - for (const moduleName of modules) { - log(` - ${moduleName}`); - const module = apiAt.query[moduleName]; - const fns = Object.keys(module); - for (const fn of fns) { - log(`🔎 checking ${moduleName}::${fn}`); - const keys = Object.keys(module[fn]); - try { - if (keys.includes("keysPaged")) { - // Generate a first query with an empty startKey - currentStartKey = ""; - const emptyKeyEntries = await module[fn].entriesPaged({ - args: [], - pageSize, - startKey: currentStartKey, - }); - - // Skip if no entries are found - if (emptyKeyEntries.length === 0) { - log(` - ${fn}: ${chalk.green(`✔ No entries found`)}`); - continue; - } - // Skip if all entries are checked - if (emptyKeyEntries.length < pageSize) { - log( - ` - ${fn}: ${chalk.green( - `✔ All ${emptyKeyEntries.length} entries checked` - )}` - ); - continue; + // Test case reproduction + if (STARTING_KEY_OVERRIDE) { + // const STARTING_KEY_OVERRIDE = ""; + if (!MODULE_NAME || !FN_NAME) { + fail("MODULE_NAME and FN_NAME variables must be set when using STARTING_KEY_OVERRIDE"); + } + log(`🔎 checking ${MODULE_NAME}::${FN_NAME}`); + const module = apiAt.query[MODULE_NAME]; + const fn = module[FN_NAME]; + const entries = await fn.entriesPaged({ + args: [], + pageSize, + startKey: STARTING_KEY_OVERRIDE, + }); + log(`entries length: ${entries.length}`); + log(`first entry: ${entries[0][0].toString()}`); + + log(` - ${FN_NAME}: ${chalk.green(`✔`)} (startKey: ${STARTING_KEY_OVERRIDE})`); + } else { + + + + + let currentStartKey = ""; + const modules = Object.keys(paraApi.query); + for (const moduleName of modules) { + log(` - ${moduleName}`); + const module = apiAt.query[moduleName]; + const fns = Object.keys(module); + for (const fn of fns) { + log(`🔎 checking ${moduleName}::${fn}`); + const keys = Object.keys(module[fn]); + try { + if (keys.includes("keysPaged")) { + // Generate a first query with an empty startKey + currentStartKey = ""; + const emptyKeyEntries = await module[fn].entriesPaged({ + args: [], + pageSize, + startKey: currentStartKey, + }); + + // Skip if no entries are found + if (emptyKeyEntries.length === 0) { + log(` - ${fn}: ${chalk.green(`✔ No entries found`)}`); + continue; + } + // Skip if all entries are checked + if (emptyKeyEntries.length < pageSize) { + log( + ` - ${fn}: ${chalk.green( + `✔ All ${emptyKeyEntries.length} entries checked` + )}` + ); + continue; + } + // Log emptyKeyFirstEntry + const emptyKeyFirstEntryKey = emptyKeyEntries[0][0].toString(); + log(` - ${fn}: ${chalk.green(`🔎`)} (first key : ${emptyKeyFirstEntryKey})`); + + // If there are more entries, perform a random check + // 1. Get the first entry storage key + const firstEntry = emptyKeyEntries[0]; + const storageKey = firstEntry[0].toString(); + + // 2. Extract the module, fn and params keys + const { moduleKey, fnKey, paramsKey } = extractStorageKeyComponents(storageKey); + + // 3. Generate a random startKey, will be overridden if STARTING_KEY_OVERRIDE is set + currentStartKey = moduleKey + fnKey + randomHex(paramsKey.length); + currentStartKey = STARTING_KEY_OVERRIDE || currentStartKey; + + // 4. Fetch the storage entries with the random startKey + // Trying to decode all storage entries may cause the node to timeout, decoding + // random storage entries should be enough to verify if a storage migration + // was missed. + const randomEntries = await module[fn].entriesPaged({ + args: [], + pageSize, + startKey: currentStartKey, + }); + // Log first entry storage key + const firstRandomEntryKey = randomEntries[0][0].toString(); + log(` - ${fn}: ${chalk.green(`🔎`)} (random key: ${firstRandomEntryKey})`); + } else if (fn != "code") { + await module[fn](); } - // Log emptyKeyFirstEntry - const emptyKeyFirstEntryKey = emptyKeyEntries[0][0].toString(); - log(` - ${fn}: ${chalk.green(`🔎`)} (first key : ${emptyKeyFirstEntryKey})`); - - // If there are more entries, perform a random check - // 1. Get the first entry storage key - const firstEntry = emptyKeyEntries[0]; - const storageKey = firstEntry[0].toString(); - - // 2. Extract the module, fn and params keys - const { moduleKey, fnKey, paramsKey } = extractStorageKeyComponents(storageKey); - - // 3. Generate a random startKey, will be overridden if STARTING_KEY_OVERRIDE is set - currentStartKey = moduleKey + fnKey + randomHex(paramsKey.length); - currentStartKey = STARTING_KEY_OVERRIDE || currentStartKey; - - // 4. Fetch the storage entries with the random startKey - // Trying to decode all storage entries may cause the node to timeout, decoding - // random storage entries should be enough to verify if a storage migration - // was missed. - const randomEntries = await module[fn].entriesPaged({ - args: [], - pageSize, - startKey: currentStartKey, - }); - // Log first entry storage key - const firstRandomEntryKey = randomEntries[0][0].toString(); - log(` - ${fn}: ${chalk.green(`🔎`)} (random key: ${firstRandomEntryKey})`); - } else if (fn != "code") { - await module[fn](); - } - log(` - ${fn}: ${chalk.green(`✔`)}`); - } catch (e) { - const failMsg = `Failed to fetch storage at (${moduleName}::${fn}) `; - const RNGDetails = `using startKey "${currentStartKey} at block ${atBlockNumber}`; - const msg = chalk.red(`${failMsg} ${RNGDetails}`); - log(msg, e); - const reproducing = `To reproduce this failled case, set the STARTING_KEY_OVERRIDE + log(` - ${fn}: ${chalk.green(`✔`)}`); + } catch (e) { + const failMsg = `Failed to fetch storage at (${moduleName}::${fn}) `; + const RNGDetails = `using startKey "${currentStartKey}" at block ${atBlockNumber}`; + const msg = chalk.red(`${failMsg} ${RNGDetails}`); + log(msg, e); + const reproducing = `To reproduce this failled case, set the STARTING_KEY_OVERRIDE variable to "${currentStartKey}" at the top of the test file and run the test again.`; - log(chalk.red(reproducing)); - fail(msg); + log(chalk.red(reproducing)); + fail(msg); + } } } } From c4e923e9de20bd10d3c9edd40caefb0f11d9a98a Mon Sep 17 00:00:00 2001 From: Pablo Labarta Date: Mon, 23 Sep 2024 12:54:30 -0300 Subject: [PATCH 02/10] add retry for emtpy queries & improve reproduction --- test/suites/smoke/test-polkadot-decoding.ts | 49 ++++++++++++--------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/test/suites/smoke/test-polkadot-decoding.ts b/test/suites/smoke/test-polkadot-decoding.ts index b4e705c677..acec49576e 100644 --- a/test/suites/smoke/test-polkadot-decoding.ts +++ b/test/suites/smoke/test-polkadot-decoding.ts @@ -7,10 +7,11 @@ import { fail } from "assert"; // Change the following line to reproduce a particular case const STARTING_KEY_OVERRIDE = ""; -const MODULE_NAME = ""; -const FN_NAME = ""; +// const STARTING_KEY_OVERRIDE = ""; +const MODULE_NAME = "assets"; +const FN_NAME = "account"; -const pageSize = (process.env.PAGE_SIZE && parseInt(process.env.PAGE_SIZE)) || 500; +const pageSize = (process.env.PAGE_SIZE && parseInt(process.env.PAGE_SIZE)) || 1000; const extractStorageKeyComponents = (storageKey: string) => { // The full storage key is composed of @@ -70,7 +71,8 @@ describeSuite({ if (!MODULE_NAME || !FN_NAME) { fail("MODULE_NAME and FN_NAME variables must be set when using STARTING_KEY_OVERRIDE"); } - log(`🔎 checking ${MODULE_NAME}::${FN_NAME}`); + log(`🔎 OVERRIDE SET, REPRODUCING CASE FOR ${MODULE_NAME}::${FN_NAME}`); + log(`🔎 STORAGE KEY: ${STARTING_KEY_OVERRIDE}`); const module = apiAt.query[MODULE_NAME]; const fn = module[FN_NAME]; const entries = await fn.entriesPaged({ @@ -80,12 +82,10 @@ describeSuite({ }); log(`entries length: ${entries.length}`); log(`first entry: ${entries[0][0].toString()}`); - + log(`last entry: ${entries[entries.length - 1][0].toString()}`); log(` - ${FN_NAME}: ${chalk.green(`✔`)} (startKey: ${STARTING_KEY_OVERRIDE})`); - } else { - - + } else { let currentStartKey = ""; const modules = Object.keys(paraApi.query); @@ -132,19 +132,26 @@ describeSuite({ // 2. Extract the module, fn and params keys const { moduleKey, fnKey, paramsKey } = extractStorageKeyComponents(storageKey); - // 3. Generate a random startKey, will be overridden if STARTING_KEY_OVERRIDE is set - currentStartKey = moduleKey + fnKey + randomHex(paramsKey.length); - currentStartKey = STARTING_KEY_OVERRIDE || currentStartKey; - - // 4. Fetch the storage entries with the random startKey - // Trying to decode all storage entries may cause the node to timeout, decoding - // random storage entries should be enough to verify if a storage migration - // was missed. - const randomEntries = await module[fn].entriesPaged({ - args: [], - pageSize, - startKey: currentStartKey, - }); + let randomEntriesCount = 0; + let randomEntries; + // Re-try on empty entries cases to avoid false positives + while (randomEntriesCount === 0) { + // 3. Generate a random startKey + // will be overridden if STARTING_KEY_OVERRIDE is set + currentStartKey = moduleKey + fnKey + randomHex(paramsKey.length); + currentStartKey = currentStartKey; + + // 4. Fetch the storage entries with the random startKey + // Trying to decode all storage entries may cause the node to timeout, decoding + // random storage entries should be enough to verify if a storage migration + // was missed. + randomEntries = await module[fn].entriesPaged({ + args: [], + pageSize, + startKey: currentStartKey, + }); + randomEntriesCount = randomEntries.length; + } // Log first entry storage key const firstRandomEntryKey = randomEntries[0][0].toString(); log(` - ${fn}: ${chalk.green(`🔎`)} (random key: ${firstRandomEntryKey})`); From cbbfdfccd5256428bd875e6fb053fe8a3f782cea Mon Sep 17 00:00:00 2001 From: Pablo Labarta Date: Mon, 23 Sep 2024 13:01:00 -0300 Subject: [PATCH 03/10] appease linter --- test/suites/smoke/test-polkadot-decoding.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/suites/smoke/test-polkadot-decoding.ts b/test/suites/smoke/test-polkadot-decoding.ts index acec49576e..3ba5abe03b 100644 --- a/test/suites/smoke/test-polkadot-decoding.ts +++ b/test/suites/smoke/test-polkadot-decoding.ts @@ -122,7 +122,7 @@ describeSuite({ } // Log emptyKeyFirstEntry const emptyKeyFirstEntryKey = emptyKeyEntries[0][0].toString(); - log(` - ${fn}: ${chalk.green(`🔎`)} (first key : ${emptyKeyFirstEntryKey})`); + log(` - ${fn}: ${chalk.green(`🔎`)} (first key: ${emptyKeyFirstEntryKey})`); // If there are more entries, perform a random check // 1. Get the first entry storage key From 5841c1574735013deff8eec4565bc5d1a41b9738 Mon Sep 17 00:00:00 2001 From: Pablo Labarta Date: Mon, 23 Sep 2024 13:05:54 -0300 Subject: [PATCH 04/10] fmt --- test/suites/smoke/test-polkadot-decoding.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/suites/smoke/test-polkadot-decoding.ts b/test/suites/smoke/test-polkadot-decoding.ts index 3ba5abe03b..83876e0793 100644 --- a/test/suites/smoke/test-polkadot-decoding.ts +++ b/test/suites/smoke/test-polkadot-decoding.ts @@ -84,9 +84,7 @@ describeSuite({ log(`first entry: ${entries[0][0].toString()}`); log(`last entry: ${entries[entries.length - 1][0].toString()}`); log(` - ${FN_NAME}: ${chalk.green(`✔`)} (startKey: ${STARTING_KEY_OVERRIDE})`); - } else { - let currentStartKey = ""; const modules = Object.keys(paraApi.query); for (const moduleName of modules) { @@ -122,7 +120,7 @@ describeSuite({ } // Log emptyKeyFirstEntry const emptyKeyFirstEntryKey = emptyKeyEntries[0][0].toString(); - log(` - ${fn}: ${chalk.green(`🔎`)} (first key: ${emptyKeyFirstEntryKey})`); + log(` - ${fn}: ${chalk.green(`🔎`)} (first key: ${emptyKeyFirstEntryKey})`); // If there are more entries, perform a random check // 1. Get the first entry storage key From 578fa636d1551a57002e5d7ff5ba0ab007c1f225 Mon Sep 17 00:00:00 2001 From: Pablo Labarta Date: Mon, 23 Sep 2024 13:06:37 -0300 Subject: [PATCH 05/10] thanks eslint --- test/suites/smoke/test-polkadot-decoding.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/suites/smoke/test-polkadot-decoding.ts b/test/suites/smoke/test-polkadot-decoding.ts index 83876e0793..5e3b2af97a 100644 --- a/test/suites/smoke/test-polkadot-decoding.ts +++ b/test/suites/smoke/test-polkadot-decoding.ts @@ -137,7 +137,6 @@ describeSuite({ // 3. Generate a random startKey // will be overridden if STARTING_KEY_OVERRIDE is set currentStartKey = moduleKey + fnKey + randomHex(paramsKey.length); - currentStartKey = currentStartKey; // 4. Fetch the storage entries with the random startKey // Trying to decode all storage entries may cause the node to timeout, decoding From bb6eceb4a2bf40c22610baad44537e3edbada0ab Mon Sep 17 00:00:00 2001 From: Pablo Labarta Date: Mon, 23 Sep 2024 13:09:50 -0300 Subject: [PATCH 06/10] remove module & fn used for reproducing case --- test/suites/smoke/test-polkadot-decoding.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/suites/smoke/test-polkadot-decoding.ts b/test/suites/smoke/test-polkadot-decoding.ts index 5e3b2af97a..a008cb047d 100644 --- a/test/suites/smoke/test-polkadot-decoding.ts +++ b/test/suites/smoke/test-polkadot-decoding.ts @@ -7,9 +7,8 @@ import { fail } from "assert"; // Change the following line to reproduce a particular case const STARTING_KEY_OVERRIDE = ""; -// const STARTING_KEY_OVERRIDE = ""; -const MODULE_NAME = "assets"; -const FN_NAME = "account"; +const MODULE_NAME = ""; +const FN_NAME = ""; const pageSize = (process.env.PAGE_SIZE && parseInt(process.env.PAGE_SIZE)) || 1000; From 0187f8ff77b1130740016de948cb1901b3f4c23a Mon Sep 17 00:00:00 2001 From: Pablo Labarta Date: Mon, 30 Sep 2024 09:09:52 -0300 Subject: [PATCH 07/10] remove if/else --- test/suites/smoke/test-polkadot-decoding.ts | 156 ++++++++++---------- 1 file changed, 79 insertions(+), 77 deletions(-) diff --git a/test/suites/smoke/test-polkadot-decoding.ts b/test/suites/smoke/test-polkadot-decoding.ts index a008cb047d..14080b38d0 100644 --- a/test/suites/smoke/test-polkadot-decoding.ts +++ b/test/suites/smoke/test-polkadot-decoding.ts @@ -83,93 +83,95 @@ describeSuite({ log(`first entry: ${entries[0][0].toString()}`); log(`last entry: ${entries[entries.length - 1][0].toString()}`); log(` - ${FN_NAME}: ${chalk.green(`✔`)} (startKey: ${STARTING_KEY_OVERRIDE})`); - } else { - let currentStartKey = ""; - const modules = Object.keys(paraApi.query); - for (const moduleName of modules) { - log(` - ${moduleName}`); - const module = apiAt.query[moduleName]; - const fns = Object.keys(module); - for (const fn of fns) { - log(`🔎 checking ${moduleName}::${fn}`); - const keys = Object.keys(module[fn]); - try { - if (keys.includes("keysPaged")) { - // Generate a first query with an empty startKey - currentStartKey = ""; - const emptyKeyEntries = await module[fn].entriesPaged({ + return; + } + + let currentStartKey = ""; + const modules = Object.keys(paraApi.query); + for (const moduleName of modules) { + log(` - ${moduleName}`); + const module = apiAt.query[moduleName]; + const fns = Object.keys(module); + for (const fn of fns) { + log(`🔎 checking ${moduleName}::${fn}`); + const keys = Object.keys(module[fn]); + try { + if (keys.includes("keysPaged")) { + // Generate a first query with an empty startKey + currentStartKey = ""; + const emptyKeyEntries = await module[fn].entriesPaged({ + args: [], + pageSize, + startKey: currentStartKey, + }); + + // Skip if no entries are found + if (emptyKeyEntries.length === 0) { + log(` - ${fn}: ${chalk.green(`✔ No entries found`)}`); + continue; + } + // Skip if all entries are checked + if (emptyKeyEntries.length < pageSize) { + log( + ` - ${fn}: ${chalk.green( + `✔ All ${emptyKeyEntries.length} entries checked` + )}` + ); + continue; + } + // Log emptyKeyFirstEntry + const emptyKeyFirstEntryKey = emptyKeyEntries[0][0].toString(); + log(` - ${fn}: ${chalk.green(`🔎`)} (first key: ${emptyKeyFirstEntryKey})`); + + // If there are more entries, perform a random check + // 1. Get the first entry storage key + const firstEntry = emptyKeyEntries[0]; + const storageKey = firstEntry[0].toString(); + + // 2. Extract the module, fn and params keys + const { moduleKey, fnKey, paramsKey } = extractStorageKeyComponents(storageKey); + + let randomEntriesCount = 0; + let randomEntries; + // Re-try on empty entries cases to avoid false positives + while (randomEntriesCount === 0) { + // 3. Generate a random startKey + // will be overridden if STARTING_KEY_OVERRIDE is set + currentStartKey = moduleKey + fnKey + randomHex(paramsKey.length); + + // 4. Fetch the storage entries with the random startKey + // Trying to decode all storage entries may cause the node to timeout, decoding + // random storage entries should be enough to verify if a storage migration + // was missed. + randomEntries = await module[fn].entriesPaged({ args: [], pageSize, startKey: currentStartKey, }); - - // Skip if no entries are found - if (emptyKeyEntries.length === 0) { - log(` - ${fn}: ${chalk.green(`✔ No entries found`)}`); - continue; - } - // Skip if all entries are checked - if (emptyKeyEntries.length < pageSize) { - log( - ` - ${fn}: ${chalk.green( - `✔ All ${emptyKeyEntries.length} entries checked` - )}` - ); - continue; - } - // Log emptyKeyFirstEntry - const emptyKeyFirstEntryKey = emptyKeyEntries[0][0].toString(); - log(` - ${fn}: ${chalk.green(`🔎`)} (first key: ${emptyKeyFirstEntryKey})`); - - // If there are more entries, perform a random check - // 1. Get the first entry storage key - const firstEntry = emptyKeyEntries[0]; - const storageKey = firstEntry[0].toString(); - - // 2. Extract the module, fn and params keys - const { moduleKey, fnKey, paramsKey } = extractStorageKeyComponents(storageKey); - - let randomEntriesCount = 0; - let randomEntries; - // Re-try on empty entries cases to avoid false positives - while (randomEntriesCount === 0) { - // 3. Generate a random startKey - // will be overridden if STARTING_KEY_OVERRIDE is set - currentStartKey = moduleKey + fnKey + randomHex(paramsKey.length); - - // 4. Fetch the storage entries with the random startKey - // Trying to decode all storage entries may cause the node to timeout, decoding - // random storage entries should be enough to verify if a storage migration - // was missed. - randomEntries = await module[fn].entriesPaged({ - args: [], - pageSize, - startKey: currentStartKey, - }); - randomEntriesCount = randomEntries.length; - } - // Log first entry storage key - const firstRandomEntryKey = randomEntries[0][0].toString(); - log(` - ${fn}: ${chalk.green(`🔎`)} (random key: ${firstRandomEntryKey})`); - } else if (fn != "code") { - await module[fn](); + randomEntriesCount = randomEntries.length; } + // Log first entry storage key + const firstRandomEntryKey = randomEntries[0][0].toString(); + log(` - ${fn}: ${chalk.green(`🔎`)} (random key: ${firstRandomEntryKey})`); + } else if (fn != "code") { + await module[fn](); + } - log(` - ${fn}: ${chalk.green(`✔`)}`); - } catch (e) { - const failMsg = `Failed to fetch storage at (${moduleName}::${fn}) `; - const RNGDetails = `using startKey "${currentStartKey}" at block ${atBlockNumber}`; - const msg = chalk.red(`${failMsg} ${RNGDetails}`); - log(msg, e); - const reproducing = `To reproduce this failled case, set the STARTING_KEY_OVERRIDE + log(` - ${fn}: ${chalk.green(`✔`)}`); + } catch (e) { + const failMsg = `Failed to fetch storage at (${moduleName}::${fn}) `; + const RNGDetails = `using startKey "${currentStartKey}" at block ${atBlockNumber}`; + const msg = chalk.red(`${failMsg} ${RNGDetails}`); + log(msg, e); + const reproducing = `To reproduce this failled case, set the STARTING_KEY_OVERRIDE variable to "${currentStartKey}" at the top of the test file and run the test again.`; - log(chalk.red(reproducing)); - fail(msg); - } + log(chalk.red(reproducing)); + fail(msg); } } } - }, + + } }); }, }); From 43fc14c9cbc7015a7f4dcc4dcbfb17bc4bceace8 Mon Sep 17 00:00:00 2001 From: Pablo Labarta Date: Mon, 30 Sep 2024 09:11:52 -0300 Subject: [PATCH 08/10] fmt --- test/suites/smoke/test-polkadot-decoding.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/suites/smoke/test-polkadot-decoding.ts b/test/suites/smoke/test-polkadot-decoding.ts index 14080b38d0..56a72a55aa 100644 --- a/test/suites/smoke/test-polkadot-decoding.ts +++ b/test/suites/smoke/test-polkadot-decoding.ts @@ -170,8 +170,7 @@ describeSuite({ } } } - - } + }, }); }, }); From 404b7d211e2fbd6c162e2cf7afde2826fd1c7af0 Mon Sep 17 00:00:00 2001 From: Pablo Labarta Date: Mon, 30 Sep 2024 12:20:56 -0300 Subject: [PATCH 09/10] change entries to 500 & add retry limit --- test/suites/smoke/test-polkadot-decoding.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/suites/smoke/test-polkadot-decoding.ts b/test/suites/smoke/test-polkadot-decoding.ts index 56a72a55aa..22f1965231 100644 --- a/test/suites/smoke/test-polkadot-decoding.ts +++ b/test/suites/smoke/test-polkadot-decoding.ts @@ -10,7 +10,7 @@ const STARTING_KEY_OVERRIDE = ""; const MODULE_NAME = ""; const FN_NAME = ""; -const pageSize = (process.env.PAGE_SIZE && parseInt(process.env.PAGE_SIZE)) || 1000; +const pageSize = (process.env.PAGE_SIZE && parseInt(process.env.PAGE_SIZE)) || 500; const extractStorageKeyComponents = (storageKey: string) => { // The full storage key is composed of @@ -133,6 +133,7 @@ describeSuite({ let randomEntriesCount = 0; let randomEntries; + let retries = 0; // Re-try on empty entries cases to avoid false positives while (randomEntriesCount === 0) { // 3. Generate a random startKey @@ -149,6 +150,12 @@ describeSuite({ startKey: currentStartKey, }); randomEntriesCount = randomEntries.length; + retries++; + if (retries > 10) { + fail( + `Failed to fetch storage entries for module ${moduleName}::${fn} after 10 retries` + ); + } } // Log first entry storage key const firstRandomEntryKey = randomEntries[0][0].toString(); From 506828eaa4d5123d7b40cfbfade24ff48f97c4c2 Mon Sep 17 00:00:00 2001 From: Pablo Labarta Date: Mon, 30 Sep 2024 14:09:46 -0300 Subject: [PATCH 10/10] shorten fail msg --- test/suites/smoke/test-polkadot-decoding.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/suites/smoke/test-polkadot-decoding.ts b/test/suites/smoke/test-polkadot-decoding.ts index 22f1965231..12d3ac1a0b 100644 --- a/test/suites/smoke/test-polkadot-decoding.ts +++ b/test/suites/smoke/test-polkadot-decoding.ts @@ -153,7 +153,7 @@ describeSuite({ retries++; if (retries > 10) { fail( - `Failed to fetch storage entries for module ${moduleName}::${fn} after 10 retries` + `Failed to fetch entries for module ${moduleName}::${fn} after 10 retries` ); } }