Skip to content

Commit 6e391ee

Browse files
committed
Fix aggregate
1 parent ce493d7 commit 6e391ee

File tree

8 files changed

+32
-141
lines changed

8 files changed

+32
-141
lines changed

tests/mainnet/Base_Mainnet.py

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,11 @@ def log_error(error, node_name, step='unknown', remote_node=None):
120120
node_error_file = f"test_output/errors_{node_name.replace(' ', '_')}.json"
121121
os.makedirs("test_output", exist_ok=True)
122122

123-
# Load existing errors for this node
124-
if os.path.exists(node_error_file):
125-
with open(node_error_file, 'r') as f:
126-
try:
127-
node_errors = json.load(f)
128-
except:
129-
node_errors = {}
130-
else:
131-
node_errors = {}
123+
# Use the in-memory error_stats as the source of truth for this node
124+
# This ensures we only track errors from the current test run
125+
node_errors = error_stats.get(node_name, {}).copy()
132126

133-
# Update errors for this node
134-
if key in node_errors:
135-
node_errors[key] += 1
136-
else:
137-
node_errors[key] = 1
138-
139-
# Save back to individual node file
127+
# Save current state to individual node file
140128
with open(node_error_file, 'w') as f:
141129
json.dump(node_errors, f, indent=2)
142130

@@ -275,21 +263,6 @@ def avg(times): return round(sum(times) / len(times), 2) if times else 0.0
275263
with open(f"test_output/summary_{name.replace(' ', '_')}.json", "w") as f:
276264
json.dump(summary, f, indent=2)
277265

278-
# Write error file by merging with existing errors from the aggregated file
279-
error_file = "test_output/error_stats.json"
280-
if os.path.exists(error_file):
281-
with open(error_file, 'r') as f:
282-
try:
283-
all_errors = json.load(f)
284-
node_errors = all_errors.get(name, {})
285-
except:
286-
node_errors = {}
287-
else:
288-
node_errors = {}
289-
290-
with open(f"test_output/errors_{name.replace(' ', '_')}.json", "w") as f:
291-
json.dump(node_errors, f, indent=2)
292-
293266
print(f"\n──────────── Summary for {name} ────────────")
294267
if failed_assets:
295268
print("🔍 Failed Assets:")

tests/mainnet/Gnosis_Mainnet.py

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,11 @@ def log_error(error, node_name, step='unknown', remote_node=None):
120120
node_error_file = f"test_output/errors_{node_name.replace(' ', '_')}.json"
121121
os.makedirs("test_output", exist_ok=True)
122122

123-
# Load existing errors for this node
124-
if os.path.exists(node_error_file):
125-
with open(node_error_file, 'r') as f:
126-
try:
127-
node_errors = json.load(f)
128-
except:
129-
node_errors = {}
130-
else:
131-
node_errors = {}
123+
# Use the in-memory error_stats as the source of truth for this node
124+
# This ensures we only track errors from the current test run
125+
node_errors = error_stats.get(node_name, {}).copy()
132126

133-
# Update errors for this node
134-
if key in node_errors:
135-
node_errors[key] += 1
136-
else:
137-
node_errors[key] = 1
138-
139-
# Save back to individual node file
127+
# Save current state to individual node file
140128
with open(node_error_file, 'w') as f:
141129
json.dump(node_errors, f, indent=2)
142130

@@ -275,21 +263,6 @@ def avg(times): return round(sum(times) / len(times), 2) if times else 0.0
275263
with open(f"test_output/summary_{name.replace(' ', '_')}.json", "w") as f:
276264
json.dump(summary, f, indent=2)
277265

278-
# Write error file by merging with existing errors from the aggregated file
279-
error_file = "test_output/error_stats.json"
280-
if os.path.exists(error_file):
281-
with open(error_file, 'r') as f:
282-
try:
283-
all_errors = json.load(f)
284-
node_errors = all_errors.get(name, {})
285-
except:
286-
node_errors = {}
287-
else:
288-
node_errors = {}
289-
290-
with open(f"test_output/errors_{name.replace(' ', '_')}.json", "w") as f:
291-
json.dump(node_errors, f, indent=2)
292-
293266
print(f"\n──────────── Summary for {name} ────────────")
294267
if failed_assets:
295268
print("🔍 Failed Assets:")

tests/mainnet/Neuroweb_Mainnet.py

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,11 @@ def log_error(error, node_name, step='unknown', remote_node=None):
120120
node_error_file = f"test_output/errors_{node_name.replace(' ', '_')}.json"
121121
os.makedirs("test_output", exist_ok=True)
122122

123-
# Load existing errors for this node
124-
if os.path.exists(node_error_file):
125-
with open(node_error_file, 'r') as f:
126-
try:
127-
node_errors = json.load(f)
128-
except:
129-
node_errors = {}
130-
else:
131-
node_errors = {}
123+
# Use the in-memory error_stats as the source of truth for this node
124+
# This ensures we only track errors from the current test run
125+
node_errors = error_stats.get(node_name, {}).copy()
132126

133-
# Update errors for this node
134-
if key in node_errors:
135-
node_errors[key] += 1
136-
else:
137-
node_errors[key] = 1
138-
139-
# Save back to individual node file
127+
# Save current state to individual node file
140128
with open(node_error_file, 'w') as f:
141129
json.dump(node_errors, f, indent=2)
142130

