--- a/tests/src/substrate/substrate-api.ts +++ b/tests/src/substrate/substrate-api.ts @@ -18,9 +18,10 @@ return { provider: wsProvider, types: rtt }; } -export default async function usingApi(action: (api: ApiPromise) => Promise, settings: ApiOptions | undefined = undefined): Promise { +export default async function usingApi(action: (api: ApiPromise) => Promise, settings: ApiOptions | undefined = undefined): Promise { settings = settings || defaultApiOptions(); let api: ApiPromise = new ApiPromise(settings); + let result: T = null as unknown as T; // TODO: Remove, this is temporary: Filter unneeded API output // (Jaco promised it will be removed in the next version) @@ -38,9 +39,9 @@ try { await promisifySubstrate(api, async () => { - if(api) { + if (api) { await api.isReadyOrError; - await action(api); + result = await action(api); } })(); } finally { @@ -48,6 +49,7 @@ console.log = consoleLog; console.error = consoleErr; } + return result as T; } enum TransactionStatus {