fixing unit tests

This commit is contained in:
Lex Berezhny 2020-03-20 12:09:20 -04:00
parent dd21803598
commit 93fc883b90
4 changed files with 11 additions and 11 deletions

View file

@ -4145,7 +4145,7 @@ class Daemon(metaclass=JSONRPCServerType):
--is_my_input : (bool) show outputs created by you --is_my_input : (bool) show outputs created by you
--is_not_my_input : (bool) show outputs not created by you --is_not_my_input : (bool) show outputs not created by you
--exclude_internal_transfers: (bool) excludes any outputs that are exactly this combination: --exclude_internal_transfers: (bool) excludes any outputs that are exactly this combination:
--is_my_input --is_my_output --type=other "--is_my_input --is_my_output --type=other"
this allows to exclude "change" payments, this this allows to exclude "change" payments, this
flag can be used in combination with any of the other flags flag can be used in combination with any of the other flags
--account_id=<account_id> : (str) id of the account to query --account_id=<account_id> : (str) id of the account to query

View file

@ -677,7 +677,7 @@ class Database(SQLiteMixin):
self, cols, accounts=None, is_my_input=None, is_my_output=True, self, cols, accounts=None, is_my_input=None, is_my_output=True,
is_my_input_or_output=None, exclude_internal_transfers=False, is_my_input_or_output=None, exclude_internal_transfers=False,
include_is_spent=False, include_is_my_input=False, include_is_spent=False, include_is_my_input=False,
read_only=True, **constraints): read_only=False, **constraints):
for rename_col in ('txid', 'txoid'): for rename_col in ('txid', 'txoid'):
for rename_constraint in (rename_col, rename_col+'__in', rename_col+'__not_in'): for rename_constraint in (rename_col, rename_col+'__in', rename_col+'__not_in'):
if rename_constraint in constraints: if rename_constraint in constraints:

View file

@ -218,7 +218,7 @@ class DaemonDocsTests(TestCase):
try: try:
docopt.docopt(fn.__doc__, ()) docopt.docopt(fn.__doc__, ())
except docopt.DocoptLanguageError as err: except docopt.DocoptLanguageError as err:
failures.append(f"invalid docstring for {name}, {err.message}") failures.append(f"invalid docstring for {name}, {err.args[0]}")
except docopt.DocoptExit: except docopt.DocoptExit:
pass pass
if failures: if failures:

View file

@ -353,14 +353,14 @@ class TestQueries(AsyncioTestCase):
self.assertListEqual([tx3.id, tx2.id, tx1.id], [tx.id for tx in txs]) self.assertListEqual([tx3.id, tx2.id, tx1.id], [tx.id for tx in txs])
self.assertListEqual([3, 2, 1], [tx.height for tx in txs]) self.assertListEqual([3, 2, 1], [tx.height for tx in txs])
txs = await self.ledger.db.get_transactions(wallet=wallet1, accounts=wallet1.accounts) txs = await self.ledger.db.get_transactions(wallet=wallet1, accounts=wallet1.accounts, include_is_my_output=True)
self.assertListEqual([tx2.id, tx1.id], [tx.id for tx in txs]) self.assertListEqual([tx2.id, tx1.id], [tx.id for tx in txs])
self.assertEqual(txs[0].inputs[0].is_my_input, True) self.assertEqual(txs[0].inputs[0].is_my_input, True)
self.assertEqual(txs[0].outputs[0].is_my_output, False) self.assertEqual(txs[0].outputs[0].is_my_output, False)
self.assertEqual(txs[1].inputs[0].is_my_input, False) self.assertEqual(txs[1].inputs[0].is_my_input, False)
self.assertEqual(txs[1].outputs[0].is_my_output, True) self.assertEqual(txs[1].outputs[0].is_my_output, True)
txs = await self.ledger.db.get_transactions(wallet=wallet2, accounts=[account2]) txs = await self.ledger.db.get_transactions(wallet=wallet2, accounts=[account2], include_is_my_output=True)
self.assertListEqual([tx3.id, tx2.id], [tx.id for tx in txs]) self.assertListEqual([tx3.id, tx2.id], [tx.id for tx in txs])
self.assertEqual(txs[0].inputs[0].is_my_input, True) self.assertEqual(txs[0].inputs[0].is_my_input, True)
self.assertEqual(txs[0].outputs[0].is_my_output, False) self.assertEqual(txs[0].outputs[0].is_my_output, False)
@ -370,20 +370,20 @@ class TestQueries(AsyncioTestCase):
tx = await self.ledger.db.get_transaction(txid=tx2.id) tx = await self.ledger.db.get_transaction(txid=tx2.id)
self.assertEqual(tx.id, tx2.id) self.assertEqual(tx.id, tx2.id)
self.assertFalse(tx.inputs[0].is_my_input) self.assertIsNone(tx.inputs[0].is_my_input)
self.assertFalse(tx.outputs[0].is_my_output) self.assertIsNone(tx.outputs[0].is_my_output)
tx = await self.ledger.db.get_transaction(wallet=wallet1, txid=tx2.id) tx = await self.ledger.db.get_transaction(wallet=wallet1, txid=tx2.id, include_is_my_output=True)
self.assertTrue(tx.inputs[0].is_my_input) self.assertTrue(tx.inputs[0].is_my_input)
self.assertFalse(tx.outputs[0].is_my_output) self.assertFalse(tx.outputs[0].is_my_output)
tx = await self.ledger.db.get_transaction(wallet=wallet2, txid=tx2.id) tx = await self.ledger.db.get_transaction(wallet=wallet2, txid=tx2.id, include_is_my_output=True)
self.assertFalse(tx.inputs[0].is_my_input) self.assertFalse(tx.inputs[0].is_my_input)
self.assertTrue(tx.outputs[0].is_my_output) self.assertTrue(tx.outputs[0].is_my_output)
# height 0 sorted to the top with the rest in descending order # height 0 sorted to the top with the rest in descending order
tx4 = await self.create_tx_from_nothing(account1, 0) tx4 = await self.create_tx_from_nothing(account1, 0)
txos = await self.ledger.db.get_txos() txos = await self.ledger.db.get_txos()
self.assertListEqual([0, 2, 2, 1], [txo.tx_ref.height for txo in txos]) self.assertListEqual([0, 3, 2, 2, 1], [txo.tx_ref.height for txo in txos])
self.assertListEqual([tx4.id, tx2.id, tx2b.id, tx1.id], [txo.tx_ref.id for txo in txos]) self.assertListEqual([tx4.id, tx3.id, tx2.id, tx2b.id, tx1.id], [txo.tx_ref.id for txo in txos])
txs = await self.ledger.db.get_transactions(accounts=[account1, account2]) txs = await self.ledger.db.get_transactions(accounts=[account1, account2])
self.assertListEqual([0, 3, 2, 1], [tx.height for tx in txs]) self.assertListEqual([0, 3, 2, 1], [tx.height for tx in txs])
self.assertListEqual([tx4.id, tx3.id, tx2.id, tx1.id], [tx.id for tx in txs]) self.assertListEqual([tx4.id, tx3.id, tx2.id, tx1.id], [tx.id for tx in txs])