Skip to content

Commit

Permalink
Rename all instances of starkware to starknet (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodgerjohnson authored May 17, 2024
1 parent 96e3238 commit 2a73342
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Exporter currently supports all EVM-compatible chains. In addition, there is lim
- Bitcoin (https)
- Dogecoin (https)
- Filecoin (https)
- Starkware (https)
- Starknet (https)

## Available Metrics

Expand Down
4 changes: 2 additions & 2 deletions src/collectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ def latency(self):
return self.interface.latest_query_latency


class StarkwareCollector():
"""A collector to fetch information about starkware RPC endpoints."""
class StarknetCollector():
"""A collector to fetch information about starknet RPC endpoints."""

def __init__(self, url, labels, chain_id, **client_parameters):

Expand Down
2 changes: 1 addition & 1 deletion src/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def endpoints(self):
def _load_configuration(self):
allowed_providers = self._load_validation_file()
supported_collectors = ('evm', 'cardano', 'conflux', 'solana',
'bitcoin', 'doge', 'filecoin', 'starkware')
'bitcoin', 'doge', 'filecoin', 'starknet')

configuration_schema = Schema({
'blockchain':
Expand Down
4 changes: 2 additions & 2 deletions src/registries.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def get_collector_registry(self) -> list:
collector = collectors.FilecoinCollector
case "solana", "solana":
collector = collectors.SolanaCollector
case "starkware", "starkware":
collector = collectors.StarkwareCollector
case "starknet", "starknet":
collector = collectors.StarknetCollector
case "evm", other: # pylint: disable=unused-variable
collector = collectors.EvmCollector
if collector is None:
Expand Down
20 changes: 10 additions & 10 deletions src/test_collectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,8 @@ def test_latency(self):
self.assertEqual(0.123, self.solana_collector.latency())


class TestStarkwareCollector(TestCase):
"""Tests the starkware collector class"""
class TestStarknetCollector(TestCase):
"""Tests the starknet collector class"""

def setUp(self):
self.url = "wss://test.com"
Expand All @@ -608,45 +608,45 @@ def setUp(self):
"id": 1
}
with mock.patch('collectors.HttpsInterface') as mocked_connection:
self.starkware_collector = collectors.StarkwareCollector(
self.starknet_collector = collectors.StarknetCollector(
self.url, self.labels, self.chain_id, **self.client_params)
self.mocked_connection = mocked_connection

def test_https_interface_created(self):
"""Tests that the starkware collector calls the https interface with the correct args"""
"""Tests that the starknet collector calls the https interface with the correct args"""
self.mocked_connection.assert_called_once_with(
self.url, self.open_timeout, self.ping_timeout)

def test_interface_attribute_exists(self):
"""Tests that the interface attribute exists.
May be used by external calls to access objects such as the interface cache"""
self.assertTrue(hasattr(self.starkware_collector, 'interface'))
self.assertTrue(hasattr(self.starknet_collector, 'interface'))

def test_alive_call(self):
"""Tests the alive function uses the correct call and args"""
self.starkware_collector.alive()
self.starknet_collector.alive()
self.mocked_connection.return_value.cached_json_rpc_post.assert_called_once_with(
self.block_height_payload)

def test_alive_false(self):
"""Tests the alive function returns false when post returns None"""
self.mocked_connection.return_value.cached_json_rpc_post.return_value = None
result = self.starkware_collector.alive()
result = self.starknet_collector.alive()
self.assertFalse(result)

def test_block_height(self):
"""Tests the block_height function uses the correct call and args to get block height"""
self.starkware_collector.block_height()
self.starknet_collector.block_height()
self.mocked_connection.return_value.cached_json_rpc_post.assert_called_once_with(
self.block_height_payload)

def test_block_height_returns_none(self):
"""Tests that the block height returns None if json_rpc_post returns None"""
self.mocked_connection.return_value.cached_json_rpc_post.return_value = None
result = self.starkware_collector.block_height()
result = self.starknet_collector.block_height()
self.assertEqual(None, result)

def test_latency(self):
"""Tests that the latency is obtained from the interface based on latest_query_latency"""
self.mocked_connection.return_value.latest_query_latency = 0.123
self.assertEqual(0.123, self.starkware_collector.latency())
self.assertEqual(0.123, self.starknet_collector.latency())
8 changes: 4 additions & 4 deletions src/test_registries.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ def test_get_collector_registry_for_solana(self):
helper_test_collector_registry(self, collector)

@mock.patch.dict(os.environ, {
"CONFIG_FILE_PATH": "tests/fixtures/configuration_starkware.yaml",
"CONFIG_FILE_PATH": "tests/fixtures/configuration_starknet.yaml",
"VALIDATION_FILE_PATH": "tests/fixtures/validation.yaml"
})
def test_get_collector_registry_for_starkware(self):
"""Tests that the starkware collector is called with the correct args"""
def test_get_collector_registry_for_starknet(self):
"""Tests that the starknet collector is called with the correct args"""
self.collector_registry = CollectorRegistry()
with mock.patch('collectors.StarkwareCollector', new=mock.Mock()) as collector:
with mock.patch('collectors.StarknetCollector', new=mock.Mock()) as collector:
helper_test_collector_registry(self, collector)

@mock.patch.dict(os.environ, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
blockchain: "starkware"
blockchain: "starknet"
chain_id: 1234
network_name: "TestNetwork"
network_type: "Mainnet"
collector: "starkware"
collector: "starknet"
endpoints:
- url: wss://test1.com
provider: TestProvider1
Expand Down

0 comments on commit 2a73342

Please sign in to comment.