From 21ca52aa271bc7b67f8147635a53cbafb29c9753 Mon Sep 17 00:00:00 2001 From: aitbc Date: Sat, 2 May 2026 15:22:24 +0200 Subject: [PATCH] Replace datetime.UTC with timezone.utc in staking test data generator and QA cycle script --- scripts/testing/generate_staking_test_data.py | 20 +++++++++---------- scripts/testing/qa-cycle.py | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/testing/generate_staking_test_data.py b/scripts/testing/generate_staking_test_data.py index d97b3875..c8ab69cb 100755 --- a/scripts/testing/generate_staking_test_data.py +++ b/scripts/testing/generate_staking_test_data.py @@ -6,7 +6,7 @@ Generates realistic test data scenarios for staking tests import json import random -from datetime import datetime, UTC, timedelta +from datetime import datetime, timezone, timedelta from typing import Dict, List, Any # Performance tiers and their properties @@ -94,7 +94,7 @@ def generate_agent_metrics(tier: str = "GOLD") -> Dict[str, Any]: "total_staked": 0.0, "staker_count": 0, "total_rewards_distributed": 0.0, - "last_update_time": datetime.now(UTC).isoformat() + "last_update_time": timezone.utcnow().isoformat() } @@ -128,7 +128,7 @@ def generate_stake_data( lock_period_days = LOCK_PERIOD_MULTIPLIERS[lock_period_category]["days"] expected_apy = calculate_expected_apy(tier, lock_period_days) - start_time = datetime.now(UTC) + start_time = timezone.utcnow() end_time = start_time + timedelta(days=lock_period_days) return { @@ -158,7 +158,7 @@ def generate_staking_pool(agent_wallet: str, total_staked: float) -> Dict[str, A "pool_apy": 5.0, "staker_count": 0, "active_stakers": [], - "last_distribution_time": datetime.now(UTC).isoformat(), + "last_distribution_time": timezone.utcnow().isoformat(), "distribution_frequency": 1 } @@ -167,7 +167,7 @@ def generate_test_scenario(num_agents: int = 5, num_stakes_per_agent: int = 3) - """Generate a complete test scenario with multiple agents and stakes""" scenario = { "scenario_id": f"scenario_{random.randint(1000, 9999)}", - "generated_at": datetime.now(UTC).isoformat(), + "generated_at": timezone.utcnow().isoformat(), "agents": [], "stakes": [], "pools": [] @@ -310,7 +310,7 @@ def generate_unbonding_scenarios() -> List[Dict[str, Any]]: generate_staker_address(), lock_period_category="medium" ) - stake["end_time"] = (datetime.now(UTC) - timedelta(days=1)).isoformat() + stake["end_time"] = (timezone.utcnow() - timedelta(days=1)).isoformat() scenarios.append({ "name": "Unbond After Lock Period", "description": "Test unbonding after lock period ends (should succeed)", @@ -326,9 +326,9 @@ def generate_unbonding_scenarios() -> List[Dict[str, Any]]: generate_staker_address(), lock_period_category="medium" ) - stake["end_time"] = (datetime.now(UTC) - timedelta(days=1)).isoformat() + stake["end_time"] = (timezone.utcnow() - timedelta(days=1)).isoformat() stake["status"] = "UNBONDING" - stake["unbonding_time"] = (datetime.now(UTC) - timedelta(days=10)).isoformat() + stake["unbonding_time"] = (timezone.utcnow() - timedelta(days=10)).isoformat() scenarios.append({ "name": "Complete Unbonding With Penalty", "description": "Test completing unbonding within 30 days (10% penalty)", @@ -344,9 +344,9 @@ def generate_unbonding_scenarios() -> List[Dict[str, Any]]: generate_staker_address(), lock_period_category="medium" ) - stake["end_time"] = (datetime.now(UTC) - timedelta(days=1)).isoformat() + stake["end_time"] = (timezone.utcnow() - timedelta(days=1)).isoformat() stake["status"] = "UNBONDING" - stake["unbonding_time"] = (datetime.now(UTC) - timedelta(days=35)).isoformat() + stake["unbonding_time"] = (timezone.utcnow() - timedelta(days=35)).isoformat() scenarios.append({ "name": "Complete Unbonding No Penalty", "description": "Test completing unbonding after 30 days (no penalty)", diff --git a/scripts/testing/qa-cycle.py b/scripts/testing/qa-cycle.py index 8651efa3..262f22a4 100755 --- a/scripts/testing/qa-cycle.py +++ b/scripts/testing/qa-cycle.py @@ -33,7 +33,7 @@ API_BASE = os.getenv('GITEA_API_BASE', 'http://gitea.bubuit.net:3000/api/v1') REPO = 'oib/aitbc' def log(msg): - now = datetime.now(datetime.UTC).isoformat() + 'Z' + now = datetime.now(timezone.utc).isoformat() + 'Z' with open(LOG_FILE, 'a') as f: f.write(f"[{now}] {msg}\n") print(msg) @@ -139,7 +139,7 @@ def synthesize_status(): log(f"PR #{num} has failing checks: {', '.join(s.get('context','?') for s in failing)}") def main(): - now = datetime.now(datetime.UTC).isoformat() + 'Z' + now = datetime.now(timezone.utc).isoformat() + 'Z' log(f"\n=== QA Cycle start: {now} ===") if not GITEA_TOKEN: log("GITEA_TOKEN not set; aborting.")