mirror of
https://github.com/monero-project/monero.git
synced 2024-12-13 03:46:32 +02:00
functional_tests: add rescan_spent/rescan_blockchain tests
This commit is contained in:
parent
4ba8254a1d
commit
f2e811fced
@ -49,6 +49,7 @@ class TransferTest():
|
|||||||
self.sweep_dust()
|
self.sweep_dust()
|
||||||
self.sweep_single()
|
self.sweep_single()
|
||||||
self.check_destinations()
|
self.check_destinations()
|
||||||
|
self.check_rescan()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
print('Resetting blockchain')
|
print('Resetting blockchain')
|
||||||
@ -718,7 +719,45 @@ class TransferTest():
|
|||||||
daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 1)
|
daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 1)
|
||||||
self.wallet[0].refresh()
|
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__':
|
if __name__ == '__main__':
|
||||||
|
@ -890,6 +890,27 @@ class Wallet(object):
|
|||||||
}
|
}
|
||||||
return self.rpc.send_json_rpc_request(set_account_tag_description)
|
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 = ''):
|
def make_uri(self, address = '', payment_id = '', amount = 0, tx_description = '', recipient_name = ''):
|
||||||
make_uri = {
|
make_uri = {
|
||||||
'method': 'make_uri',
|
'method': 'make_uri',
|
||||||
|
Loading…
Reference in New Issue
Block a user