mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-26 21:03:28 +01:00
functional_tests: add spend proof tests
This commit is contained in:
parent
a71d91cecf
commit
8e077a5fc0
@ -44,6 +44,7 @@ class ProofsTest():
|
|||||||
txid, tx_key, amount = self.transfer()
|
txid, tx_key, amount = self.transfer()
|
||||||
self.check_tx_key(txid, tx_key, amount)
|
self.check_tx_key(txid, tx_key, amount)
|
||||||
self.check_tx_proof(txid, amount)
|
self.check_tx_proof(txid, amount)
|
||||||
|
self.check_spend_proof(txid)
|
||||||
self.check_reserve_proof()
|
self.check_reserve_proof()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
@ -217,6 +218,40 @@ class ProofsTest():
|
|||||||
except: ok = True
|
except: ok = True
|
||||||
assert ok or not res.good
|
assert ok or not res.good
|
||||||
|
|
||||||
|
def check_spend_proof(self, txid):
|
||||||
|
daemon = Daemon()
|
||||||
|
|
||||||
|
print('Checking spend proof')
|
||||||
|
|
||||||
|
self.wallet[0].refresh()
|
||||||
|
self.wallet[1].refresh()
|
||||||
|
|
||||||
|
res = self.wallet[0].get_spend_proof(txid, message = 'foo')
|
||||||
|
assert len(res.signature) > 0
|
||||||
|
signature = res.signature
|
||||||
|
res = self.wallet[1].check_spend_proof(txid, message = 'foo', signature = signature)
|
||||||
|
assert res.good
|
||||||
|
|
||||||
|
res = self.wallet[0].get_spend_proof(txid, message = 'foobar')
|
||||||
|
assert len(res.signature) > 0
|
||||||
|
signature2 = res.signature
|
||||||
|
res = self.wallet[1].check_spend_proof(txid, message = 'foobar', signature = signature2)
|
||||||
|
assert res.good
|
||||||
|
|
||||||
|
ok = False
|
||||||
|
try: res = self.wallet[1].check_spend_proof('0' * 64, message = 'foo', signature = signature)
|
||||||
|
except: ok = True
|
||||||
|
assert ok or not res.good
|
||||||
|
|
||||||
|
ok = False
|
||||||
|
try: res = self.wallet[1].check_spend_proof(txid, message = 'bar', signature = signature)
|
||||||
|
except: ok = True
|
||||||
|
assert ok or not res.good
|
||||||
|
|
||||||
|
ok = False
|
||||||
|
try: res = self.wallet[1].check_spend_proof(txid, message = 'foo', signature = signature2)
|
||||||
|
except: ok = True
|
||||||
|
assert ok or not res.good
|
||||||
|
|
||||||
def check_reserve_proof(self):
|
def check_reserve_proof(self):
|
||||||
daemon = Daemon()
|
daemon = Daemon()
|
||||||
|
@ -622,6 +622,31 @@ class Wallet(object):
|
|||||||
}
|
}
|
||||||
return self.rpc.send_json_rpc_request(check_tx_proof)
|
return self.rpc.send_json_rpc_request(check_tx_proof)
|
||||||
|
|
||||||
|
def get_spend_proof(self, txid = '', message = ''):
|
||||||
|
get_spend_proof = {
|
||||||
|
'method': 'get_spend_proof',
|
||||||
|
'params' : {
|
||||||
|
'txid': txid,
|
||||||
|
'message': message,
|
||||||
|
},
|
||||||
|
'jsonrpc': '2.0',
|
||||||
|
'id': '0'
|
||||||
|
}
|
||||||
|
return self.rpc.send_json_rpc_request(get_spend_proof)
|
||||||
|
|
||||||
|
def check_spend_proof(self, txid = '', message = '', signature = ''):
|
||||||
|
check_spend_proof = {
|
||||||
|
'method': 'check_spend_proof',
|
||||||
|
'params' : {
|
||||||
|
'txid': txid,
|
||||||
|
'message': message,
|
||||||
|
'signature': signature,
|
||||||
|
},
|
||||||
|
'jsonrpc': '2.0',
|
||||||
|
'id': '0'
|
||||||
|
}
|
||||||
|
return self.rpc.send_json_rpc_request(check_spend_proof)
|
||||||
|
|
||||||
def get_reserve_proof(self, all_ = True, account_index = 0, amount = 0, message = ''):
|
def get_reserve_proof(self, all_ = True, account_index = 0, amount = 0, message = ''):
|
||||||
get_reserve_proof = {
|
get_reserve_proof = {
|
||||||
'method': 'get_reserve_proof',
|
'method': 'get_reserve_proof',
|
||||||
|
Loading…
Reference in New Issue
Block a user