mirror of
https://github.com/cryptoadvance/specter-desktop.git
synced 2026-08-13 12:33:29 +02:00
Bugfix: Fix float issue (#1900)
Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
This commit is contained in:
parent
92c12d3730
commit
0bd48ab837
2 changed files with 17 additions and 15 deletions
|
|
@ -31,20 +31,16 @@ describe('Test sending transactions', () => {
|
|||
})
|
||||
})
|
||||
|
||||
// Skipped for now, will only work reliably once the the Cypress tests run without mining loop
|
||||
//
|
||||
it('Open up transaction details', () => {
|
||||
cy.selectWallet("Test Hot Wallet 1")
|
||||
cy.get('#btn_transactions').click()
|
||||
// Click on the txid in the first row
|
||||
cy.get('tbody.tx-tbody').find('tr').eq(0).find('#column-txid').find('.explorer-link').click()
|
||||
cy.get('.tx-data-info').contains('Input #0')
|
||||
cy.get('.tx-data-info').contains('Transaction id:')
|
||||
cy.get('.tx-data-info').contains('Output index:') // Not sure whether it is always 1 - output ordering is random in Core ...
|
||||
cy.get('.tx-data-info').contains('Address #0')
|
||||
// Click on the txid of the (hopefully) only send tx
|
||||
cy.get('tbody.tx-tbody').find('tr').find('.svg-send').parent().parent().parent().find('#column-txid').find('.explorer-link').click()
|
||||
// Input
|
||||
cy.get('.tx-data-info').contains('Value: 20 tBTC')
|
||||
cy.get('.tx-data-info').contains('Output #0')
|
||||
cy.get('.tx-data-info').contains('Burn address')
|
||||
cy.get('.tx-data-info').contains('Value: 19.9999989 tBTC') // Fees should always be the same
|
||||
// Output
|
||||
cy.get('.tx-data-info').contains(/Value:\s19\.9999\d{3}/) // The amount from the raw tx has 7 decimals, fees change apparently
|
||||
cy.get('#page_overlay_popup_cancel_button').click()
|
||||
// Change to sats and check amounts and units
|
||||
cy.get('[href="/settings/"]').click()
|
||||
|
|
@ -52,9 +48,11 @@ describe('Test sending transactions', () => {
|
|||
cy.contains('Save').click()
|
||||
cy.selectWallet("Test Hot Wallet 1")
|
||||
cy.get('#btn_transactions').click()
|
||||
cy.get('tbody.tx-tbody').find('tr').eq(0).find('#column-txid').find('.explorer-link').click()
|
||||
cy.get('tbody.tx-tbody').find('tr').find('.svg-send').parent().parent().parent().find('#column-txid').find('.explorer-link').click()
|
||||
// Input
|
||||
cy.get('.tx-data-info').contains('Value: 2,000,000,000 tsat')
|
||||
cy.get('.tx-data-info').contains('Value: 1,999,999,890 tsat')
|
||||
// Output
|
||||
cy.get('.tx-data-info').contains(/Value:\s1,999,99\d,\d{3}\stsat/) // Fees change apparently
|
||||
cy.get('#page_overlay_popup_cancel_button').click()
|
||||
// Change back to btc
|
||||
cy.get('[href="/settings/"]').click()
|
||||
|
|
|
|||
|
|
@ -34,11 +34,15 @@
|
|||
function formatBtcAmount(valueInBTC, unitLabel, convertToSat){
|
||||
var formattedUnitLabel = formatUnitLabel(unitLabel, convertToSat);
|
||||
var formattedValue = valueInBTC;
|
||||
if (valueInBTC) {
|
||||
value = parseFloat(valueInBTC.toFixed(8));
|
||||
if (formattedValue) {
|
||||
// The second condition in the if clause if True if formattedUnitLabel is equal to any element of the array
|
||||
if (convertToSat && (["Lsat", "sat", "tLsat", "tsat"].indexOf(formattedUnitLabel) > -1)) {
|
||||
formattedValue = parseInt(value * 1e8)
|
||||
// if it is sat, then format at integer
|
||||
formattedValue = parseInt(parseFloat(valueInBTC) * 1e8);
|
||||
}
|
||||
else{
|
||||
// else, then cut off at 8 digits
|
||||
formattedValue = parseFloat(valueInBTC).toFixed(8);
|
||||
}
|
||||
formattedValue = `${numberWithCommas(formattedValue)}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue