Add Binance Testnet exchange gateway
This commit is contained in:
@@ -75,3 +75,66 @@ def test_rejects_missing_prompts_file(tmp_path: Path):
|
||||
path.write_text(CONFIG, encoding="utf-8")
|
||||
with pytest.raises(ConfigError, match="Prompts file not found"):
|
||||
load_config(path)
|
||||
|
||||
|
||||
def test_legacy_bybit_config_selects_bybit(tmp_path: Path):
|
||||
config = load_config(write_config(tmp_path))
|
||||
assert config.exchange.provider == "bybit"
|
||||
assert config.bybit is not None
|
||||
assert config.binance is None
|
||||
|
||||
|
||||
def test_binance_config_only_requires_binance_credentials(tmp_path: Path):
|
||||
content = CONFIG.replace(
|
||||
'[bybit]\napi_key = "bybit-key"\napi_secret = "bybit-secret"\n',
|
||||
'''[exchange]
|
||||
provider = "binance"
|
||||
[binance.spot]
|
||||
api_key = "spot-key"
|
||||
api_secret = "spot-secret"
|
||||
[binance.usdm]
|
||||
api_key = "usdm-key"
|
||||
api_secret = "usdm-secret"
|
||||
''',
|
||||
)
|
||||
config = load_config(write_config(tmp_path, content))
|
||||
assert config.exchange.provider == "binance"
|
||||
assert config.bybit is None
|
||||
assert config.binance is not None
|
||||
assert config.binance.spot.api_key == "spot-key"
|
||||
|
||||
|
||||
def test_binance_rejects_endpoint_override(tmp_path: Path):
|
||||
content = CONFIG.replace(
|
||||
'[bybit]\napi_key = "bybit-key"\napi_secret = "bybit-secret"\n',
|
||||
'''[exchange]
|
||||
provider = "binance"
|
||||
[binance]
|
||||
base_url = "https://api.binance.com"
|
||||
[binance.spot]
|
||||
api_key = "spot-key"
|
||||
api_secret = "spot-secret"
|
||||
[binance.usdm]
|
||||
api_key = "usdm-key"
|
||||
api_secret = "usdm-secret"
|
||||
''',
|
||||
)
|
||||
with pytest.raises(ConfigError, match="fixed to Testnet"):
|
||||
load_config(write_config(tmp_path, content))
|
||||
|
||||
|
||||
def test_binance_requires_both_selected_wallet_credentials(tmp_path: Path):
|
||||
content = CONFIG.replace(
|
||||
'[bybit]\napi_key = "bybit-key"\napi_secret = "bybit-secret"\n',
|
||||
'''[exchange]
|
||||
provider = "binance"
|
||||
[binance.spot]
|
||||
api_key = "spot-key"
|
||||
api_secret = "spot-secret"
|
||||
[binance.usdm]
|
||||
api_key = "replace-me"
|
||||
api_secret = "replace-me"
|
||||
''',
|
||||
)
|
||||
with pytest.raises(ConfigError, match="placeholder"):
|
||||
load_config(write_config(tmp_path, content))
|
||||
|
||||
Reference in New Issue
Block a user