Skip to content

Commit fa62188

Browse files
authored
remove provider validation (#67)
- we use rpc-inventory to guarantee consistency across naming - this introduced friction when managing providers and building OneClick / crib automation around this app
1 parent 07a353f commit fa62188

File tree

4 files changed

+8
-30
lines changed

4 files changed

+8
-30
lines changed

config/exporter_example/validation.yml

-5
This file was deleted.

src/configuration.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ def __init__(self):
1515
self._logger_metadata = {'component': 'Config'}
1616
self.configuration_file_path = os.getenv('CONFIG_FILE_PATH',
1717
default='/config/config.yml')
18-
self.validation_file_path = os.getenv('VALIDATION_FILE_PATH',
19-
default='/config/validation.yml')
2018
self._configuration = self._load_configuration()
2119

2220
def get_property(self, property_name):
@@ -45,7 +43,6 @@ def endpoints(self):
4543
return self.get_property('endpoints')
4644

4745
def _load_configuration(self):
48-
allowed_providers = self._load_validation_file()
4946
supported_collectors = ('evm', 'evmhttp', 'cardano', 'conflux', 'solana',
5047
'bitcoin', 'doge', 'filecoin', 'starknet', 'aptos',
5148
'tron')
@@ -77,19 +74,12 @@ def _load_configuration(self):
7774
'url':
7875
And(str, Regex('https://.*|wss://.*|ws://.*')),
7976
'provider':
80-
And(str, lambda s: s in allowed_providers)
77+
And(str)
8178
}]
8279
})
8380
return self._load_and_validate(self.configuration_file_path,
8481
configuration_schema)
8582

86-
def _load_validation_file(self):
87-
88-
validation_schema = Schema({'allowed_providers': [And(str)]})
89-
return self._load_and_validate(
90-
self.validation_file_path,
91-
validation_schema).get('allowed_providers')
92-
9383
def _load_and_validate(self, path: str, schema: Schema) -> dict:
9484
"""Loads file from path as yaml and validates against provided schema."""
9585
try:

src/test_configuration.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@
1010
CONFIG_FILES = {"valid": "tests/fixtures/configuration.yaml",
1111
"invalid": "tests/fixtures/configuration_invalid.yaml",
1212
"client_params": "tests/fixtures/configuration_conn_params.yaml"}
13-
VALIDATION_FILES = {"valid": "tests/fixtures/validation.yaml"}
1413

15-
16-
def setup_config_object(config_file, validation_file) -> Config:
17-
"""Creates a Config object using the provided config and validation files"""
14+
def setup_config_object(config_file) -> Config:
15+
"""Creates a Config object using the provided config files"""
1816
with mock.patch.dict(
1917
os.environ, {
2018
"CONFIG_FILE_PATH": config_file,
21-
"VALIDATION_FILE_PATH": validation_file
2219
}):
2320
return Config()
2421

@@ -30,9 +27,9 @@ def setUp(self):
3027
"""Set up dummy configs for us."""
3128
self.maxDiff = None
3229
self.config = setup_config_object(
33-
CONFIG_FILES["valid"], VALIDATION_FILES["valid"])
30+
CONFIG_FILES["valid"])
3431
self.client_params_config = setup_config_object(
35-
CONFIG_FILES["client_params"], VALIDATION_FILES["valid"])
32+
CONFIG_FILES["client_params"])
3633

3734
def test_invalid_get_property(self):
3835
"""Tests getting invalid properties returns None type"""
@@ -113,15 +110,15 @@ def test_load_and_validate_schema_exception_exit(self):
113110
"""Tests that the program exits when loading a configuration file with a schema exception"""
114111
with self.assertRaises(SystemExit) as cm:
115112
setup_config_object(
116-
CONFIG_FILES["invalid"], VALIDATION_FILES["valid"])
113+
CONFIG_FILES["invalid"])
117114
self.assertEqual(1, cm.exception.code)
118115

119116
def test_load_and_validate_schema_exception_error_log(self):
120117
"""Tests that an error is logged when loading a config file with a schema exception"""
121118
try:
122119
with capture_logs() as captured:
123120
setup_config_object(
124-
CONFIG_FILES["invalid"], VALIDATION_FILES["valid"])
121+
CONFIG_FILES["invalid"])
125122
except SystemExit:
126123
# Catch and pass on expected SystemExit so tests keep running
127124
pass
@@ -132,7 +129,7 @@ def test_load_and_validate_no_error_log(self):
132129
try:
133130
with capture_logs() as captured:
134131
setup_config_object(
135-
CONFIG_FILES["valid"], VALIDATION_FILES["valid"])
132+
CONFIG_FILES["valid"])
136133
except SystemExit:
137134
# Catch and pass on expected SystemExit so tests keep running
138135
pass

src/tests/fixtures/validation.yaml

-4
This file was deleted.

0 commit comments

Comments
 (0)