aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-03-25 20:49:09 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-04-11 11:08:17 +0000
commit798e3cad2ba923d61cbce95784ee7990bf20b3a0 (patch)
treefe50231b33d66010e413f126b6ef6819bbafc8a8 /tests
parentfunctional_tests: add alt chains tests (diff)
downloadmonero-798e3cad2ba923d61cbce95784ee7990bf20b3a0.tar.xz
functional_tests: add double spend detection tests
Diffstat (limited to 'tests')
-rwxr-xr-xtests/functional_tests/transfer.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/functional_tests/transfer.py b/tests/functional_tests/transfer.py
index d0c692157..050277c51 100755
--- a/tests/functional_tests/transfer.py
+++ b/tests/functional_tests/transfer.py
@@ -42,6 +42,7 @@ class TransferTest():
self.mine()
self.transfer()
self.check_get_bulk_payments()
+ self.check_double_spend_detection()
def create(self):
print 'Creating wallets'
@@ -509,5 +510,65 @@ class TransferTest():
res = self.wallet[2].get_bulk_payments(payment_ids = ['1'*64, '1234500000012345abcde00000abcdeff1234500000012345abcde00000abcde', '2'*64])
assert len(res.payments) >= 1 # one tx was sent
+ def check_double_spend_detection(self):
+ print('Checking double spend detection')
+ txes = [[None, None], [None, None]]
+ for i in range(2):
+ self.wallet[0].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')
+ self.wallet[0].refresh()
+ res = self.wallet[0].get_balance()
+ unlocked_balance = res.unlocked_balance
+ res = self.wallet[0].sweep_all(address = '44Kbx4sJ7JDRDV5aAhLJzQCjDz2ViLRduE3ijDZu3osWKBjMGkV1XPk4pfDUMqt1Aiezvephdqm6YD19GKFD9ZcXVUTp6BW', do_not_relay = True, get_tx_hex = True)
+ assert len(res.tx_hash_list) == 1
+ assert len(res.tx_hash_list[0]) == 32*2
+ txes[i][0] = res.tx_hash_list[0]
+ assert len(res.fee_list) == 1
+ assert res.fee_list[0] > 0
+ assert len(res.amount_list) == 1
+ assert res.amount_list[0] == unlocked_balance - res.fee_list[0]
+ assert len(res.tx_blob_list) > 0
+ assert len(res.tx_blob_list[0]) > 0
+ assert not 'tx_metadata_list' in res or len(res.tx_metadata_list) == 0
+ assert not 'multisig_txset' in res or len(res.multisig_txset) == 0
+ assert not 'unsigned_txset' in res or len(res.unsigned_txset) == 0
+ assert len(res.tx_blob_list) == 1
+ txes[i][1] = res.tx_blob_list[0]
+
+ daemon = Daemon()
+ res = daemon.send_raw_transaction(txes[0][1])
+ assert res.not_relayed == False
+ assert res.low_mixin == False
+ assert res.double_spend == False
+ assert res.invalid_input == False
+ assert res.invalid_output == False
+ assert res.too_big == False
+ assert res.overspend == False
+ assert res.fee_too_low == False
+ assert res.not_rct == False
+
+ res = daemon.get_transactions([txes[0][0]])
+ assert len(res.txs) >= 1
+ tx = [tx for tx in res.txs if tx.tx_hash == txes[0][0]][0]
+ assert tx.in_pool
+ assert not tx.double_spend_seen
+
+ res = daemon.send_raw_transaction(txes[1][1])
+ assert res.not_relayed == False
+ assert res.low_mixin == False
+ assert res.double_spend == True
+ assert res.invalid_input == False
+ assert res.invalid_output == False
+ assert res.too_big == False
+ assert res.overspend == False
+ assert res.fee_too_low == False
+ assert res.not_rct == False
+
+ res = daemon.get_transactions([txes[0][0]])
+ assert len(res.txs) >= 1
+ tx = [tx for tx in res.txs if tx.tx_hash == txes[0][0]][0]
+ assert tx.in_pool
+ assert tx.double_spend_seen
+
+
if __name__ == '__main__':
TransferTest().run_test()