fix: replace bare except with except Exception in tests/dev/plugins
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Successful in 19s
Deploy to Testnet / deploy-testnet (push) Successful in 1m10s
Multi-Node Stress Testing / stress-test (push) Successful in 2s
Node Failover Simulation / failover-test (push) Successful in 1s
Python Tests / test-python (push) Failing after 7s
Deploy to Testnet / notify-deployment (push) Successful in 1s
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Successful in 19s
Deploy to Testnet / deploy-testnet (push) Successful in 1m10s
Multi-Node Stress Testing / stress-test (push) Successful in 2s
Node Failover Simulation / failover-test (push) Successful in 1s
Python Tests / test-python (push) Failing after 7s
Deploy to Testnet / notify-deployment (push) Successful in 1s
- Fixed bare except clauses in dev/examples/wallet.py - Fixed bare except clauses in dev/gpu/gpu_exchange_status.py (2 clauses) - Fixed bare except clauses in dev/gpu/gpu_miner_host.py - Fixed bare except clauses in dev/onboarding/auto-onboard.py - Fixed bare except clauses in dev/onboarding/onboarding-monitor.py - Fixed bare except clauses in dev/scripts/dev_heartbeat.py - Fixed bare except clauses in tests/integration/test_blockchain_simple.py (3 clauses) - Fixed bare except clause in tests/integration/test_full_workflow.py - Fixed bare except clause in tests/load_test.py - Fixed bare except clause in tests/security/test_confidential_transactions.py - Fixed bare except clause in tests/verification/test_coordinator.py - All bare except clauses now use proper Exception handling - Addresses remaining ruff E722 warnings in non-critical code
This commit is contained in:
@@ -23,7 +23,7 @@ class AITBCWallet:
|
|||||||
try:
|
try:
|
||||||
with open(self.wallet_file, 'r') as f:
|
with open(self.wallet_file, 'r') as f:
|
||||||
return json.load(f)
|
return json.load(f)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Create new wallet
|
# Create new wallet
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ try:
|
|||||||
print(" 🌐 URL: http://localhost:3002")
|
print(" 🌐 URL: http://localhost:3002")
|
||||||
else:
|
else:
|
||||||
print(" ❌ Trade Exchange not responding")
|
print(" ❌ Trade Exchange not responding")
|
||||||
except:
|
except Exception:
|
||||||
print(" ❌ Trade Exchange not accessible")
|
print(" ❌ Trade Exchange not accessible")
|
||||||
|
|
||||||
# Check Blockchain
|
# Check Blockchain
|
||||||
@@ -57,7 +57,7 @@ try:
|
|||||||
print(f" Block Hash: {data.get('hash', 'Unknown')[:16]}...")
|
print(f" Block Hash: {data.get('hash', 'Unknown')[:16]}...")
|
||||||
else:
|
else:
|
||||||
print(" ❌ Blockchain Node not responding")
|
print(" ❌ Blockchain Node not responding")
|
||||||
except:
|
except Exception:
|
||||||
print(" ❌ Blockchain Node not accessible")
|
print(" ❌ Blockchain Node not accessible")
|
||||||
|
|
||||||
# Show Integration Points
|
# Show Integration Points
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ def wait_for_coordinator():
|
|||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
logger.info("Coordinator is available!")
|
logger.info("Coordinator is available!")
|
||||||
return True
|
return True
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
logger.info(f"Waiting for coordinator... ({i+1}/{MAX_RETRIES})")
|
logger.info(f"Waiting for coordinator... ({i+1}/{MAX_RETRIES})")
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ class AgentOnboarder:
|
|||||||
latency = (datetime.now(datetime.UTC) - start_time).total_seconds()
|
latency = (datetime.now(datetime.UTC) - start_time).total_seconds()
|
||||||
capabilities['network_latency'] = latency
|
capabilities['network_latency'] = latency
|
||||||
logger.info(f"✅ Network latency: {latency:.2f}s")
|
logger.info(f"✅ Network latency: {latency:.2f}s")
|
||||||
except:
|
except Exception:
|
||||||
capabilities['network_latency'] = None
|
capabilities['network_latency'] = None
|
||||||
logger.warning("⚠️ Could not measure network latency")
|
logger.warning("⚠️ Could not measure network latency")
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ class OnboardingMonitor:
|
|||||||
}
|
}
|
||||||
|
|
||||||
return type_mapping.get(compute_type, 'unknown')
|
return type_mapping.get(compute_type, 'unknown')
|
||||||
except:
|
except Exception:
|
||||||
return 'unknown'
|
return 'unknown'
|
||||||
|
|
||||||
def calculate_metrics(self):
|
def calculate_metrics(self):
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ def check_vulnerabilities():
|
|||||||
count = audit.get("metadata", {}).get("vulnerabilities", {}).get("total", 0)
|
count = audit.get("metadata", {}).get("vulnerabilities", {}).get("total", 0)
|
||||||
if count > 0:
|
if count > 0:
|
||||||
issues.append(f"Node dependencies: {count} vulnerabilities (npm audit)")
|
issues.append(f"Node dependencies: {count} vulnerabilities (npm audit)")
|
||||||
except:
|
except Exception:
|
||||||
issues.append("Node dependencies: npm audit failed to parse")
|
issues.append("Node dependencies: npm audit failed to parse")
|
||||||
return issues
|
return issues
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class ExamplePlugin(BasePlugin):
|
|||||||
try:
|
try:
|
||||||
process = psutil.Process(os.getpid())
|
process = psutil.Process(os.getpid())
|
||||||
self._memory_usage = process.memory_info().rss
|
self._memory_usage = process.memory_info().rss
|
||||||
except:
|
except Exception:
|
||||||
self._memory_usage = 0
|
self._memory_usage = 0
|
||||||
|
|
||||||
uptime = None
|
uptime = None
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ def test_nodes():
|
|||||||
response = httpx.get(f"{node['url']}/openapi.json", timeout=5)
|
response = httpx.get(f"{node['url']}/openapi.json", timeout=5)
|
||||||
api_ok = response.status_code == 200
|
api_ok = response.status_code == 200
|
||||||
print(f" RPC API: {'✅' if api_ok else '❌'}")
|
print(f" RPC API: {'✅' if api_ok else '❌'}")
|
||||||
except:
|
except Exception:
|
||||||
api_ok = False
|
api_ok = False
|
||||||
print(f" RPC API: ❌")
|
print(f" RPC API: ❌")
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ def test_nodes():
|
|||||||
)
|
)
|
||||||
faucet_ok = response.status_code == 200
|
faucet_ok = response.status_code == 200
|
||||||
print(f" Faucet: {'✅' if faucet_ok else '❌'}")
|
print(f" Faucet: {'✅' if faucet_ok else '❌'}")
|
||||||
except:
|
except Exception:
|
||||||
faucet_ok = False
|
faucet_ok = False
|
||||||
print(f" Faucet: ❌")
|
print(f" Faucet: ❌")
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ def test_nodes():
|
|||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
print(f" Chain Head: ❌")
|
print(f" Chain Head: ❌")
|
||||||
except:
|
except Exception:
|
||||||
print(f" Chain Head: ❌")
|
print(f" Chain Head: ❌")
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ def test_node_basic_functionality():
|
|||||||
try:
|
try:
|
||||||
response = httpx.get(f"{url}/openapi.json", timeout=5)
|
response = httpx.get(f"{url}/openapi.json", timeout=5)
|
||||||
print(f" ✅ Node responsive")
|
print(f" ✅ Node responsive")
|
||||||
except:
|
except Exception:
|
||||||
print(f" ❌ Node not responding")
|
print(f" ❌ Node not responding")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ def test_node_basic_functionality():
|
|||||||
print(f" ✅ Chain height: {head.get('height', 'unknown')}")
|
print(f" ✅ Chain height: {head.get('height', 'unknown')}")
|
||||||
else:
|
else:
|
||||||
print(f" ❌ Failed to get chain head")
|
print(f" ❌ Failed to get chain head")
|
||||||
except:
|
except Exception:
|
||||||
print(f" ❌ Error getting chain head")
|
print(f" ❌ Error getting chain head")
|
||||||
|
|
||||||
# Test faucet
|
# Test faucet
|
||||||
@@ -52,7 +52,7 @@ def test_node_basic_functionality():
|
|||||||
print(f" ✅ Faucet working")
|
print(f" ✅ Faucet working")
|
||||||
else:
|
else:
|
||||||
print(f" ❌ Faucet failed: {response.status_code}")
|
print(f" ❌ Faucet failed: {response.status_code}")
|
||||||
except:
|
except Exception:
|
||||||
print(f" ❌ Error testing faucet")
|
print(f" ❌ Error testing faucet")
|
||||||
|
|
||||||
def show_networking_config():
|
def show_networking_config():
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ class TestMarketplaceIntegration:
|
|||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
services = response.json()
|
services = response.json()
|
||||||
assert isinstance(services, list)
|
assert isinstance(services, list)
|
||||||
except:
|
except Exception:
|
||||||
# API endpoint might not be available, that's OK
|
# API endpoint might not be available, that's OK
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,6 @@ class AITBCUser(HttpUser):
|
|||||||
"payload": "0x",
|
"payload": "0x",
|
||||||
"chain_id": "ait-mainnet"
|
"chain_id": "ait-mainnet"
|
||||||
})
|
})
|
||||||
except:
|
except Exception:
|
||||||
# Expected to fail due to invalid signature, but tests endpoint availability
|
# Expected to fail due to invalid signature, but tests endpoint availability
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ class TestConfidentialTransactionSecurity:
|
|||||||
x25519.X25519PrivateKey.generate(),
|
x25519.X25519PrivateKey.generate(),
|
||||||
x25519.X25519PrivateKey.generate().public_key(),
|
x25519.X25519PrivateKey.generate().public_key(),
|
||||||
)
|
)
|
||||||
except:
|
except Exception:
|
||||||
pass # Expected to fail with wrong keys
|
pass # Expected to fail with wrong keys
|
||||||
end = time.perf_counter()
|
end = time.perf_counter()
|
||||||
times.append(end - start)
|
times.append(end - start)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ for endpoint in endpoints:
|
|||||||
try:
|
try:
|
||||||
data = response.json()
|
data = response.json()
|
||||||
print(f" Response: {json.dumps(data, indent=2)[:200]}...")
|
print(f" Response: {json.dumps(data, indent=2)[:200]}...")
|
||||||
except:
|
except Exception:
|
||||||
print(f" Response: {response.text[:100]}...")
|
print(f" Response: {response.text[:100]}...")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"{endpoint}: Error - {e}")
|
print(f"{endpoint}: Error - {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user