Skip to content

Commit 5038b3d

Browse files
committed
Merge remote-tracking branch 'origin/feat/mainsail' into feat/contracts-endpoint
2 parents 91453b9 + a094348 commit 5038b3d

File tree

8 files changed

+61
-61
lines changed

8 files changed

+61
-61
lines changed

client/api/commits.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
class Commits(Resource):
55

6-
def show(self, height):
7-
return self.with_endpoint('api').request_get(f'commits/{height}')
6+
def show(self, block_number):
7+
return self.with_endpoint('api').request_get(f'commits/{block_number}')

client/api/delegates.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

client/api/rounds.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ def all(self, **kwargs):
99
def show(self, round_id):
1010
return self.with_endpoint('api').request_get(f'rounds/{round_id}')
1111

12-
def delegates(self, round_id):
13-
return self.with_endpoint('api').request_get(f'rounds/{round_id}/delegates')
12+
def validators(self, round_id):
13+
return self.with_endpoint('api').request_get(f'rounds/{round_id}/validators')

client/api/validators.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from client.resource import Resource
2+
3+
4+
class Validators(Resource):
5+
6+
def all(self, page=None, limit=100, **kwargs):
7+
extra_params = {name: kwargs[name] for name in kwargs if kwargs[name] is not None}
8+
params = {
9+
'page': page,
10+
'limit': limit,
11+
**extra_params
12+
}
13+
return self.with_endpoint('api').request_get('validators', params)
14+
15+
def get(self, validator_id):
16+
return self.with_endpoint('api').request_get(f'validators/{validator_id}')
17+
18+
def blocks(self, validator_id, **kwargs):
19+
return self.with_endpoint('api').request_get(f'validators/{validator_id}/blocks', kwargs)
20+
21+
def voters(self, validator_id, **kwargs):
22+
return self.with_endpoint('api').request_get(f'validators/{validator_id}/voters', kwargs)

client/client.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from client.api.blockchain import Blockchain
66
from client.api.blocks import Blocks
77
from client.api.commits import Commits
8-
from client.api.delegates import Delegates
8+
from client.api.validators import Validators
99
from client.api.evm import EVM
1010
from client.api.node import Node
1111
from client.api.peers import Peers
@@ -63,14 +63,6 @@ def contracts(self):
6363
"""
6464
return Contracts(self.connection)
6565

66-
@property
67-
def delegates(self):
68-
"""
69-
:return: Delegates API
70-
:rtype: client.api.delegates.Delegates
71-
"""
72-
return Delegates(self.connection)
73-
7466
@property
7567
def evm(self):
7668
"""
@@ -119,6 +111,14 @@ def transactions(self):
119111
"""
120112
return Transactions(self.connection)
121113

114+
@property
115+
def validators(self):
116+
"""
117+
:return: Validators API
118+
:rtype: client.api.validators.Validators
119+
"""
120+
return Validators(self.connection)
121+
122122
@property
123123
def votes(self):
124124
"""

tests/api/test_rounds.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ def test_show_calls_correct_url():
4747
assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/rounds/12345'
4848

4949

50-
def test_delegates_calls_correct_url():
50+
def test_validators_calls_correct_url():
5151
round_id = '12345'
5252
responses.add(
5353
responses.GET,
54-
f'http://127.0.0.1:4002/api/rounds/{round_id}/delegates',
54+
f'http://127.0.0.1:4002/api/rounds/{round_id}/validators',
5555
json={'success': True},
5656
status=200
5757
)
5858

5959
client = ArkClient('http://127.0.0.1:4002/api')
60-
client.rounds.delegates(round_id)
60+
client.rounds.validators(round_id)
6161

6262
assert len(responses.calls) == 1
63-
assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/rounds/12345/delegates'
63+
assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/rounds/12345/validators'
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,97 +8,97 @@
88
def test_all_calls_correct_url_with_default_params():
99
responses.add(
1010
responses.GET,
11-
'http://127.0.0.1:4002/api/delegates',
11+
'http://127.0.0.1:4002/api/validators',
1212
json={'success': True},
1313
status=200
1414
)
1515

1616
client = ArkClient('http://127.0.0.1:4002/api')
17-
client.delegates.all()
17+
client.validators.all()
1818
assert len(responses.calls) == 1
19-
assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/delegates?limit=100'
19+
assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/validators?limit=100'
2020

2121

2222
def test_all_calls_correct_url_with_passed_in_params():
2323
responses.add(
2424
responses.GET,
25-
'http://127.0.0.1:4002/api/delegates',
25+
'http://127.0.0.1:4002/api/validators',
2626
json={'success': True},
2727
status=200
2828
)
2929

