Skip to content

Commit

Permalink
update for release/beta
Browse files Browse the repository at this point in the history
  • Loading branch information
yourbuddyconner committed Jul 19, 2019
1 parent cf045da commit 0a0b3aa
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 35 deletions.
24 changes: 18 additions & 6 deletions CodaClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(
websocket_protocol: str = "ws",
graphql_host: str = "localhost",
graphql_path: str = "/graphql",
graphql_port: int = 8080,
graphql_port: int = 8304,
):
self.endpoint = "{}://{}:{}{}".format(graphql_protocol, graphql_host, graphql_port, graphql_path)
self.websocket_endpoint = "{}://{}:{}{}".format(websocket_protocol, graphql_host, graphql_port, graphql_path)
Expand Down Expand Up @@ -112,7 +112,7 @@ def get_daemon_status(self) -> dict:
query {
daemonStatus {
numAccounts
blockCount
blockchainLength
uptimeSecs
ledgerMerkleRoot
stagedLedgerHash
Expand Down Expand Up @@ -170,8 +170,8 @@ def get_wallets(self) -> dict:
res = self._send_query(query)
return res["data"]

def get_balance(self, pk: str) -> dict:
"""Gets the balance for the specified Public Key.
def get_wallet(self, pk: str) -> dict:
"""Gets the wallet for the specified Public Key.
Arguments:
pk {str} -- A Public Key corresponding to a currently installed wallet.
Expand All @@ -180,8 +180,20 @@ def get_balance(self, pk: str) -> dict:
dict -- Returns the "data" field of the JSON Response as a Dict.
"""
query = '''
query($publicKey:String!){
balance(publicKey:$publicKey)
query($publicKey:PublicKey!){
wallet(publicKey:$publicKey) {
publicKey
balance {
total
unknown
}
nonce
receiptChainHash
delegate
votingFor
stakingActive
privateKeyPath
}
}
'''
variables = {
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name='CodaClient',
version='0.0.3',
version='0.0.4',
python_requires='>=3.5',
description='A Python wrapper around the Coda Daemon GraphQL API.',
github='http://github.com/CodaProtocol/coda-python',
Expand Down
52 changes: 26 additions & 26 deletions tests/snapshots/snap_test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
snapshots['TestCodaClient.test_get_daemon_status 1'] = [
(
(
'http://localhost:8080/graphql'
'http://localhost:8304/graphql'
,),
{
'json': {
'query': 'query { daemonStatus { numAccounts blockCount uptimeSecs ledgerMerkleRoot stagedLedgerHash stateHash peers userCommandsSent runSnarkWorker proposePubkeys consensusTimeNow consensusTimeBestTip consensusMechanism consensusConfiguration { delta k c cTimesK slotsPerEpoch slotDuration epochDuration acceptableNetworkDelay } } }'
'query': 'query { daemonStatus { numAccounts blockchainLength uptimeSecs ledgerMerkleRoot stagedLedgerHash stateHash peers userCommandsSent runSnarkWorker proposePubkeys consensusTimeNow consensusTimeBestTip consensusMechanism consensusConfiguration { delta k c cTimesK slotsPerEpoch slotDuration epochDuration acceptableNetworkDelay } } }'
}
}
,)
Expand All @@ -23,7 +23,7 @@
snapshots['TestCodaClient.test_get_daemon_version 1'] = [
(
(
'http://localhost:8080/graphql'
'http://localhost:8304/graphql'
,),
{
'json': {
Expand All @@ -36,7 +36,7 @@
snapshots['TestCodaClient.test_get_wallets 1'] = [
(
(
'http://localhost:8080/graphql'
'http://localhost:8304/graphql'
,),
{
'json': {
Expand All @@ -46,26 +46,10 @@
,)
]

snapshots['TestCodaClient.test_get_balance 1'] = [
(
(
'http://localhost:8080/graphql'
,),
{
'json': {
'query': 'query($publicKey:String!){ balance(publicKey:$publicKey) }',
'variables': {
'publicKey': 'pk'
}
}
}
,)
]

snapshots['TestCodaClient.test_get_current_snark_worker 1'] = [
(
(
'http://localhost:8080/graphql'
'http://localhost:8304/graphql'
,),
{
'json': {
Expand All @@ -78,7 +62,7 @@
snapshots['TestCodaClient.test_get_sync_status 1'] = [
(
(
'http://localhost:8080/graphql'
'http://localhost:8304/graphql'
,),
{
'json': {
Expand All @@ -91,7 +75,7 @@
snapshots['TestCodaClient.test_set_current_snark_worker 1'] = [
(
(
'http://localhost:8080/graphql'
'http://localhost:8304/graphql'
,),
{
'json': {
Expand All @@ -104,7 +88,7 @@
snapshots['TestCodaClient.test_create_wallet_with_args 1'] = [
(
(
'http://localhost:8080/graphql'
'http://localhost:8304/graphql'
,),
{
'json': {
Expand All @@ -121,7 +105,7 @@
snapshots['TestCodaClient.test_create_wallet_no_args 1'] = [
(
(
'http://localhost:8080/graphql'
'http://localhost:8304/graphql'
,),
{
'json': {
Expand All @@ -138,7 +122,7 @@
snapshots['TestCodaClient.test_send_payment 1'] = [
(
(
'http://localhost:8080/graphql'
'http://localhost:8304/graphql'
,),
{
'json': {
Expand All @@ -154,3 +138,19 @@
}
,)
]

snapshots['TestCodaClient.test_get_wallet 1'] = [
(
(
'http://localhost:8304/graphql'
,),
{
'json': {
'query': 'query($publicKey:PublicKey!){ wallet(publicKey:$publicKey) { publicKey balance { total unknown } nonce receiptChainHash delegate votingFor stakingActive privateKeyPath } }',
'variables': {
'publicKey': 'pk'
}
}
}
,)
]
4 changes: 2 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ def test_get_wallets(self, mock_post, snapshot):
client.get_wallets()
snapshot.assert_match(mock_post.call_args_list)

def test_get_balance(self, mock_post, snapshot):
def test_get_wallet(self, mock_post, snapshot):
mock_post.return_value = self._mock_response(json_data={"data": "foo"})

client = Client()
client.get_balance("pk")
client.get_wallet("pk")
snapshot.assert_match(mock_post.call_args_list)

def test_get_current_snark_worker(self, mock_post, snapshot):
Expand Down

0 comments on commit 0a0b3aa

Please sign in to comment.