-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_setup.py
More file actions
136 lines (109 loc) Β· 3.68 KB
/
test_setup.py
File metadata and controls
136 lines (109 loc) Β· 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env python3
"""
Test script to verify the Relay listener setup
"""
import sys
import os
def test_imports():
"""Test if all required modules can be imported"""
print("π Testing imports...")
try:
import yaml
print("β
PyYAML imported successfully")
except ImportError as e:
print(f"β PyYAML import failed: {e}")
return False
try:
import web3
print("β
Web3.py imported successfully")
except ImportError as e:
print(f"β Web3.py import failed: {e}")
return False
try:
from dotenv import load_dotenv
print("β
python-dotenv imported successfully")
except ImportError as e:
print(f"β python-dotenv import failed: {e}")
return False
try:
from config.config_loader import get_config
print("β
Config loader imported successfully")
except ImportError as e:
print(f"β Config loader import failed: {e}")
return False
return True
def test_config_loading():
"""Test if configuration can be loaded"""
print("\nπ Testing configuration loading...")
try:
from config.config_loader import get_config
config = get_config()
print("β
Configuration loaded successfully")
# Test some config methods
api_key = config.get_alchemy_api_key()
if api_key:
print(f"β
Alchemy API key found: {api_key[:10]}...")
else:
print("β οΈ No Alchemy API key found (expected if .env not set)")
addresses = config.get_all_shapeshift_addresses()
print(f"β
Found {len(addresses)} ShapeShift affiliate addresses")
chains = config.get_supported_chains()
print(f"β
Supported chains: {', '.join(chains)}")
return True
except Exception as e:
print(f"β Configuration loading failed: {e}")
return False
def test_directory_structure():
"""Test if required directories exist"""
print("\nπ Testing directory structure...")
required_dirs = ["config", "data"]
required_files = [
"config/config.yaml",
"config/config.example.yaml",
"config/config_loader.py",
"relay_listener.py",
"requirements.txt",
"README.md"
]
for directory in required_dirs:
if os.path.exists(directory):
print(f"β
Directory exists: {directory}")
else:
print(f"β Directory missing: {directory}")
return False
for file_path in required_files:
if os.path.exists(file_path):
print(f"β
File exists: {file_path}")
else:
print(f"β File missing: {file_path}")
return False
return True
def main():
"""Run all tests"""
print("π Relay Affiliate Fee Listener - Setup Test")
print("=" * 50)
tests = [
test_imports,
test_config_loading,
test_directory_structure
]
passed = 0
total = len(tests)
for test in tests:
if test():
passed += 1
print()
print("=" * 50)
print(f"π Test Results: {passed}/{total} tests passed")
if passed == total:
print("π All tests passed! Setup is complete.")
print("\nNext steps:")
print("1. Copy env.example to .env and add your API keys")
print("2. Run: python relay_listener.py --help")
print("3. Start monitoring: python relay_listener.py")
else:
print("β Some tests failed. Please check the errors above.")
return 1
return 0
if __name__ == "__main__":
sys.exit(main())