--blocking support in abandon command

This commit is contained in:
Lex Berezhny 2018-11-07 14:43:07 -05:00
parent daecc582f3
commit 934682bd0f
2 changed files with 9 additions and 11 deletions

View file

@ -2315,7 +2315,7 @@ class Daemon(AuthJSONRPCServer):
) )
@requires(WALLET_COMPONENT, conditions=[WALLET_IS_UNLOCKED]) @requires(WALLET_COMPONENT, conditions=[WALLET_IS_UNLOCKED])
async def jsonrpc_claim_abandon(self, claim_id=None, txid=None, nout=None, account_id=None): async def jsonrpc_claim_abandon(self, claim_id=None, txid=None, nout=None, account_id=None, blocking=True):
""" """
Abandon a name and reclaim credits from the claim Abandon a name and reclaim credits from the claim
@ -2323,12 +2323,14 @@ class Daemon(AuthJSONRPCServer):
claim_abandon [<claim_id> | --claim_id=<claim_id>] claim_abandon [<claim_id> | --claim_id=<claim_id>]
[<txid> | --txid=<txid>] [<nout> | --nout=<nout>] [<txid> | --txid=<txid>] [<nout> | --nout=<nout>]
[--account_id=<account_id>] [--account_id=<account_id>]
[--blocking]
Options: Options:
--claim_id=<claim_id> : (str) claim_id of the claim to abandon --claim_id=<claim_id> : (str) claim_id of the claim to abandon
--txid=<txid> : (str) txid of the claim to abandon --txid=<txid> : (str) txid of the claim to abandon
--nout=<nout> : (int) nout of the claim to abandon --nout=<nout> : (int) nout of the claim to abandon
--account_id=<account_id> : (str) id of the account to use --account_id=<account_id> : (str) id of the account to use
--blocking : (bool) wait until abandon is in mempool
Returns: Returns:
(dict) Dictionary containing result of the claim (dict) Dictionary containing result of the claim
@ -2348,6 +2350,8 @@ class Daemon(AuthJSONRPCServer):
tx = await self.wallet_manager.abandon_claim(claim_id, txid, nout, account) tx = await self.wallet_manager.abandon_claim(claim_id, txid, nout, account)
self.analytics_manager.send_claim_action('abandon') self.analytics_manager.send_claim_action('abandon')
if blocking:
await self.ledger.wait(tx)
return {"success": True, "tx": tx} return {"success": True, "tx": tx}
@requires(WALLET_COMPONENT, conditions=[WALLET_IS_UNLOCKED]) @requires(WALLET_COMPONENT, conditions=[WALLET_IS_UNLOCKED])

View file

@ -163,9 +163,9 @@ class CommandTestCase(IntegrationTestCase):
self.manager.old_db = self.daemon.storage self.manager.old_db = self.daemon.storage
async def tearDown(self): async def tearDown(self):
await super().tearDown()
self.wallet_component._running = False self.wallet_component._running = False
await d2f(self.daemon._shutdown()) await d2f(self.daemon._shutdown())
await super().tearDown()
async def confirm_tx(self, txid): async def confirm_tx(self, txid):
""" Wait for tx to be in mempool, then generate a block, wait for tx to be in a block. """ """ Wait for tx to be in mempool, then generate a block, wait for tx to be in a block. """
@ -622,17 +622,11 @@ class AbandonCommand(CommandTestCase):
'hovercraft', '0.0001', file_path=file.name 'hovercraft', '0.0001', file_path=file.name
)) ))
self.assertTrue(claim['success']) self.assertTrue(claim['success'])
await self.on_transaction_dict(claim['tx'])
await self.on_transaction_dict(claim['tx']) await self.generate(1)
await self.generate(1)
self.assertEqual('9.979793', await self.daemon.jsonrpc_account_balance()) self.assertEqual('9.979793', await self.daemon.jsonrpc_account_balance())
await self.out(self.daemon.jsonrpc_claim_abandon(claim['claim_id']))
abandon = await self.out(self.daemon.jsonrpc_claim_abandon(claim['claim_id']))
await self.on_transaction_dict(abandon['tx'])
await self.generate(1)
self.assertEqual('9.97968399', await self.daemon.jsonrpc_account_balance()) self.assertEqual('9.97968399', await self.daemon.jsonrpc_account_balance())