Skip to content

Commit

Permalink
Adding wallet_balance method
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlynch committed Feb 9, 2018
1 parent ee536c0 commit 62afb18
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sia_load_tester/sia_client.py
Expand Up @@ -94,6 +94,10 @@ def allowance_budget(self):
return long(
self._api_impl.get_renter()[u'settings'][u'allowance'][u'funds'])

def wallet_balance(self):
"""Returns the wallet's confirmed Siacoin balance (in hastings)."""
return long(self._api_impl.get_wallet()[u'confirmedsiacoinbalance'])

def renter_files(self):
"""Returns a list of files known to the Sia renter."""
return self._api_impl.get_renter_files()[u'files']
Expand Down
29 changes: 29 additions & 0 deletions tests/test_sia_client.py
Expand Up @@ -57,6 +57,35 @@ def test_allowance_budget_returns_zero_when_no_budget_is_zero(self):
}
self.assertEqual(0, self.sia_client.allowance_budget())

def test_wallet_balance_returns_balance_when_wallet_has_siacoins(self):
self.mock_sia_api_impl.get_wallet.return_value = {
u'dustthreshold': u'30000000000000000000',
u'unlocked': True,
u'encrypted': True,
u'confirmedsiacoinbalance': u'500000000000000000000000000',
u'rescanning': False,
u'unconfirmedincomingsiacoins': u'0',
u'siacoinclaimbalance': u'0',
u'unconfirmedoutgoingsiacoins': u'0',
u'siafundbalance': u'0'
}
self.assertEqual(500000000000000000000000000,
self.sia_client.wallet_balance())

def test_wallet_balance_returns_zero_when_wallet_is_empty(self):
self.mock_sia_api_impl.get_wallet.return_value = {
u'dustthreshold': u'30000000000000000000',
u'unlocked': True,
u'encrypted': True,
u'confirmedsiacoinbalance': u'0',
u'rescanning': False,
u'unconfirmedincomingsiacoins': u'0',
u'siacoinclaimbalance': u'0',
u'unconfirmedoutgoingsiacoins': u'0',
u'siafundbalance': u'0'
}
self.assertEqual(0, self.sia_client.wallet_balance())

def test_renter_files_returns_all_files(self):
self.mock_sia_api_impl.get_renter_files.return_value = {
u'files': [
Expand Down

0 comments on commit 62afb18

Please sign in to comment.