From 575b8a02427e2069910aa88109b7bd463109cab3 Mon Sep 17 00:00:00 2001 From: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com> Date: Wed, 26 Mar 2025 17:05:59 +0000 Subject: [PATCH 1/2] refactor: blocks transactions endpoint wildcard arguments --- client/api/blocks.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/client/api/blocks.py b/client/api/blocks.py index 6939919..4fafce4 100644 --- a/client/api/blocks.py +++ b/client/api/blocks.py @@ -21,9 +21,5 @@ def first(self): def last(self): return self.with_endpoint('api').request_get('blocks/last') - def transactions(self, block_id, page=None, limit=100): - params = { - 'page': page, - 'limit': limit, - } - return self.with_endpoint('api').request_get(f'blocks/{block_id}/transactions', params) + def transactions(self, block_id, **kwargs): + return self.with_endpoint('api').request_get(f'blocks/{block_id}/transactions', kwargs) From 11a13cfd9c93e0539dbf6f54f4141258774c551b Mon Sep 17 00:00:00 2001 From: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com> Date: Wed, 26 Mar 2025 17:06:06 +0000 Subject: [PATCH 2/2] test --- tests/api/test_blocks.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/tests/api/test_blocks.py b/tests/api/test_blocks.py index 949c77f..1115c5a 100644 --- a/tests/api/test_blocks.py +++ b/tests/api/test_blocks.py @@ -99,23 +99,6 @@ def test_last_calls_correct_url(): assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/blocks/last' -def test_transactions_calls_correct_url_with_default_params(): - block_id = '12345' - responses.add( - responses.GET, - 'http://127.0.0.1:4002/api/blocks/{}/transactions'.format(block_id), - json={'success': True}, - status=200 - ) - - client = ArkClient('http://127.0.0.1:4002/api') - client.blocks.transactions(block_id) - assert len(responses.calls) == 1 - assert responses.calls[0].request.url == ( - 'http://127.0.0.1:4002/api/blocks/12345/transactions?limit=100' - ) - - def test_transactions_calls_correct_url_with_passed_in_params(): block_id = '12345' responses.add( @@ -126,10 +109,11 @@ def test_transactions_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.blocks.transactions(block_id, page=5, limit=69) + client.blocks.transactions(block_id, page=5, limit=69, orderBy="timestamp.epoch") assert len(responses.calls) == 1 assert responses.calls[0].request.url.startswith( 'http://127.0.0.1:4002/api/blocks/12345/transactions?' ) assert 'page=5' in responses.calls[0].request.url assert 'limit=69' in responses.calls[0].request.url + assert 'orderBy=timestamp.epoch' in responses.calls[0].request.url