diff --git a/Makefile b/Makefile index 8e7a2d21..a22559c2 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,12 @@ check: make lint make types +test-unit: + python -m pytest tests/unit + +test-integration: + python -m pytest tests/integration + test: python -m pytest tests diff --git a/src/models/batch_rewards_schema.py b/src/models/batch_rewards_schema.py index 8e253ea0..a3bc5bab 100644 --- a/src/models/batch_rewards_schema.py +++ b/src/models/batch_rewards_schema.py @@ -27,13 +27,13 @@ def from_pdf_to_dune_records(cls, rewards_df: DataFrame) -> list[dict[str, Any]] "block_deadline": int(row["block_deadline"]), "data": { # All the following values are in WEI. - "uncapped_payment_eth": str(row["uncapped_payment_eth"]), - "capped_payment": str(row["capped_payment"]), - "execution_cost": str(row["execution_cost"]), - "surplus": str(row["surplus"]), - "fee": str(row["fee"]), - "winning_score": str(row["winning_score"]), - "reference_score": str(row["reference_score"]), + "uncapped_payment_eth": int(row["uncapped_payment_eth"]), + "capped_payment": int(row["capped_payment"]), + "execution_cost": int(row["execution_cost"]), + "surplus": int(row["surplus"]), + "fee": int(row["fee"]), + "winning_score": int(row["winning_score"]), + "reference_score": int(row["reference_score"]), "participating_solvers": row["participating_solvers"], }, } diff --git a/src/sql/orderbook/batch_rewards.sql b/src/sql/orderbook/batch_rewards.sql index a416a0fa..affa000b 100644 --- a/src/sql/orderbook/batch_rewards.sql +++ b/src/sql/orderbook/batch_rewards.sql @@ -86,12 +86,12 @@ SELECT settlement_block as block_number, else concat('0x', encode(tx_hash, 'hex')) end as tx_hash, concat('0x', encode(solver, 'hex')) as solver, - execution_cost, - surplus, - fee, - uncapped_payment_eth, - capped_payment, - winning_score, - reference_score, + execution_cost::text as execution_cost, + surplus::text as surplus, + fee::text as fee, + uncapped_payment_eth::text as uncapped_payment_eth, + capped_payment::text as capped_payment, + winning_score::text as winning_score, + reference_score::text as reference_score, participating_solvers FROM reward_per_auction diff --git a/tests/integration/test_fetch_orderbook.py b/tests/integration/test_fetch_orderbook.py index 4177a492..7214c8db 100644 --- a/tests/integration/test_fetch_orderbook.py +++ b/tests/integration/test_fetch_orderbook.py @@ -59,39 +59,39 @@ def test_get_batch_rewards(self): "0x55a37a2e5e5973510ac9d9c723aec213fa161919", ], "execution_cost": [ - 5417013431615490.0, - 14681404168612460.0, - 0.0, + 5417013431615490, + 14681404168612460, + 0, ], "surplus": [ - 5867838023808109.0, - 104011002982952096.0, - 0.0, + 5867838023808109, + 104011002982952096, + 0, ], "fee": [ - 7751978767036064.0, - 10350680045815652.0, - 0.0, + 7751978767036064, + 10350680045815652, + 0, ], "uncapped_payment_eth": [ - 7232682540629268.0, - 82825156151734416.0, - -3527106002507021.0, + 7232682540629268, + 82825156151734416, + -3527106002507021, ], "capped_payment": [ - 7232682540629268.0, - 24681404168612460.0, - -3527106002507021.0, + 7232682540629268, + 24681404168612460, + -3527106002507021, ], "winning_score": [ - 6537976145828389.0, - 95640781782532192.0, - 3527282436747751.0, + 6537976145828389, + 95640781782532192, + 3527282436747751, ], "reference_score": [ - 6387134250214905.0, - 31536526877033328.0, - 3527106002507021.0, + 6387134250214905, + 31536526877033328, + 3527106002507021, ], "participating_solvers": [ [ diff --git a/tests/unit/test_batch_rewards_schema.py b/tests/unit/test_batch_rewards_schema.py index 57e9026e..cfdaaca1 100644 --- a/tests/unit/test_batch_rewards_schema.py +++ b/tests/unit/test_batch_rewards_schema.py @@ -10,6 +10,7 @@ class TestModelBatchRewards(unittest.TestCase): def test_order_rewards_transformation(self): + max_uint = 115792089237316195423570985008687907853269984665640564039457584007913129639936 sample_df = pd.DataFrame( { "block_number": pd.Series([123, pandas.NA], dtype="Int64"), @@ -26,7 +27,7 @@ def test_order_rewards_transformation(self): "surplus": [2 * ONE_ETH, 3 * ONE_ETH], "fee": [ 1000000000000000, - 0, + max_uint, ], "uncapped_payment_eth": [0, -10 * ONE_ETH], "capped_payment": [-1000000000000000, -1000000000000000], @@ -56,14 +57,14 @@ def test_order_rewards_transformation(self): "block_deadline": 789, "block_number": 123, "data": { - "capped_payment": "-1000000000000000", - "execution_cost": "9999000000000000000000", - "fee": "1000000000000000", + "capped_payment": -1000000000000000, + "execution_cost": 9999000000000000000000, + "fee": 1000000000000000, "participating_solvers": ["0x51", "0x52", "0x53"], - "reference_score": "1000000000000000000", - "surplus": "2000000000000000000", - "uncapped_payment_eth": "0", - "winning_score": "123456000000000000000000", + "reference_score": 1000000000000000000, + "surplus": 2000000000000000000, + "uncapped_payment_eth": 0, + "winning_score": 123456000000000000000000, }, "solver": "0x51", "tx_hash": "0x71", @@ -72,9 +73,9 @@ def test_order_rewards_transformation(self): "block_deadline": 1011, "block_number": None, "data": { - "capped_payment": "-1000000000000000", - "execution_cost": "1", - "fee": "0", + "capped_payment": -1000000000000000, + "execution_cost": 1, + "fee": max_uint, "participating_solvers": [ "0x51", "0x52", @@ -83,10 +84,10 @@ def test_order_rewards_transformation(self): "0x55", "0x56", ], - "reference_score": "2000000000000000000", - "surplus": "3000000000000000000", - "uncapped_payment_eth": "-10000000000000000000", - "winning_score": "6789000000000000000000", + "reference_score": 2000000000000000000, + "surplus": 3000000000000000000, + "uncapped_payment_eth": -10000000000000000000, + "winning_score": 6789000000000000000000, }, "solver": "0x52", "tx_hash": None,