3030
client = ArkClient('http://127.0.0.1:4002/api')
31-
client.delegates.all(page=5, limit=69)
31+
client.validators.all(page=5, limit=69)
3232
assert len(responses.calls) == 1
33-
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/delegates?')
33+
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/validators?')
3434
assert 'page=5' in responses.calls[0].request.url
3535
assert 'limit=69' in responses.calls[0].request.url
3636

3737

3838
def test_all_calls_correct_url_with_additional_params():
3939
responses.add(
4040
responses.GET,
41-
'http://127.0.0.1:4002/api/delegates',
41+
'http://127.0.0.1:4002/api/validators',
4242
json={'success': True},
4343
status=200
4444
)
4545

4646
client = ArkClient('http://127.0.0.1:4002/api')
47-
client.delegates.all(page=5, limit=69, orderBy="username")
47+
client.validators.all(page=5, limit=69, orderBy="username")
4848
assert len(responses.calls) == 1
49-
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/delegates?')
49+
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/validators?')
5050
assert 'page=5' in responses.calls[0].request.url
5151
assert 'limit=69' in responses.calls[0].request.url
5252
assert 'orderBy=username' in responses.calls[0].request.url
5353

5454

5555
def test_get_calls_correct_url():
56-
delegate_id = '12345'
56+
validator_id = '12345'
5757
responses.add(
5858
responses.GET,
59-
'http://127.0.0.1:4002/api/delegates/{}'.format(delegate_id),
59+
'http://127.0.0.1:4002/api/validators/{}'.format(validator_id),
6060
json={'success': True},
6161
status=200
6262
)
6363

6464
client = ArkClient('http://127.0.0.1:4002/api')
65-
client.delegates.get(delegate_id)
65+
client.validators.get(validator_id)
6666

6767
assert len(responses.calls) == 1
68-
assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/delegates/12345'
68+
assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/validators/12345'
6969

7070

7171
def test_blocks_calls_correct_url():
72-
delegate_id = '12345'
72+
validator_id = '12345'
7373
responses.add(
7474
responses.GET,
75-
'http://127.0.0.1:4002/api/delegates/{}/blocks'.format(delegate_id),
75+
'http://127.0.0.1:4002/api/validators/{}/blocks'.format(validator_id),
7676
json={'success': True},
7777
status=200
7878
)
7979

8080
client = ArkClient('http://127.0.0.1:4002/api')
81-
client.delegates.blocks(delegate_id, limit=100, orderBy='timestamp:desc')
81+
client.validators.blocks(validator_id, limit=100, orderBy='timestamp:desc')
8282

8383
assert len(responses.calls) == 1
84-
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/delegates/12345/blocks?')
84+
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/validators/12345/blocks?')
8585
assert 'limit=100' in responses.calls[0].request.url
8686
assert 'orderBy=timestamp%3Adesc' in responses.calls[0].request.url
8787

8888

8989
def test_voters_calls_correct_url():
90-
delegate_id = '12345'
90+
validator_id = '12345'
9191
responses.add(
9292
responses.GET,
93-
'http://127.0.0.1:4002/api/delegates/{}/voters'.format(delegate_id),
93+
'http://127.0.0.1:4002/api/validators/{}/voters'.format(validator_id),
9494
json={'success': True},
9595
status=200
9696
)
9797

9898
client = ArkClient('http://127.0.0.1:4002/api')
99-
client.delegates.voters(delegate_id, limit=100, orderBy='timestamp:desc')
99+
client.validators.voters(validator_id, limit=100, orderBy='timestamp:desc')
100100

101101
assert len(responses.calls) == 1
102-
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/delegates/12345/voters?')
102+
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/validators/12345/voters?')
103103
assert 'limit=100' in responses.calls[0].request.url
104104
assert 'orderBy=timestamp%3Adesc' in responses.calls[0].request.url

tests/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ def test_client():
1111
assert hasattr(client, 'blockchain') == True
1212
assert hasattr(client, 'blocks') == True
1313
assert hasattr(client, 'commits') == True
14-
assert hasattr(client, 'delegates') == True
1514
assert hasattr(client, 'evm') == True
1615
assert hasattr(client, 'node') == True
1716
assert hasattr(client, 'peers') == True
1817
assert hasattr(client, 'rounds') == True
1918
assert hasattr(client, 'transactions') == True
19+
assert hasattr(client, 'validators') == True
2020
assert hasattr(client, 'votes') == True
2121
assert hasattr(client, 'wallets') == True

0 commit comments

Comments
 (0)