Skip to content

Commit

Permalink
[Easy] fix subtle difference in (non-deterministic) test (#179)
Browse files Browse the repository at this point in the history
* fix subtle difference in (non-deterministic) test

* add todo

* remove unnecessary changes
  • Loading branch information
bh2smith authored Feb 2, 2023
1 parent 2805e2e commit 274a5b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/fetch/prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,6 @@ def usd_price(token: TokenId, day: datetime) -> float:
item = response_list[0]
price_time = datetime.strptime(item["timestamp"], "%Y-%m-%dT00:00:00Z")
assert price_time == day
return float(item["price"])
result = float(item["price"])
log.info(f"got price {result}")
return result
8 changes: 6 additions & 2 deletions tests/unit/test_split_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

ONE_ETH = 10**18

# TODO - these tests aren't entirely deterministic because they make requests to CoinPaprika API for COW and ETH prices.
# We should be able to mock the return values of price fetching:
# cf https://github.com/cowprotocol/solver-rewards/pull/179


class TestSplitTransfers(unittest.TestCase):
def setUp(self) -> None:
Expand Down Expand Up @@ -241,7 +245,7 @@ def test_process_with_overdraft_exceeding_eth_not_cow(self):
receiver=self.redirect_map[self.solver].reward_target,
# This is the amount of COW deducted based on a "deterministic" price
# on the date of the fixed accounting period.
amount_wei=cow_reward - 11549056229718590750720,
amount_wei=cow_reward - 11528681622554420445184,
)
],
)
Expand Down Expand Up @@ -271,7 +275,7 @@ def test_process_with_overdraft_exceeding_both_eth_and_cow(self):
period=self.period,
account=self.solver,
name=self.solver_name,
wei=1913412838234630144,
wei=1913259812982984448,
)
},
)
Expand Down

0 comments on commit 274a5b1

Please sign in to comment.