From 5930cd35155c6e59174ca8dec80327f120e065c2 Mon Sep 17 00:00:00 2001 From: Fahrrader Date: Fri, 14 Oct 2022 13:49:10 +0000 Subject: [PATCH] tests(util): fix t isDevNoderying to access discarded blocks --- --- a/tests/src/util/playgrounds/unique.dev.ts +++ b/tests/src/util/playgrounds/unique.dev.ts @@ -260,8 +260,13 @@ }; isDevNode = async () => { - const block1 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [1])]); - const block2 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [2])]); + let blockNumber = (await this.helper.callRpc('api.query.system.number')).toJSON(); + if (blockNumber == 0) { + await this.helper.wait.newBlocks(1); + blockNumber = (await this.helper.callRpc('api.query.system.number')).toJSON(); + } + const block2 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [blockNumber])]); + const block1 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [blockNumber - 1])]); const findCreationDate = async (block: any) => { const humanBlock = block.toHuman(); let date; -- gitstuff