mirror of
https://github.com/monero-project/monero.git
synced 2024-10-01 11:49:47 -04:00
functional_tests: add more wallet tests
get_transfer_by_txid, get_height, open/close
This commit is contained in:
parent
23f86dad02
commit
2d68b31f3e
@ -62,9 +62,14 @@ class TransferTest():
|
||||
print("Mining some blocks")
|
||||
daemon = Daemon()
|
||||
|
||||
res = daemon.get_info()
|
||||
height = res.height
|
||||
|
||||
daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 80)
|
||||
for i in range(len(self.wallet)):
|
||||
self.wallet[i].refresh()
|
||||
res = self.wallet[i].get_height()
|
||||
assert res.height == height + 80
|
||||
|
||||
def transfer(self):
|
||||
daemon = Daemon()
|
||||
@ -169,6 +174,27 @@ class TransferTest():
|
||||
assert e.double_spend_seen == False
|
||||
assert e.confirmations == 1
|
||||
|
||||
res = self.wallet[0].get_height()
|
||||
wallet_height = res.height
|
||||
res = self.wallet[0].get_transfer_by_txid(txid)
|
||||
assert len(res.transfers) == 1
|
||||
assert res.transfers[0] == res.transfer
|
||||
t = res.transfer
|
||||
assert t.txid == txid
|
||||
assert t.payment_id == payment_id
|
||||
assert t.height == wallet_height - 1
|
||||
assert t.timestamp > 0
|
||||
assert t.amount == 0 # to self, so it's just "pay a fee" really
|
||||
assert t.fee == fee
|
||||
assert t.note == ''
|
||||
assert len(t.destinations) == 1
|
||||
assert t.destinations[0] == {'address': '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 'amount': 1000000000000}
|
||||
assert t.type == 'out'
|
||||
assert t.unlock_time == 0
|
||||
assert t.address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
|
||||
assert t.double_spend_seen == False
|
||||
assert t.confirmations == 1
|
||||
|
||||
res = self.wallet[0].get_balance()
|
||||
assert res.balance == running_balances[0]
|
||||
assert res.unlocked_balance <= res.balance
|
||||
|
@ -45,6 +45,7 @@ class WalletAddressTest():
|
||||
self.check_main_address()
|
||||
self.check_keys()
|
||||
self.create_subaddresses()
|
||||
self.open_close()
|
||||
|
||||
def create(self):
|
||||
print 'Creating wallet'
|
||||
@ -148,5 +149,33 @@ class WalletAddressTest():
|
||||
res = wallet.get_address_index('82pP87g1Vkd3LUMssBCumk3MfyEsFqLAaGDf6oxddu61EgSFzt8gCwUD4tr3kp9TUfdPs2CnpD7xLZzyC1Ei9UsW3oyCWDf')
|
||||
assert res.index == {'major': 1, 'minor': 0}
|
||||
|
||||
def open_close(self):
|
||||
print 'Testing open/close'
|
||||
wallet = Wallet()
|
||||
|
||||
res = wallet.get_address()
|
||||
assert res.address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
|
||||
|
||||
wallet.close_wallet()
|
||||
ok = False
|
||||
try: res = wallet.get_address()
|
||||
except: ok = True
|
||||
assert ok
|
||||
|
||||
wallet.restore_deterministic_wallet(seed = 'peeled mixture ionic radar utopia puddle buying illness nuns gadget river spout cavernous bounced paradise drunk looking cottage jump tequila melting went winter adjust spout')
|
||||
res = wallet.get_address()
|
||||
assert res.address == '44Kbx4sJ7JDRDV5aAhLJzQCjDz2ViLRduE3ijDZu3osWKBjMGkV1XPk4pfDUMqt1Aiezvephdqm6YD19GKFD9ZcXVUTp6BW'
|
||||
|
||||
wallet.close_wallet()
|
||||
ok = False
|
||||
try: wallet.get_address()
|
||||
except: ok = True
|
||||
assert ok
|
||||
|
||||
wallet.restore_deterministic_wallet(seed = 'velvet lymph giddy number token physics poetry unquoted nibs useful sabotage limits benches lifestyle eden nitrogen anvil fewest avoid batch vials washing fences goat unquoted')
|
||||
res = wallet.get_address()
|
||||
assert res.address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
WalletAddressTest().run_test()
|
||||
|
@ -89,6 +89,18 @@ class Wallet(object):
|
||||
}
|
||||
return self.rpc.send_json_rpc_request(transfer)
|
||||
|
||||
def get_transfer_by_txid(self, txid, account_index = 0):
|
||||
get_transfer_by_txid = {
|
||||
'method': 'get_transfer_by_txid',
|
||||
'params': {
|
||||
'txid': txid,
|
||||
'account_index': account_index,
|
||||
},
|
||||
'jsonrpc': '2.0',
|
||||
'id': '0'
|
||||
}
|
||||
return self.rpc.send_json_rpc_request(get_transfer_by_txid)
|
||||
|
||||
def get_bulk_payments(self, payment_ids = [], min_block_height = 0):
|
||||
get_bulk_payments = {
|
||||
'method': 'get_bulk_payments',
|
||||
@ -592,6 +604,25 @@ class Wallet(object):
|
||||
}
|
||||
return self.rpc.send_json_rpc_request(verify)
|
||||
|
||||
def get_height(self):
|
||||
get_height = {
|
||||
'method': 'get_height',
|
||||
'jsonrpc': '2.0',
|
||||
'id': '0'
|
||||
}
|
||||
return self.rpc.send_json_rpc_request(get_height)
|
||||
|
||||
def relay_tx(self, hex_):
|
||||
relay_tx = {
|
||||
'method': 'relay_tx',
|
||||
'params': {
|
||||
'hex': hex_,
|
||||
},
|
||||
'jsonrpc': '2.0',
|
||||
'id': '0'
|
||||
}
|
||||
return self.rpc.send_json_rpc_request(relay_tx)
|
||||
|
||||
def get_version(self):
|
||||
get_version = {
|
||||
'method': 'get_version',
|
||||
|
Loading…
Reference in New Issue
Block a user