Move simple PoSe tests into llmq-simplepose.py
These tend to fail quite often on Travis due to multiple reasons. One reason is that establishing intra quorum connections take some time and the tests in dip3-deterministicmns.py did not sleep long enough. Another reason is that the individual stages were not really checked for completion but instead just a hardcoded sleep was used. And another reason was that with a total of 13 MNs, it's not guaranteed that every DKG results in one MN to be punished.
This commit is contained in:
parent
6488135f46
commit
e21da2d99b
@ -46,6 +46,7 @@ BASE_SCRIPTS= [
|
||||
'multikeysporks.py',
|
||||
'llmq-signing.py', # NOTE: needs dash_hash to pass
|
||||
'llmq-chainlocks.py', # NOTE: needs dash_hash to pass
|
||||
'llmq-simplepose.py', # NOTE: needs dash_hash to pass
|
||||
# vv Tests less than 60s vv
|
||||
'sendheaders.py', # NOTE: needs dash_hash to pass
|
||||
'zapwallettxes.py',
|
||||
|
@ -194,48 +194,6 @@ class DIP3Test(BitcoinTestFramework):
|
||||
self.log.info("testing instant send with replaced MNs")
|
||||
self.test_instantsend(10, 3, timeout=20)
|
||||
|
||||
self.log.info("testing simple PoSe")
|
||||
self.assert_mnlists(mns)
|
||||
self.nodes[0].spork('SPORK_17_QUORUM_DKG_ENABLED', 0)
|
||||
self.wait_for_sporks()
|
||||
|
||||
height = self.nodes[0].getblockcount()
|
||||
skip_count = 24 - (height % 24)
|
||||
if skip_count != 0:
|
||||
self.nodes[0].generate(skip_count)
|
||||
|
||||
for i in range(len(mns), len(mns) - 2, -1):
|
||||
mn = mns[len(mns) - 1]
|
||||
mns.remove(mn)
|
||||
self.stop_node(mn.idx)
|
||||
self.nodes.remove(mn.node)
|
||||
|
||||
punished = False
|
||||
banned = False
|
||||
t = time.time()
|
||||
while (not punished or not banned) and (time.time() - t) < 120:
|
||||
# Init phase needs some time
|
||||
time.sleep(0.5)
|
||||
|
||||
# all phases
|
||||
for j in range(6):
|
||||
self.nodes[0].generate(2)
|
||||
self.sync_all()
|
||||
time.sleep(2)
|
||||
|
||||
info = self.nodes[0].protx('info', mn.protx_hash)
|
||||
if not punished:
|
||||
if info['state']['PoSePenalty'] > 0:
|
||||
punished = True
|
||||
if not banned:
|
||||
if info['state']['PoSeBanHeight'] != -1:
|
||||
banned = True
|
||||
|
||||
# Fast-forward to next DKG session
|
||||
self.nodes[0].generate(24 - (self.nodes[0].getblockcount() % 24))
|
||||
self.sync_all()
|
||||
assert(punished and banned)
|
||||
|
||||
def prepare_mn(self, node, idx, alias):
|
||||
mn = Masternode()
|
||||
mn.idx = idx
|
||||
|
58
qa/rpc-tests/llmq-simplepose.py
Executable file
58
qa/rpc-tests/llmq-simplepose.py
Executable file
@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2015-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.test_framework import DashTestFramework
|
||||
from test_framework.util import *
|
||||
from time import *
|
||||
|
||||
'''
|
||||
llmq-simplepose.py
|
||||
|
||||
Checks simple PoSe system based on LLMQ commitments
|
||||
|
||||
'''
|
||||
|
||||
class LLMQSimplePoSeTest(DashTestFramework):
|
||||
def __init__(self):
|
||||
super().__init__(11, 10, [], fast_dip3_enforcement=True)
|
||||
|
||||
def run_test(self):
|
||||
|
||||
self.nodes[0].spork("SPORK_17_QUORUM_DKG_ENABLED", 0)
|
||||
self.wait_for_sporks_same()
|
||||
|
||||
# check if mining quorums with all nodes being online succeeds without punishment/banning
|
||||
for i in range(3):
|
||||
self.mine_quorum(expected_valid_count=10)
|
||||
for mn in self.mninfo:
|
||||
assert(not self.check_punished(mn) and not self.check_punished(mn))
|
||||
|
||||
# Now lets kill MNs one by one and verify that punishment/banning happens
|
||||
for i in range(len(self.mninfo), len(self.mninfo) - 2, -1):
|
||||
mn = self.mninfo[len(self.mninfo) - 1]
|
||||
self.mninfo.remove(mn)
|
||||
self.stop_node(mn.nodeIdx)
|
||||
self.nodes.remove(mn.node)
|
||||
|
||||
t = time()
|
||||
while (not self.check_punished(mn) or not self.check_banned(mn)) and (time() - t) < 120:
|
||||
self.mine_quorum(expected_valid_count=i-1)
|
||||
|
||||
assert(self.check_punished(mn) and self.check_banned(mn))
|
||||
|
||||
def check_punished(self, mn):
|
||||
info = self.nodes[0].protx('info', mn.proTxHash)
|
||||
if info['state']['PoSePenalty'] > 0:
|
||||
return True
|
||||
return False
|
||||
|
||||
def check_banned(self, mn):
|
||||
info = self.nodes[0].protx('info', mn.proTxHash)
|
||||
if info['state']['PoSeBanHeight'] != -1:
|
||||
return True
|
||||
return False
|
||||
|
||||
if __name__ == '__main__':
|
||||
LLMQSimplePoSeTest().main()
|
Loading…
Reference in New Issue
Block a user