fix: replace datetime.UTC with timezone.utc for Python 3.12+ compatibility
Some checks failed
API Endpoint Tests / test-api-endpoints (push) Successful in 22s
Blockchain Synchronization Verification / sync-verification (push) Successful in 3s
CLI Tests / test-cli (push) Failing after 13s
Cross-Chain Functionality Tests / test-cross-chain-sync (push) Failing after 3s
Cross-Chain Functionality Tests / test-cross-chain-transactions (push) Successful in 3s
Cross-Chain Functionality Tests / test-cross-chain-bridge (push) Has been skipped
Cross-Chain Functionality Tests / test-multi-chain-consensus (push) Failing after 3s
Cross-Chain Functionality Tests / aggregate-results (push) Has been skipped
Cross-Node Transaction Testing / transaction-test (push) Successful in 2s
Deploy to Testnet / deploy-testnet (push) Successful in 1m34s
Documentation Validation / validate-docs (push) Failing after 10s
Documentation Validation / validate-policies-strict (push) Successful in 3s
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Node Failover Simulation / failover-test (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
Integration Tests / test-service-integration (push) Successful in 2m42s
Multi-Chain Island Architecture Tests / test-multi-chain-island (push) Successful in 3s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 5s
P2P Network Verification / p2p-verification (push) Successful in 3s
Package Tests / Python package - aitbc-agent-sdk (push) Failing after 33s
Package Tests / Python package - aitbc-core (push) Successful in 17s
Package Tests / Python package - aitbc-crypto (push) Successful in 11s
Security Scanning / security-scan (push) Has been cancelled
Package Tests / Python package - aitbc-sdk (push) Successful in 13s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 9s
Package Tests / JavaScript package - aitbc-token (push) Successful in 17s
Staking Tests / test-staking-service (push) Failing after 6s
Staking Tests / test-staking-integration (push) Has been skipped
Staking Tests / test-staking-contract (push) Has been skipped
Staking Tests / run-staking-test-runner (push) Has been skipped

This commit is contained in:
aitbc
2026-05-09 12:03:26 +02:00
parent 14449b0758
commit d26e6d3772
152 changed files with 848 additions and 848 deletions

View File

@@ -3,7 +3,7 @@
FastAPI backend for the AITBC Trade Exchange
"""
from datetime import datetime, UTC, timedelta
from datetime import datetime, timezone, timedelta
from typing import List, Optional
from fastapi import FastAPI, Depends, HTTPException, status, Header
from fastapi.middleware.cors import CORSMiddleware
@@ -123,7 +123,7 @@ def create_mock_trades(db: Session):
import random
# Create mock trades over the last hour
now = datetime.now(datetime.UTC)
now = datetime.now(timezone.utc)
trades = []
for i in range(20):
@@ -278,7 +278,7 @@ def try_match_order(order: Order, db: Session):
amount=trade_amount,
price=match.price,
total=trade_total,
trade_hash=f"trade_{datetime.now(datetime.UTC).timestamp()}"
trade_hash=f"trade_{datetime.now(timezone.utc).timestamp()}"
)
db.add(trade)
@@ -344,7 +344,7 @@ def logout_user(token: str = Header(..., alias="Authorization")):
@app.get("/api/health")
def health_check():
"""Health check endpoint"""
return {"status": "ok", "timestamp": datetime.now(datetime.UTC)}
return {"status": "ok", "timestamp": datetime.now(timezone.utc)}
if __name__ == "__main__":
import uvicorn

View File

@@ -22,7 +22,7 @@ class User(Base):
password_hash = Column(String(255), nullable=False)
bitcoin_address = Column(String(100), unique=True, nullable=False)
aitbc_address = Column(String(100), unique=True, nullable=False)
created_at = Column(DateTime, default=datetime.now(datetime.UTC))
created_at = Column(DateTime, default=datetime.now(timezone.utc))
is_active = Column(Boolean, default=True)
# Relationships
@@ -46,8 +46,8 @@ class Order(Base):
filled = Column(Float, default=0.0) # Amount filled
remaining = Column(Float, nullable=False) # Amount remaining to fill
status = Column(String(20), default='OPEN') # OPEN, PARTIALLY_FILLED, FILLED, CANCELLED
created_at = Column(DateTime, default=datetime.now(datetime.UTC))
updated_at = Column(DateTime, default=datetime.now(datetime.UTC), onupdate=datetime.now(datetime.UTC))
created_at = Column(DateTime, default=datetime.now(timezone.utc))
updated_at = Column(DateTime, default=datetime.now(timezone.utc), onupdate=datetime.now(timezone.utc))
# Relationships
user = relationship("User", back_populates="orders")
@@ -74,7 +74,7 @@ class Trade(Base):
price = Column(Float, nullable=False) # Trade price in BTC
total = Column(Float, nullable=False) # Total value in BTC
trade_hash = Column(String(100), unique=True, nullable=False) # Blockchain transaction hash
created_at = Column(DateTime, default=datetime.now(datetime.UTC))
created_at = Column(DateTime, default=datetime.now(timezone.utc))
# Relationships
buyer = relationship("User", back_populates="trades", foreign_keys=[buyer_id])
@@ -100,7 +100,7 @@ class Balance(Base):
aitbc_balance = Column(Float, default=0.0)
btc_locked = Column(Float, default=0.0) # Locked in open orders
aitbc_locked = Column(Float, default=0.0) # Locked in open orders
updated_at = Column(DateTime, default=datetime.now(datetime.UTC), onupdate=datetime.now(datetime.UTC))
updated_at = Column(DateTime, default=datetime.now(timezone.utc), onupdate=datetime.now(timezone.utc))
# Relationship
user = relationship("User")

View File

@@ -8,7 +8,7 @@ import asyncio
import ccxt
import json
import time
from datetime import datetime, UTC, timedelta
from datetime import datetime, timezone, timedelta
from typing import Dict, List, Optional, Any, Tuple
from dataclasses import dataclass
from enum import Enum
@@ -105,7 +105,7 @@ class RealExchangeManager:
self.health_status[exchange_name] = ExchangeHealth(
status=ExchangeStatus.CONNECTED,
latency_ms=0.0,
last_check=datetime.now(datetime.UTC)
last_check=datetime.now(timezone.utc)
)
logger.info(f"✅ Connected to {exchange_name}")
@@ -116,7 +116,7 @@ class RealExchangeManager:
self.health_status[exchange_name] = ExchangeHealth(
status=ExchangeStatus.ERROR,
latency_ms=0.0,
last_check=datetime.now(datetime.UTC),
last_check=datetime.now(timezone.utc),
error_message=str(e)
)
return False

View File

@@ -2,7 +2,7 @@
"""Seed initial market price for the exchange"""
import sqlite3
from datetime import datetime, UTC
from datetime import datetime, timezone
from aitbc.constants import DATA_DIR
def seed_initial_price():
@@ -27,7 +27,7 @@ def seed_initial_price():
cursor.execute('''
INSERT INTO trades (amount, price, total, created_at)
VALUES (?, ?, ?, ?)
''', (amount, price, total, datetime.now(datetime.UTC)))
''', (amount, price, total, datetime.now(timezone.utc)))
# Also create some initial orders for liquidity
initial_orders = [

View File

@@ -5,7 +5,7 @@ Simple FastAPI backend for the AITBC Trade Exchange (Python 3.13 compatible)
import sqlite3
import json
from datetime import datetime, UTC, timedelta
from datetime import datetime, timezone, timedelta
from http.server import HTTPServer, BaseHTTPRequestHandler
import urllib.parse
import random

View File

@@ -7,7 +7,7 @@ import json
import urllib.request
import psycopg2
from psycopg2.extras import RealDictCursor
from datetime import datetime, UTC
from datetime import datetime, timezone
from decimal import Decimal
import random
@@ -151,7 +151,7 @@ class ExchangeAPIHandler(BaseHTTPRequestHandler):
self.send_json_response({
'status': 'ok',
'database': 'postgresql',
'timestamp': datetime.now(datetime.UTC).isoformat()
'timestamp': datetime.now(timezone.utc).isoformat()
})
except Exception as e:
self.send_json_response({

View File

@@ -7,7 +7,7 @@ from pathlib import Path
from exchange_api import OrderCreate, OrderResponse, TradeResponse, OrderBookResponse
from datetime import datetime, UTC
from datetime import datetime, timezone
@pytest.mark.unit
@@ -55,7 +55,7 @@ def test_order_response_zero_remaining():
filled=100.0,
remaining=0.0,
status="FILLED",
created_at=datetime.now(datetime.UTC)
created_at=datetime.now(timezone.utc)
)
assert order.remaining == 0.0
assert order.status == "FILLED"
@@ -73,7 +73,7 @@ def test_order_response_empty_status():
filled=0.0,
remaining=100.0,
status="",
created_at=datetime.now(datetime.UTC)
created_at=datetime.now(timezone.utc)
)
assert order.status == ""
@@ -86,7 +86,7 @@ def test_trade_response_zero_amount():
amount=0.0,
price=0.00001,
total=0.0,
created_at=datetime.now(datetime.UTC)
created_at=datetime.now(timezone.utc)
)
assert trade.amount == 0.0
assert trade.total == 0.0
@@ -103,7 +103,7 @@ def test_order_book_empty_buys():
@pytest.mark.unit
def test_order_book_empty_sells():
"""Test OrderBookResponse with empty sells"""
from datetime import datetime, UTC
from datetime import datetime, timezone
buy_order = OrderResponse(
id=1,
order_type="BUY",
@@ -113,7 +113,7 @@ def test_order_book_empty_sells():
filled=0.0,
remaining=100.0,
status="OPEN",
created_at=datetime.now(datetime.UTC)
created_at=datetime.now(timezone.utc)
)
orderbook = OrderBookResponse(buys=[buy_order], sells=[])
assert len(orderbook.buys) == 1

View File

@@ -45,7 +45,7 @@ def test_order_create_model_sell():
@pytest.mark.unit
def test_order_response_model():
"""Test OrderResponse model"""
from datetime import datetime, UTC
from datetime import datetime, timezone
order = OrderResponse(
id=1,
order_type="BUY",
@@ -55,7 +55,7 @@ def test_order_response_model():
filled=0.0,
remaining=100.0,
status="OPEN",
created_at=datetime.now(datetime.UTC)
created_at=datetime.now(timezone.utc)
)
assert order.id == 1
assert order.order_type == "BUY"
@@ -66,13 +66,13 @@ def test_order_response_model():
@pytest.mark.unit
def test_trade_response_model():
"""Test TradeResponse model"""
from datetime import datetime, UTC
from datetime import datetime, timezone
trade = TradeResponse(
id=1,
amount=50.0,
price=0.00001,
total=0.0005,
created_at=datetime.now(datetime.UTC)
created_at=datetime.now(timezone.utc)
)
assert trade.id == 1
assert trade.amount == 50.0
@@ -82,7 +82,7 @@ def test_trade_response_model():
@pytest.mark.unit
def test_order_book_response_model():
"""Test OrderBookResponse model"""
from datetime import datetime, UTC
from datetime import datetime, timezone
buy_order = OrderResponse(
id=1,
order_type="BUY",
@@ -92,7 +92,7 @@ def test_order_book_response_model():
filled=0.0,
remaining=100.0,
status="OPEN",
created_at=datetime.now(datetime.UTC)
created_at=datetime.now(timezone.utc)
)
sell_order = OrderResponse(
id=2,
@@ -103,7 +103,7 @@ def test_order_book_response_model():
filled=0.0,
remaining=50.0,
status="OPEN",
created_at=datetime.now(datetime.UTC)
created_at=datetime.now(timezone.utc)
)
orderbook = OrderBookResponse(buys=[buy_order], sells=[sell_order])
assert len(orderbook.buys) == 1