Skip to content

Commit eb7affe

Browse files
authored
Merge pull request #8 from Cycxyz/aggregated_test
Aggregated test
2 parents 528421a + 2e70b7d commit eb7affe

5 files changed

Lines changed: 40 additions & 41 deletions

File tree

.github/ci.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

nft_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def read_events_chunked(contract, start_block, end_block, chunk_size=10000):
7474
all_logs = []
7575
current_block = start_block
7676

77-
while current_block <= end_block:
77+
while current_block < end_block:
7878
chunk_end = min(current_block + chunk_size - 1, end_block)
7979

8080
try:

pilot_vault_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def read_events_chunked(contract, start_block, end_block, chunk_size=10000):
7474
all_logs = []
7575
current_block = start_block
7676

77-
while current_block <= end_block:
77+
while current_block < end_block:
7878
chunk_end = min(current_block + chunk_size - 1, end_block)
7979

8080
try:

test/test_aggregate_points.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from test_points import load_points_sorted, DATA_DIR
2+
from pathlib import Path
3+
import json
4+
5+
6+
def load_aggregated_points_sorted():
7+
aggregated_points_dir = DATA_DIR / "aggregated_points"
8+
aggregated_points = sorted(
9+
aggregated_points_dir.glob("*.json"), key=lambda f: int(f.stem)
10+
)
11+
return [json.loads(f.read_text()) for f in aggregated_points]
12+
13+
14+
class TestAggregatePoints:
15+
def test_aggregate_points_borders_match_points_borders(self):
16+
aggregated_points = load_aggregated_points_sorted()
17+
points = load_points_sorted()
18+
for i in range(len(aggregated_points)):
19+
for user, data in aggregated_points[i]["points"].items():
20+
assert (
21+
sum(
22+
[
23+
point["points"].get(user.lower(), 0)
24+
for point in points[: i + 1]
25+
]
26+
)
27+
== data["cumulative_points"]
28+
)
29+
30+
assert (
31+
sum([sum(point["points"].values()) for point in points[: i + 1]])
32+
== aggregated_points[i]["metadata"]["total_points_all_users"]
33+
)
34+
assert (
35+
sum(user_points for _, user_points in points[i]["points"].items())
36+
== aggregated_points[i]["metadata"]["day_points"]
37+
)

test/test_user_balance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def get_onchain_balances(w3, state_data, users_data, addresses, block_key):
3535
block = state_data[block_key] if block_key == "end_block" else state_data[block_key] - 1
3636
for user, _ in users_data.items():
3737
contract = w3.eth.contract(
38-
address=Web3.to_checksum_address(["pilot_vault"]), abi=ERC20_ABI
38+
address=Web3.to_checksum_address(addresses["pilot_vault"]), abi=ERC20_ABI
3939
)
4040
balance = contract.functions.balanceOf(Web3.to_checksum_address(user)).call(
4141
block_identifier=block

0 commit comments

Comments
 (0)