2018-09-26 16:17:47 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Copyright (c) 2018 The Dash Core developers
|
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
from test_framework.mininode import *
|
2018-10-20 16:08:02 +02:00
|
|
|
from test_framework.test_framework import DashTestFramework
|
2018-09-26 16:17:47 +02:00
|
|
|
from test_framework.util import *
|
|
|
|
from time import *
|
|
|
|
|
|
|
|
'''
|
|
|
|
p2p-autoinstantsend.py
|
|
|
|
|
|
|
|
Test automatic InstantSend locks functionality.
|
|
|
|
|
|
|
|
Checks that simple transactions automatically become InstantSend locked,
|
|
|
|
complex transactions don't become IS-locked and this functionality is
|
2018-12-31 08:12:36 +01:00
|
|
|
activated only if SPORK_16_INSTANTSEND_AUTOLOCKS is active.
|
2018-09-26 16:17:47 +02:00
|
|
|
|
|
|
|
Also checks that this functionality doesn't influence regular InstantSend
|
|
|
|
transactions with high fee.
|
|
|
|
'''
|
|
|
|
|
2018-10-20 16:08:02 +02:00
|
|
|
class AutoInstantSendTest(DashTestFramework):
|
2018-09-26 16:17:47 +02:00
|
|
|
def __init__(self):
|
2019-03-15 09:48:24 +01:00
|
|
|
super().__init__(8, 5, [], fast_dip3_enforcement=True)
|
2018-09-26 16:17:47 +02:00
|
|
|
# set sender, receiver, isolated nodes
|
2019-03-15 09:48:24 +01:00
|
|
|
self.receiver_idx = 1
|
|
|
|
self.sender_idx = 2
|
2018-09-26 16:17:47 +02:00
|
|
|
|
|
|
|
def run_test(self):
|
2018-11-05 10:28:04 +01:00
|
|
|
# make sure masternodes are synced
|
|
|
|
sync_masternodes(self.nodes)
|
2019-03-03 11:30:34 +01:00
|
|
|
|
|
|
|
self.nodes[0].spork("SPORK_17_QUORUM_DKG_ENABLED", 0)
|
|
|
|
self.wait_for_sporks_same()
|
|
|
|
self.mine_quorum()
|
|
|
|
|
2019-03-11 14:32:26 +01:00
|
|
|
self.log.info("Test old InstantSend")
|
2019-03-03 11:30:34 +01:00
|
|
|
self.test_auto();
|
|
|
|
|
2019-03-04 13:33:34 +01:00
|
|
|
self.nodes[0].spork("SPORK_20_INSTANTSEND_LLMQ_BASED", 0)
|
2019-03-03 11:30:34 +01:00
|
|
|
self.wait_for_sporks_same()
|
|
|
|
|
2019-03-11 14:32:26 +01:00
|
|
|
self.log.info("Test new InstantSend")
|
2019-03-03 11:30:34 +01:00
|
|
|
self.test_auto(True);
|
|
|
|
|
|
|
|
def test_auto(self, new_is = False):
|
2019-03-18 14:50:44 +01:00
|
|
|
sender = self.nodes[self.sender_idx]
|
|
|
|
receiver = self.nodes[self.receiver_idx]
|
|
|
|
# feed the sender with some balance, make sure there are enough inputs
|
|
|
|
recipients = {}
|
|
|
|
for i in range(0, 30):
|
|
|
|
recipients[sender.getnewaddress()] = 1
|
|
|
|
# use a single transaction to not overload Travis with InstantSend
|
|
|
|
self.nodes[0].sendmany("", recipients)
|
|
|
|
|
2018-10-20 16:08:02 +02:00
|
|
|
# make sender funds mature for InstantSend
|
|
|
|
for i in range(0, 2):
|
|
|
|
set_mocktime(get_mocktime() + 1)
|
|
|
|
set_node_times(self.nodes, get_mocktime())
|
|
|
|
self.nodes[0].generate(1)
|
2019-03-18 14:50:44 +01:00
|
|
|
self.sync_all()
|
|
|
|
|
|
|
|
assert(not self.get_autois_spork_state(self.nodes[0]))
|
2018-09-26 16:17:47 +02:00
|
|
|
|
2019-03-18 14:50:44 +01:00
|
|
|
assert(self.send_regular_instantsend(sender, receiver, not new_is))
|
|
|
|
assert(self.send_simple_tx(sender, receiver) if new_is else not self.send_simple_tx(sender, receiver))
|
|
|
|
assert(self.send_complex_tx(sender, receiver) if new_is else not self.send_complex_tx(sender, receiver))
|
2018-09-26 16:17:47 +02:00
|
|
|
|
2019-03-18 14:50:44 +01:00
|
|
|
self.activate_autois_bip9(self.nodes[0])
|
|
|
|
self.set_autois_spork_state(self.nodes[0], True)
|
2018-09-26 16:17:47 +02:00
|
|
|
|
2019-03-18 14:50:44 +01:00
|
|
|
assert(self.get_autois_bip9_status(self.nodes[0]) == 'active')
|
|
|
|
assert(self.get_autois_spork_state(self.nodes[0]))
|
2018-09-26 16:17:47 +02:00
|
|
|
|
2019-03-18 14:50:44 +01:00
|
|
|
assert(self.send_regular_instantsend(sender, receiver, not new_is))
|
|
|
|
assert(self.send_simple_tx(sender, receiver))
|
|
|
|
assert(self.send_complex_tx(sender, receiver) if new_is else not self.send_complex_tx(sender, receiver))
|
2018-09-26 16:17:47 +02:00
|
|
|
|
2019-03-18 14:50:44 +01:00
|
|
|
self.set_autois_spork_state(self.nodes[0], False)
|
|
|
|
assert(not self.get_autois_spork_state(self.nodes[0]))
|
2018-10-15 13:59:57 +02:00
|
|
|
|
2019-03-18 14:50:44 +01:00
|
|
|
assert(self.send_regular_instantsend(sender, receiver, not new_is))
|
|
|
|
assert(self.send_simple_tx(sender, receiver) if new_is else not self.send_simple_tx(sender, receiver))
|
|
|
|
assert(self.send_complex_tx(sender, receiver) if new_is else not self.send_complex_tx(sender, receiver))
|
2018-10-15 13:59:57 +02:00
|
|
|
|
2019-03-18 14:50:44 +01:00
|
|
|
# mine all mempool txes
|
|
|
|
set_mocktime(get_mocktime() + 1)
|
|
|
|
set_node_times(self.nodes, get_mocktime())
|
|
|
|
self.nodes[0].generate(1)
|
|
|
|
self.sync_all()
|
2018-10-20 16:08:02 +02:00
|
|
|
|
2018-09-26 16:17:47 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
AutoInstantSendTest().main()
|