diff --git a/frontend/cypress/e2e/mainnet/mainnet.spec.ts b/frontend/cypress/e2e/mainnet/mainnet.spec.ts index a1082b769..5a36569ee 100644 --- a/frontend/cypress/e2e/mainnet/mainnet.spec.ts +++ b/frontend/cypress/e2e/mainnet/mainnet.spec.ts @@ -594,4 +594,63 @@ describe('Mainnet', () => { } else { it.skip(`Tests cannot be run on the selected BASE_MODULE ${baseModule}`); } + + describe('Accelerated Transactions', () => { + describe('Unconfirmed Accelerated Transaction', () => { + before(() => { + cy.intercept('/api/tx/40ba6b3c4ce73e3ba0160c137b1cc6c2c7333a2b9c19537b61ee8a8aaf095e0a', { + fixture: 'accelerated_tx.json' + }).as('tx'); + + cy.intercept('/api/v1/cpfp/40ba6b3c4ce73e3ba0160c137b1cc6c2c7333a2b9c19537b61ee8a8aaf095e0a', { + fixture: 'accelerated_cpfp.json' + }).as('accelerated_cpfp'); + + cy.intercept('/api/v1/transaction-times?txId%5B%5D=40ba6b3c4ce73e3ba0160c137b1cc6c2c7333a2b9c19537b61ee8a8aaf095e0a', { + body: '[1723416086]', + }).as('transaction-time'); + + cy.intercept('https://mempool.space/api/v1/services/accelerator/accelerations/history', { + fixture: 'accelerated_history.json' + }).as('history'); + + cy.viewport('macbook-16'); + cy.mockMempoolSocket(); + cy.visit('/tx/40ba6b3c4ce73e3ba0160c137b1cc6c2c7333a2b9c19537b61ee8a8aaf095e0a'); + + emitMempoolInfo({ + 'params': { + command: 'txPosition' + } + }); + cy.waitForSkeletonGone(); + }); + + it('shows unconfirmed accelerated transaction properly', () => { + cy.get('.badge-accelerated').should('exist'); + cy.get('[data-cy="active-acceleration-box"]').should('exist'); + cy.get('[data-cy="active-acceleration-box"] > table > tbody > :nth-child(1) .oobFees').invoke('text').should('contain', `15.5 `); + cy.get('[data-cy="tx-fee-delta"]').invoke('text').should('contain', `3,000`); + cy.get('#acceleration-timeline').should('be.visible'); + }); + + // currently doesn't work due to 'accelerations/history' endpoint not being intercepted + it.skip('properly render accelerated transacion as it confirms', () => { + emitMempoolInfo({ + 'params': { + command: 'txPositionConfirmed' + } + }); + + cy.wait(1000); + + cy.get('.badge-accelerated').should('exist'); + cy.get('[data-cy="active-acceleration-box"]').should('not.exist'); + cy.get('[data-cy="fee-rate"]').invoke('text').should('contain', `2.17 `); + cy.get('[data-cy="tx-fee-delta"]').invoke('text').should('contain', `39`); + cy.get('#acceleration-timeline').should('be.visible'); + }); + }); + }); + }); diff --git a/frontend/cypress/fixtures/accelerated_cpfp.json b/frontend/cypress/fixtures/accelerated_cpfp.json new file mode 100644 index 000000000..a2f2efd83 --- /dev/null +++ b/frontend/cypress/fixtures/accelerated_cpfp.json @@ -0,0 +1,20 @@ +{ + "ancestors": [], + "bestDescendant": null, + "descendants": [], + "effectiveFeePerVsize": 15.452914798206278, + "sigops": 4, + "fee": 446, + "adjustedVsize": 223, + "acceleration": true, + "acceleratedBy": [ + 111, + 43, + 102, + 112, + 142, + 115 + ], + "acceleratedAt": 1723417553, + "feeDelta": 3000 +} diff --git a/frontend/cypress/fixtures/accelerated_history.json b/frontend/cypress/fixtures/accelerated_history.json new file mode 100644 index 000000000..4fab29427 --- /dev/null +++ b/frontend/cypress/fixtures/accelerated_history.json @@ -0,0 +1,24 @@ +[ + { + "txid": "40ba6b3c4ce73e3ba0160c137b1cc6c2c7333a2b9c19537b61ee8a8aaf095e0a", + "status": "completed", + "added": 1723417553, + "lastUpdated": 1723424127, + "effectiveFee": 446, + "effectiveVsize": 223, + "feeDelta": 3000, + "blockHash": "000000000000000000005bc0a822da172e43c687428cc268177ad27d636f3059", + "blockHeight": 856387, + "bidBoost": 39, + "boostVersion": "v2", + "pools": [ + 111, + 43, + 102, + 112, + 142, + 115 + ], + "minedByPoolUniqueId": 111 + } +] \ No newline at end of file diff --git a/frontend/cypress/fixtures/accelerated_position.json b/frontend/cypress/fixtures/accelerated_position.json new file mode 100644 index 000000000..8e321f3e4 --- /dev/null +++ b/frontend/cypress/fixtures/accelerated_position.json @@ -0,0 +1,48 @@ +{ + "txPosition": { + "txid": "40ba6b3c4ce73e3ba0160c137b1cc6c2c7333a2b9c19537b61ee8a8aaf095e0a", + "position": { + "block": 0, + "vsize": 37321.5, + "accelerated": true + }, + "accelerationPositions": [ + { + "block": 0, + "vsize": 37321.5, + "poolId": 111, + "pool": "Foundry USA" + }, + { + "block": 0, + "vsize": 37321.5, + "poolId": 43, + "pool": "Braiins Pool" + }, + { + "block": 0, + "vsize": 37321.5, + "poolId": 102, + "pool": "SpiderPool" + }, + { + "block": 0, + "vsize": 37321.5, + "poolId": 112, + "pool": "SBI Crypto" + }, + { + "block": 0, + "vsize": 37321.5, + "poolId": 142, + "pool": "OCEAN" + }, + { + "block": 0, + "vsize": 37321.5, + "poolId": 115, + "pool": "MARA Pool" + } + ] + } +} \ No newline at end of file diff --git a/frontend/cypress/fixtures/accelerated_position_confirmed.json b/frontend/cypress/fixtures/accelerated_position_confirmed.json new file mode 100644 index 000000000..f59e9d76a --- /dev/null +++ b/frontend/cypress/fixtures/accelerated_position_confirmed.json @@ -0,0 +1,66 @@ +{ + "txConfirmed": "40ba6b3c4ce73e3ba0160c137b1cc6c2c7333a2b9c19537b61ee8a8aaf095e0a", + "block":{ + "id": "000000000000000000014cc3d86b7c096ef92aca180e3cf27d72e34ce944caed", + "height": 837051, + "version": 821051392, + "timestamp": 1723452588, + "bits": 386079422, + "nonce": 2215159619, + "difficulty": 90666502495565.78, + "merkle_root": "207ad51f6c1150f63fcd043eb1b4624b77ac70558594317e989c1109fbb47c47", + "tx_count": 2284, + "size": 1490522, + "weight": 3993155, + "previousblockhash": "00000000000000000002b8a66307c997aa27bf99a384ceb7cfe5f29576eddb26", + "mediantime": 1723450608, + "stale": false, + "extras": { + "reward": 319417632, + "coinbaseRaw": "0378110d04adccb9662f466f756e6472792055534120506f6f6c202364726f70676f6c642f2c08727fca05000000000000", + "orphans": [], + "medianFee": 4.021446911342697, + "feeRange": [ + 3.1, + 3.4184397163120566, + 3.998624011007912, + 4.444976076555024, + 5.382978723404255, + 11.62814371257485, + 468.75 + ], + "totalFees": 6917632, + "avgFee": 3030, + "avgFeeRate": 6, + "utxoSetChange": -2647, + "avgTxSize": 652.44, + "totalInputs": 8544, + "totalOutputs": 5897, + "totalOutputAmt": 2950130527407, + "segwitTotalTxs": 2084, + "segwitTotalSize": 1137877, + "segwitTotalWeight": 2582683, + "feePercentiles": null, + "virtualSize": 998288.75, + "coinbaseAddress": "bc1p8k4v4xuz55dv49svzjg43qjxq2whur7ync9tm0xgl5t4wjl9ca9snxgmlt", + "coinbaseAddresses": [ + "bc1p8k4v4xuz55dv49svzjg43qjxq2whur7ync9tm0xgl5t4wjl9ca9snxgmlt", + "bc1qxhmdufsvnuaaaer4ynz88fspdsxq2h9e9cetdj" + ], + "coinbaseSignature": "OP_PUSHNUM_1 OP_PUSHBYTES_32 3daaca9b82a51aca960c1491588246029d7e0fc49e0abdbcc8fd17574be5c74b", + "coinbaseSignatureAscii": "f/Foundry USA Pool #dropgold/", + "header": "0040f03026dbed7695f2e5cfb7ce84a399bf27aa97c90763a6b802000000000000000000477cb4fb09119c987e3194855570ac774b62b4b13e04cd3ff650116c1fd57a20acccb966be1a031743a70884", + "utxoSetSize": null, + "totalInputAmt": null, + "pool": { + "id": 111, + "name": "Foundry USA", + "slug": "foundryusa" + }, + "matchRate": 100, + "expectedFees": 6957093, + "expectedWeight": 3991895, + "similarity": 0.9907343565880212 + } + } +} \ No newline at end of file diff --git a/frontend/cypress/fixtures/accelerated_tx.json b/frontend/cypress/fixtures/accelerated_tx.json new file mode 100644 index 000000000..03fac9881 --- /dev/null +++ b/frontend/cypress/fixtures/accelerated_tx.json @@ -0,0 +1,45 @@ +{ + "txid": "40ba6b3c4ce73e3ba0160c137b1cc6c2c7333a2b9c19537b61ee8a8aaf095e0a", + "version": 1, + "locktime": 0, + "vin": [ + { + "txid": "7c6e17739d7225d097db1f08df17d06dc712dc0951f266db1070939b85b5e8e7", + "vout": 0, + "prevout": { + "scriptpubkey": "76a914fb706ea28ba8f83e3cfa2fa1f3f01a6a613b94ca88ac", + "scriptpubkey_asm": "OP_DUP OP_HASH160 OP_PUSHBYTES_20 fb706ea28ba8f83e3cfa2fa1f3f01a6a613b94ca OP_EQUALVERIFY OP_CHECKSIG", + "scriptpubkey_type": "p2pkh", + "scriptpubkey_address": "1PvVJ5FvkNnsatmD4nfkb6j59CjKq7dxxy", + "value": 16610556 + }, + "scriptsig": "483045022100811726483f9c91dd91aa136c6ba4e97e6db79ef7026aa4fdd4216ea6a954f91a0220508b7fdf4078bf82114f7cfed5090b77114dec19b122870a34e562689441399d01210275f84bf0270b233f83be9b1ba6549e3281a133bfd93b24e1c16d80c4e742f09e", + "scriptsig_asm": "OP_PUSHBYTES_72 3045022100811726483f9c91dd91aa136c6ba4e97e6db79ef7026aa4fdd4216ea6a954f91a0220508b7fdf4078bf82114f7cfed5090b77114dec19b122870a34e562689441399d01 OP_PUSHBYTES_33 0275f84bf0270b233f83be9b1ba6549e3281a133bfd93b24e1c16d80c4e742f09e", + "is_coinbase": false, + "sequence": 4294967295 + } + ], + "vout": [ + { + "scriptpubkey": "0014ce6c0bb00482016d12657174b6468cd01df6421e", + "scriptpubkey_asm": "OP_0 OP_PUSHBYTES_20 ce6c0bb00482016d12657174b6468cd01df6421e", + "scriptpubkey_type": "v0_p2wpkh", + "scriptpubkey_address": "bc1qeekqhvqysgqk6yn9w96tv35v6qwlvss7vuvtj0", + "value": 6796193 + }, + { + "scriptpubkey": "76a914fb706ea28ba8f83e3cfa2fa1f3f01a6a613b94ca88ac", + "scriptpubkey_asm": "OP_DUP OP_HASH160 OP_PUSHBYTES_20 fb706ea28ba8f83e3cfa2fa1f3f01a6a613b94ca OP_EQUALVERIFY OP_CHECKSIG", + "scriptpubkey_type": "p2pkh", + "scriptpubkey_address": "1PvVJ5FvkNnsatmD4nfkb6j59CjKq7dxxy", + "value": 9813917 + } + ], + "size": 223, + "weight": 892, + "sigops": 4, + "fee": 446, + "status": { + "confirmed": false + } +} \ No newline at end of file diff --git a/frontend/cypress/support/websocket.ts b/frontend/cypress/support/websocket.ts index 1356ccc76..afbd27d3e 100644 --- a/frontend/cypress/support/websocket.ts +++ b/frontend/cypress/support/websocket.ts @@ -96,6 +96,18 @@ export const emitMempoolInfo = ({ }); break; } + case 'txPosition': { + cy.readFile('cypress/fixtures/accelerated_position.json', 'ascii').then((fixture) => { + win.mockSocket.send(JSON.stringify(fixture)); + }); + break; + } + case 'txPositionConfirmed': { + cy.readFile('cypress/fixtures/accelerated_position_confirmed.json', 'ascii').then((fixture) => { + win.mockSocket.send(JSON.stringify(fixture)); + }); + break; + } default: break; } diff --git a/frontend/src/app/components/transaction/transaction.component.html b/frontend/src/app/components/transaction/transaction.component.html index 9d3c0d678..a16109fda 100644 --- a/frontend/src/app/components/transaction/transaction.component.html +++ b/frontend/src/app/components/transaction/transaction.component.html @@ -608,7 +608,7 @@