From 0639ce9b07a882753f2b79e765bdb55728b510ae Mon Sep 17 00:00:00 2001 From: Miguel Medeiros Date: Mon, 15 Nov 2021 14:16:27 -0300 Subject: [PATCH 1/3] fix: mempool empty block. --- frontend/cypress/integration/liquid/liquid.spec.ts | 6 ++++++ .../cypress/integration/mainnet/mainnet.spec.ts | 6 ++++++ frontend/cypress/integration/signet/signet.spec.ts | 6 ++++++ .../cypress/integration/testnet/testnet.spec.ts | 6 ++++++ .../mempool-blocks/mempool-blocks.component.ts | 13 ++++++++----- 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/frontend/cypress/integration/liquid/liquid.spec.ts b/frontend/cypress/integration/liquid/liquid.spec.ts index 44aca078e..bf5c733c1 100644 --- a/frontend/cypress/integration/liquid/liquid.spec.ts +++ b/frontend/cypress/integration/liquid/liquid.spec.ts @@ -18,6 +18,12 @@ describe('Liquid', () => { if (baseModule === 'mempool' || baseModule === 'liquid') { + it('check first mempool block after skeleton loads', () => { + cy.visit(`${basePath}`); + cy.waitForSkeletonGone(); + cy.get('#mempool-block-0 > .blockLink').should('exist'); + }); + it('loads the dashboard', () => { cy.visit(`${basePath}`); cy.waitForSkeletonGone(); diff --git a/frontend/cypress/integration/mainnet/mainnet.spec.ts b/frontend/cypress/integration/mainnet/mainnet.spec.ts index d53c8bb6c..13c0e35b8 100644 --- a/frontend/cypress/integration/mainnet/mainnet.spec.ts +++ b/frontend/cypress/integration/mainnet/mainnet.spec.ts @@ -24,6 +24,12 @@ describe('Mainnet', () => { if (baseModule === 'mempool') { + it('check first mempool block after skeleton loads', () => { + cy.visit('/'); + cy.waitForSkeletonGone(); + cy.get('#mempool-block-0 > .blockLink').should('exist'); + }); + it('loads the status screen', () => { cy.visit('/status'); cy.get('#mempool-block-0').should('be.visible'); diff --git a/frontend/cypress/integration/signet/signet.spec.ts b/frontend/cypress/integration/signet/signet.spec.ts index ec2a0a852..d0d8f67df 100644 --- a/frontend/cypress/integration/signet/signet.spec.ts +++ b/frontend/cypress/integration/signet/signet.spec.ts @@ -17,6 +17,12 @@ describe('Signet', () => { cy.waitForSkeletonGone(); }); + it('check first mempool block after skeleton loads', () => { + cy.visit('/'); + cy.waitForSkeletonGone(); + cy.get('#mempool-block-0 > .blockLink').should('exist'); + }); + it('loads the dashboard with the skeleton blocks', () => { cy.mockMempoolSocket(); cy.visit("/signet"); diff --git a/frontend/cypress/integration/testnet/testnet.spec.ts b/frontend/cypress/integration/testnet/testnet.spec.ts index 6e406c087..861087e2c 100644 --- a/frontend/cypress/integration/testnet/testnet.spec.ts +++ b/frontend/cypress/integration/testnet/testnet.spec.ts @@ -17,6 +17,12 @@ describe('Testnet', () => { cy.waitForSkeletonGone(); }); + it('check first mempool block after skeleton loads', () => { + cy.visit('/'); + cy.waitForSkeletonGone(); + cy.get('#mempool-block-0 > .blockLink').should('exist'); + }); + it('loads the dashboard with the skeleton blocks', () => { cy.mockMempoolSocket(); cy.visit("/testnet"); diff --git a/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts b/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts index fe10d56bb..47ab19329 100644 --- a/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts +++ b/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts @@ -88,13 +88,16 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy { block.blink = specialBlocks[block.height] ? true : false; } }); - const stringifiedBlocks = JSON.stringify(mempoolBlocks); - this.mempoolBlocksFull = JSON.parse(stringifiedBlocks); - this.mempoolBlocks = this.reduceMempoolBlocksToFitScreen(JSON.parse(stringifiedBlocks)); + + let blocks = mempoolBlocks; + if (!mempoolBlocks.length) { + blocks = [{ index: 0, blockSize: 0, blockVSize: 0, feeRange: [0, 0], medianFee: 0, nTx: 0, totalFees: 0 }]; + } + this.mempoolBlocksFull = blocks; + this.mempoolBlocks = this.reduceMempoolBlocksToFitScreen(blocks); this.updateMempoolBlockStyles(); this.calculateTransactionPosition(); - - return this.mempoolBlocks; + return blocks; }) ); From 3bab50a43bb86d732685dad9484fe8ca533629ad Mon Sep 17 00:00:00 2001 From: Miguel Medeiros Date: Mon, 15 Nov 2021 16:38:28 -0300 Subject: [PATCH 2/3] fix: blocksfull variable. --- .../mempool-blocks/mempool-blocks.component.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts b/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts index 47ab19329..e9f38ed1e 100644 --- a/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts +++ b/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts @@ -89,15 +89,17 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy { } }); - let blocks = mempoolBlocks; if (!mempoolBlocks.length) { - blocks = [{ index: 0, blockSize: 0, blockVSize: 0, feeRange: [0, 0], medianFee: 0, nTx: 0, totalFees: 0 }]; + const emptyBlock = [{ index: 0, blockSize: 0, blockVSize: 0, feeRange: [0, 0], medianFee: 0, nTx: 0, totalFees: 0 }]; + this.mempoolBlocks = this.reduceMempoolBlocksToFitScreen(emptyBlock); + } else { + const stringifiedBlocks = JSON.stringify(mempoolBlocks); + this.mempoolBlocksFull = JSON.parse(stringifiedBlocks); + this.mempoolBlocks = this.reduceMempoolBlocksToFitScreen(JSON.parse(stringifiedBlocks)); } - this.mempoolBlocksFull = blocks; - this.mempoolBlocks = this.reduceMempoolBlocksToFitScreen(blocks); this.updateMempoolBlockStyles(); this.calculateTransactionPosition(); - return blocks; + return this.mempoolBlocks; }) ); From 9cb203f98ab8b48854c3c7e262e626e819e61bb4 Mon Sep 17 00:00:00 2001 From: Miguel Medeiros Date: Mon, 15 Nov 2021 17:10:54 -0300 Subject: [PATCH 3/3] ref: remove function to better performance --- .../app/components/mempool-blocks/mempool-blocks.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts b/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts index e9f38ed1e..9000aab0b 100644 --- a/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts +++ b/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts @@ -91,7 +91,7 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy { if (!mempoolBlocks.length) { const emptyBlock = [{ index: 0, blockSize: 0, blockVSize: 0, feeRange: [0, 0], medianFee: 0, nTx: 0, totalFees: 0 }]; - this.mempoolBlocks = this.reduceMempoolBlocksToFitScreen(emptyBlock); + this.mempoolBlocks = emptyBlock; } else { const stringifiedBlocks = JSON.stringify(mempoolBlocks); this.mempoolBlocksFull = JSON.parse(stringifiedBlocks);