From ada27e4359528875d10b400dbac8918478fda4e0 Mon Sep 17 00:00:00 2001 From: Martijn de Vos Date: Wed, 28 Oct 2020 17:33:59 +0100 Subject: [PATCH] Converted bandwidth amount to BIGINT type --- .../modules/bandwidth_accounting/transaction.py | 2 +- .../modules/tests/bandwidth_accounting/test_database.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/tribler-core/tribler_core/modules/bandwidth_accounting/transaction.py b/src/tribler-core/tribler_core/modules/bandwidth_accounting/transaction.py index fc4542c1d4a..97a2951a4c8 100644 --- a/src/tribler-core/tribler_core/modules/bandwidth_accounting/transaction.py +++ b/src/tribler-core/tribler_core/modules/bandwidth_accounting/transaction.py @@ -136,7 +136,7 @@ class BandwidthTransaction(db.Entity): public_key_b = Required(bytes, index=True) signature_a = Required(bytes) signature_b = Required(bytes) - amount = Required(int) + amount = Required(int, size=64) timestamp = Required(int, size=64) PrimaryKey(sequence_number, public_key_a, public_key_b) diff --git a/src/tribler-core/tribler_core/modules/tests/bandwidth_accounting/test_database.py b/src/tribler-core/tribler_core/modules/tests/bandwidth_accounting/test_database.py index 42435163b52..37cfa2f7c9b 100644 --- a/src/tribler-core/tribler_core/modules/tests/bandwidth_accounting/test_database.py +++ b/src/tribler-core/tribler_core/modules/tests/bandwidth_accounting/test_database.py @@ -46,6 +46,15 @@ def test_get_latest_transaction(bandwidth_db): assert tx2.amount == 3000 +@db_session +def test_store_large_transaction(bandwidth_db): + large_tx = BandwidthTransactionData(1, b"a", b"b", EMPTY_SIGNATURE, EMPTY_SIGNATURE, 1024 * 1024 * 1024 * 3) + bandwidth_db.BandwidthTransaction.insert(large_tx) + + latest_tx = bandwidth_db.get_latest_transaction(b"a", b"b") + assert latest_tx + + @pytest.mark.asyncio async def test_totals(bandwidth_db): with db_session: