aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-05-02 11:04:43 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-09-17 11:38:24 +0000
commitf2e811fcedd8ba3d9195f75f13cb816c2e8ecb1f (patch)
treef24db27804842b100c90c75a46d361f676f5b97f
parentfunctional_tests: add monero: URI tests (diff)
downloadmonero-f2e811fcedd8ba3d9195f75f13cb816c2e8ecb1f.tar.xz
functional_tests: add rescan_spent/rescan_blockchain tests
-rwxr-xr-xtests/functional_tests/transfer.py39
-rw-r--r--utils/python-rpc/framework/wallet.py21
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/functional_tests/transfer.py b/tests/functional_tests/transfer.py
index 44898b68e..ab1d6ccfe 100755
--- a/tests/functional_tests/transfer.py
+++ b/tests/functional_tests/transfer.py
@@ -49,6 +49,7 @@ class TransferTest():
self.sweep_dust()
self.sweep_single()
self.check_destinations()
+ self.check_rescan()
def reset(self):
print('Resetting blockchain')
@@ -718,7 +719,45 @@ class TransferTest():
daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 1)
self.wallet[0].refresh()
+ def check_rescan(self):
+ daemon = Daemon()
+ print('Testing rescan_spent')
+ res = self.wallet[0].incoming_transfers(transfer_type = 'all')
+ transfers = res.transfers
+ res = self.wallet[0].rescan_spent()
+ res = self.wallet[0].incoming_transfers(transfer_type = 'all')
+ assert transfers == res.transfers
+
+ for hard in [False, True]:
+ print('Testing %s rescan_blockchain' % ('hard' if hard else 'soft'))
+ res = self.wallet[0].incoming_transfers(transfer_type = 'all')
+ transfers = res.transfers
+ res = self.wallet[0].get_transfers()
+ t_in = res['in']
+ t_out = res.out
+ res = self.wallet[0].rescan_blockchain(hard = hard)
+ res = self.wallet[0].incoming_transfers(transfer_type = 'all')
+ assert transfers == res.transfers
+ res = self.wallet[0].get_transfers()
+ assert t_in == res['in']
+ # some information can not be recovered for out txes
+ unrecoverable_fields = ['payment_id', 'destinations', 'note']
+ old_t_out = []
+ for x in t_out:
+ e = {}
+ for k in x.keys():
+ if not k in unrecoverable_fields:
+ e[k] = x[k]
+ old_t_out.append(e)
+ new_t_out = []
+ for x in res.out:
+ e = {}
+ for k in x.keys():
+ if not k in unrecoverable_fields:
+ e[k] = x[k]
+ new_t_out.append(e)
+ assert sorted(old_t_out) == sorted(new_t_out)
if __name__ == '__main__':
diff --git a/utils/python-rpc/framework/wallet.py b/utils/python-rpc/framework/wallet.py
index 741569858..4065af892 100644
--- a/utils/python-rpc/framework/wallet.py
+++ b/utils/python-rpc/framework/wallet.py
@@ -890,6 +890,27 @@ class Wallet(object):
}
return self.rpc.send_json_rpc_request(set_account_tag_description)
+ def rescan_blockchain(self, hard = False):
+ rescan_blockchain = {
+ 'method': 'rescan_blockchain',
+ 'jsonrpc': '2.0',
+ 'params': {
+ 'hard': hard,
+ },
+ 'id': '0'
+ }
+ return self.rpc.send_json_rpc_request(rescan_blockchain)
+
+ def rescan_spent(self):
+ rescan_spent = {
+ 'method': 'rescan_spent',
+ 'jsonrpc': '2.0',
+ 'params': {
+ },
+ 'id': '0'
+ }
+ return self.rpc.send_json_rpc_request(rescan_spent)
+
def make_uri(self, address = '', payment_id = '', amount = 0, tx_description = '', recipient_name = ''):
make_uri = {
'method': 'make_uri',