Do not round the order's bid_per_byte value

Store the fractional value on the db. Let the frontend round if
necessary but keep it non-rounded on the backend.
This commit is contained in:
Blockstream Satellite 2021-07-06 11:44:10 -03:00
parent 1568ee54f2
commit 24a4c5ccb7
2 changed files with 2 additions and 3 deletions

View file

@ -39,8 +39,7 @@ def _unpaid_invoices_total(order):
def adjust_bids(order):
order.bid = _paid_invoices_total(order)
order.bid_per_byte = round(
order.bid / calc_ota_msg_len(order.message_size), 2)
order.bid_per_byte = order.bid / calc_ota_msg_len(order.message_size)
order.unpaid_bid = _unpaid_invoices_total(order)
db.session.commit()

View file

@ -253,7 +253,7 @@ def test_adjust_bids(client):
assert order.bid == paid_bid
assert order.unpaid_bid == unpaid_bid
expected_bid_per_byte = paid_bid / (n_bytes + 52) # w/ 52 overhead bytes
assert order.bid_per_byte == round(expected_bid_per_byte, 2)
assert order.bid_per_byte == expected_bid_per_byte
@patch('orders.new_invoice')