diff --git a/tests/archived_phase_tests/phase3/test_decision_framework.py b/tests/archived_phase_tests/phase3/test_decision_framework.py index 00c76da0..a7bb0923 100644 --- a/tests/archived_phase_tests/phase3/test_decision_framework.py +++ b/tests/archived_phase_tests/phase3/test_decision_framework.py @@ -23,7 +23,7 @@ class MockDecisionEngine: 'decision_id': decision_id, 'status': 'completed', 'result': decision_data.get('proposal', 'approved'), - 'timestamp': datetime.now(UTC).isoformat() + 'timestamp': datetime.now(timezone.utc).isoformat() } async def submit_vote(self, vote_data: Dict[str, Any]) -> Dict[str, Any]: @@ -32,7 +32,7 @@ class MockDecisionEngine: return { 'vote_id': vote_id, 'status': 'recorded', - 'timestamp': datetime.now(UTC).isoformat() + 'timestamp': datetime.now(timezone.utc).isoformat() } class MockConsensusAlgorithm: @@ -50,7 +50,7 @@ class MockConsensusAlgorithm: 'consensus_id': consensus_id, 'status': 'consensus_reached', 'agreement': True, - 'timestamp': datetime.now(UTC).isoformat() + 'timestamp': datetime.now(timezone.utc).isoformat() } class TestDecisionEngine: @@ -102,7 +102,7 @@ class TestDecisionEngine: 'amounts': {'cpu': 50, 'memory': 2048, 'storage': 100} }, 'participants': ['agent_001', 'agent_002', 'agent_003'], - 'deadline': (datetime.now(UTC) + timedelta(hours=1)).isoformat() + 'deadline': (datetime.now(timezone.utc) + timedelta(hours=1)).isoformat() } result = await self.decision_engine.make_decision(decision_data) @@ -157,7 +157,7 @@ class TestConsensusAlgorithm: {'rule': 'priority_based', 'weight': 0.6}, {'rule': 'fair_share', 'weight': 0.4} ], - 'effective_date': datetime.now(UTC).isoformat() + 'effective_date': datetime.now(timezone.utc).isoformat() } } @@ -260,7 +260,7 @@ class TestAgentLifecycleManagement: 'agent_id': 'agent_001', 'capabilities': ['decision_making', 'voting'], 'status': 'active', - 'join_time': datetime.now(UTC).isoformat() + 'join_time': datetime.now(timezone.utc).isoformat() } self.agents[agent_data['agent_id']] = agent_data @@ -276,12 +276,12 @@ class TestAgentLifecycleManagement: self.agents[agent_id] = { 'agent_id': agent_id, 'status': 'active', - 'last_update': datetime.now(UTC).isoformat() + 'last_update': datetime.now(timezone.utc).isoformat() } # Update agent status self.agents[agent_id]['status'] = 'busy' - self.agents[agent_id]['last_update'] = datetime.now(UTC).isoformat() + self.agents[agent_id]['last_update'] = datetime.now(timezone.utc).isoformat() assert self.agents[agent_id]['status'] == 'busy' assert 'last_update' in self.agents[agent_id] diff --git a/tests/archived_phase_tests/phase4/test_autonomous_decision_making.py b/tests/archived_phase_tests/phase4/test_autonomous_decision_making.py index 7d775051..2e1393f1 100644 --- a/tests/archived_phase_tests/phase4/test_autonomous_decision_making.py +++ b/tests/archived_phase_tests/phase4/test_autonomous_decision_making.py @@ -27,7 +27,7 @@ class MockAutonomousEngine: 'action': self._determine_action(context), 'reasoning': self._generate_reasoning(context), 'confidence': self._calculate_confidence(context), - 'timestamp': datetime.now(UTC).isoformat() + 'timestamp': datetime.now(timezone.utc).isoformat() } self.decisions.append(decision) return decision @@ -67,7 +67,7 @@ class MockLearningSystem: 'experience': experience, 'lessons_learned': self._extract_lessons(experience), 'performance_impact': self._calculate_impact(experience), - 'timestamp': datetime.now(UTC).isoformat() + 'timestamp': datetime.now(timezone.utc).isoformat() } self.experience_buffer.append(learning_data) return learning_data @@ -93,7 +93,7 @@ class MockLearningSystem: 'type': adaptation_data.get('type', 'parameter_adjustment'), 'changes': adaptation_data.get('changes', {}), 'expected_improvement': adaptation_data.get('expected_improvement', 0.1), - 'timestamp': datetime.now(UTC).isoformat() + 'timestamp': datetime.now(timezone.utc).isoformat() } self.adaptations[adaptation_id] = adaptation return adaptation @@ -128,7 +128,7 @@ class MockPolicyEngine: 'compliance_score': compliance_score, 'violations': violations, 'approved': compliance_score >= 0.8 and len(violations) == 0, - 'timestamp': datetime.now(UTC).isoformat() + 'timestamp': datetime.now(timezone.utc).isoformat() } def _calculate_compliance(self, decision: Dict[str, Any]) -> float: diff --git a/tests/archived_phase_tests/phase5/test_vision_integration.py b/tests/archived_phase_tests/phase5/test_vision_integration.py index 794c2c38..0f993807 100644 --- a/tests/archived_phase_tests/phase5/test_vision_integration.py +++ b/tests/archived_phase_tests/phase5/test_vision_integration.py @@ -26,7 +26,7 @@ class MockVisionProcessor: 'processing_type': processing_type, 'size': len(image_data), 'format': 'processed', - 'timestamp': datetime.now(UTC).isoformat(), + 'timestamp': datetime.now(timezone.utc).isoformat(), 'analysis': await self._analyze_image(image_data, processing_type) } self.processed_images[image_id] = result @@ -130,7 +130,7 @@ class MockMultiModalAgent: 'result_id': result_id, 'modalities_processed': list(results.keys()), 'integration': await self._integrate_modalities(results), - 'timestamp': datetime.now(UTC).isoformat() + 'timestamp': datetime.now(timezone.utc).isoformat() } self.integrated_results[result_id] = integrated_result @@ -151,7 +151,7 @@ class MockMultiModalAgent: return { 'sensor_type': sensor_data.get('type', 'unknown'), 'readings': sensor_data.get('readings', {}), - 'timestamp': sensor_data.get('timestamp', datetime.now(UTC).isoformat()), + 'timestamp': sensor_data.get('timestamp', datetime.now(timezone.utc).isoformat()), 'quality': 'good' } @@ -186,7 +186,7 @@ class MockContextIntegration: 'vision_result': vision_result, 'context_data': context_data, 'enhanced_understanding': await self._enhance_understanding(vision_result, context_data), - 'timestamp': datetime.now(UTC).isoformat() + 'timestamp': datetime.now(timezone.utc).isoformat() } self.context_history.append(integration) @@ -298,7 +298,7 @@ class TestMultiModalIntegration: self.sample_sensor_data = { 'type': 'temperature', 'readings': {'value': 25.5, 'unit': 'celsius'}, - 'timestamp': datetime.now(UTC).isoformat() + 'timestamp': datetime.now(timezone.utc).isoformat() } @pytest.mark.asyncio @@ -431,7 +431,7 @@ class TestContextIntegration: vision_result = await self.vision_processor.process_image(self.sample_image) context_data = { 'location': f'location_{i}', - 'timestamp': datetime.now(UTC).isoformat() + 'timestamp': datetime.now(timezone.utc).isoformat() } await self.context_integration.integrate_context(vision_result, context_data) @@ -530,11 +530,11 @@ class TestPerformanceMetrics: @pytest.mark.asyncio async def test_processing_speed(self): """Test image processing speed""" - start_time = datetime.now(UTC) + start_time = datetime.now(timezone.utc) result = await self.vision_processor.process_image(self.sample_image) - end_time = datetime.now(UTC) + end_time = datetime.now(timezone.utc) processing_time = (end_time - start_time).total_seconds() assert processing_time < 2.0 # Should process within 2 seconds @@ -545,12 +545,12 @@ class TestPerformanceMetrics: """Test batch image processing""" images = [self.sample_image] * 5 - start_time = datetime.now(UTC) + start_time = datetime.now(timezone.utc) results = [] for image in images: result = await self.vision_processor.process_image(image) results.append(result) - end_time = datetime.now(UTC) + end_time = datetime.now(timezone.utc) total_time = (end_time - start_time).total_seconds() avg_time = total_time / len(images) @@ -625,9 +625,9 @@ class TestVisionIntegration: # Simulate real-time processing processing_times = [] for i in range(10): - start_time = datetime.now(UTC) + start_time = datetime.now(timezone.utc) await vision_processor.process_image(f'frame_{i}'.encode()) - end_time = datetime.now(UTC) + end_time = datetime.now(timezone.utc) processing_times.append((end_time - start_time).total_seconds()) avg_time = sum(processing_times) / len(processing_times) diff --git a/tests/verification/test_block_import.py b/tests/verification/test_block_import.py index a4ae8285..db800c95 100644 --- a/tests/verification/test_block_import.py +++ b/tests/verification/test_block_import.py @@ -30,7 +30,7 @@ def test_block_import(): print(f"Current head: height={head['height']}, hash={head['hash']}") # Use very high heights to avoid conflicts with existing chain - base_height = 1000000 + base_height = head["height"] + 10000000 # Test 1: Import a valid block at high height print("\n1. Testing valid block import...") diff --git a/tests/verification/test_block_import_complete.py b/tests/verification/test_block_import_complete.py index 834d10c2..d9b0e1f8 100644 --- a/tests/verification/test_block_import_complete.py +++ b/tests/verification/test_block_import_complete.py @@ -6,7 +6,8 @@ Tests all functionality including validation, conflicts, and transaction import import json import hashlib -from datetime import datetime +import requests +from datetime import datetime, timezone from aitbc import AITBCHTTPClient BASE_URL = "https://aitbc.bubuit.net/rpc" @@ -27,6 +28,11 @@ def test_block_import_complete(): results = [] client = AITBCHTTPClient() + # Get current head to use for dynamic height calculation + response = requests.get(f"{BASE_URL}/head") + head = response.json() + base_height = head["height"] + 10000000 + # Test 1: Invalid height (0) print("\n[TEST 1] Invalid height (0)...") response = client.post( @@ -53,7 +59,7 @@ def test_block_import_complete(): response = requests.post( f"{BASE_URL}/importBlock", json={ - "height": 1, + "height": base_height, "hash": "0xinvalidhash", "parent_hash": "0x00", "proposer": "test", @@ -101,7 +107,7 @@ def test_block_import_complete(): response = requests.post( f"{BASE_URL}/importBlock", json={ - "height": 999999, + "height": base_height + 1, "hash": "0xinvalid", "parent_hash": head["hash"], "proposer": "test", @@ -122,8 +128,8 @@ def test_block_import_complete(): response = requests.post( f"{BASE_URL}/importBlock", json={ - "height": 999998, - "hash": compute_block_hash(999998, "0xnonexistent", "2026-01-29T10:20:00"), + "height": base_height + 2, + "hash": compute_block_hash(base_height + 2, "0xnonexistent", "2026-01-29T10:20:00"), "parent_hash": "0xnonexistent", "proposer": "test", "timestamp": "2026-01-29T10:20:00", @@ -143,7 +149,7 @@ def test_block_import_complete(): response = requests.get(f"{BASE_URL}/head") head = response.json() - height = head["height"] + 1 + height = base_height + 10 block_hash = compute_block_hash(height, head["hash"], "2026-01-29T10:20:00") response = requests.post( @@ -171,7 +177,7 @@ def test_block_import_complete(): print("⚠️ KNOWN ISSUE: Transaction import currently fails with database constraint error") print(" This appears to be a bug in the transaction field mapping") - height = height + 1 + height = base_height + 11 block_hash = compute_block_hash(height, head["hash"], "2026-01-29T10:20:00") response = requests.post( diff --git a/tests/verification/test_cross_node_blockchain.py b/tests/verification/test_cross_node_blockchain.py index fec93baf..71e85e45 100644 --- a/tests/verification/test_cross_node_blockchain.py +++ b/tests/verification/test_cross_node_blockchain.py @@ -73,9 +73,10 @@ def test_cross_node_chain_id_consistency(): else: # Check remote .env file via SSH result = subprocess.run( - ["ssh", node_key, "cat /etc/aitbc/.env | grep CHAIN_ID"], + ["ssh", "-o", "StrictHostKeyChecking=no", "-o", "BatchMode=yes", node_key, "cat /etc/aitbc/.env | grep CHAIN_ID"], capture_output=True, - text=True + text=True, + timeout=10 ) if result.returncode == 0: chain_id = result.stdout.strip().split("=")[1] @@ -116,7 +117,7 @@ def test_cross_node_block_sync(): aitbc_head = heads["aitbc"] height = aitbc_head["height"] + 10000000 # Use very high height to avoid conflicts parent_hash = aitbc_head["hash"] - timestamp = datetime.now(UTC).isoformat() + "Z" + timestamp = datetime.now(timezone.utc).isoformat() + "Z" valid_hash = compute_block_hash(height, parent_hash, timestamp) client = AITBCHTTPClient(timeout=10)