@@ -274,21 +262,6 @@ def avg(times): return round(sum(times) / len(times), 2) if times else 0.0
274262
os.makedirs("test_output", exist_ok=True)
275263
with open(f"test_output/summary_{name.replace(' ', '_')}.json", "w") as f:
276264
json.dump(summary, f, indent=2)
277-
278-
# Write error file by merging with existing errors from the aggregated file
279-
error_file = "test_output/error_stats.json"
280-
if os.path.exists(error_file):
281-
with open(error_file, 'r') as f:
282-
try:
283-
all_errors = json.load(f)
284-
node_errors = all_errors.get(name, {})
285-
except:
286-
node_errors = {}
287-
else:
288-
node_errors = {}
289-
290-
with open(f"test_output/errors_{name.replace(' ', '_')}.json", "w") as f:
291-
json.dump(node_errors, f, indent=2)
292265

293266
print(f"\n──────────── Summary for {name} ────────────")
294267
if failed_assets:

tests/mainnet/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def setup_test_environment():
2525
# Create test_output directory if it doesn't exist
2626
os.makedirs("test_output", exist_ok=True)
2727

28+
# Clear global dictionaries to prevent errors from previous runs
29+
global_stats.clear()
30+
error_stats.clear()
31+
2832
# Clear error files at the start of each test run to show only current run errors
2933
error_files_to_clear = [
3034
"test_output/error_stats.json",

tests/testnet/Base_Testnet.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,11 @@ def log_error(error, node_name, step='unknown', remote_node=None):
125125
node_error_file = f"test_output/errors_{node_name.replace(' ', '_')}.json"
126126
os.makedirs("test_output", exist_ok=True)
127127

128-
# Load existing errors for this node
129-
if os.path.exists(node_error_file):
130-
with open(node_error_file, 'r') as f:
131-
try:
132-
node_errors = json.load(f)
133-
except:
134-
node_errors = {}
135-
else:
136-
node_errors = {}
137-
138-
# Update errors for this node
139-
if key in node_errors:
140-
node_errors[key] += 1
141-
else:
142-
node_errors[key] = 1
128+
# Use the in-memory error_stats as the source of truth for this node
129+
# This ensures we only track errors from the current test run
130+
node_errors = error_stats.get(node_name, {}).copy()
143131

144-
# Save back to individual node file
132+
# Save current state to individual node file
145133
with open(node_error_file, 'w') as f:
146134
json.dump(node_errors, f, indent=2)
147135

tests/testnet/Gnosis_Testnet.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,11 @@ def log_error(error, node_name, step='unknown', remote_node=None):
125125
node_error_file = f"test_output/errors_{node_name.replace(' ', '_')}.json"
126126
os.makedirs("test_output", exist_ok=True)
127127

128-
# Load existing errors for this node
129-
if os.path.exists(node_error_file):
130-
with open(node_error_file, 'r') as f:
131-
try:
132-
node_errors = json.load(f)
133-
except:
134-
node_errors = {}
135-
else:
136-
node_errors = {}
137-
138-
# Update errors for this node
139-
if key in node_errors:
140-
node_errors[key] += 1
141-
else:
142-
node_errors[key] = 1
128+
# Use the in-memory error_stats as the source of truth for this node
129+
# This ensures we only track errors from the current test run
130+
node_errors = error_stats.get(node_name, {}).copy()
143131

144-
# Save back to individual node file
132+
# Save current state to individual node file
145133
with open(node_error_file, 'w') as f:
146134
json.dump(node_errors, f, indent=2)
147135

tests/testnet/Neuroweb_Testnet.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,11 @@ def log_error(error, node_name, step='unknown', remote_node=None):
125125
node_error_file = f"test_output/errors_{node_name.replace(' ', '_')}.json"
126126
os.makedirs("test_output", exist_ok=True)
127127

128-
# Load existing errors for this node
129-
if os.path.exists(node_error_file):
130-
with open(node_error_file, 'r') as f:
131-
try:
132-
node_errors = json.load(f)
133-
except:
134-
node_errors = {}
135-
else:
136-
node_errors = {}
137-
138-
# Update errors for this node
139-
if key in node_errors:
140-
node_errors[key] += 1
141-
else:
142-
node_errors[key] = 1
128+
# Use the in-memory error_stats as the source of truth for this node
129+
# This ensures we only track errors from the current test run
130+
node_errors = error_stats.get(node_name, {}).copy()
143131

144-
# Save back to individual node file
132+
# Save current state to individual node file
145133
with open(node_error_file, 'w') as f:
146134
json.dump(node_errors, f, indent=2)
147135

tests/testnet/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def setup_test_environment():
2525
# Create test_output directory if it doesn't exist
2626
os.makedirs("test_output", exist_ok=True)
2727

28+
# Clear global dictionaries to prevent errors from previous runs
29+
global_stats.clear()
30+
error_stats.clear()
31+
2832
# Clear error files at the start of each test run to show only current run errors
2933
error_files_to_clear = [
3034
"test_output/error_stats.json",

0 commit comments

Comments
 (0)