2019-03-11 09:42:34 +01:00
|
|
|
#!/usr/bin/env python3
|
2020-01-17 15:42:55 +01:00
|
|
|
# Copyright (c) 2015-2020 The Dash Core developers
|
2019-03-11 09:42:34 +01:00
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2019-08-28 13:51:59 +02:00
|
|
|
import time
|
|
|
|
|
2019-03-11 09:42:34 +01:00
|
|
|
from test_framework.test_framework import DashTestFramework
|
|
|
|
from test_framework.util import *
|
|
|
|
|
|
|
|
'''
|
|
|
|
llmq-simplepose.py
|
|
|
|
|
|
|
|
Checks simple PoSe system based on LLMQ commitments
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
class LLMQSimplePoSeTest(DashTestFramework):
|
2019-09-24 00:57:30 +02:00
|
|
|
def set_test_params(self):
|
2019-12-05 19:28:33 +01:00
|
|
|
self.set_dash_test_params(6, 5, fast_dip3_enforcement=True)
|
2020-01-07 13:49:51 +01:00
|
|
|
self.set_dash_llmq_test_params(5, 3)
|
2019-03-11 09:42:34 +01:00
|
|
|
|
|
|
|
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):
|
2019-03-15 09:48:24 +01:00
|
|
|
self.mine_quorum()
|
2019-03-11 09:42:34 +01:00
|
|
|
for mn in self.mninfo:
|
2020-03-30 10:38:36 +02:00
|
|
|
assert(not self.check_punished(mn) and not self.check_banned(mn))
|
2019-03-11 09:42:34 +01:00
|
|
|
|
2020-03-30 10:44:09 +02:00
|
|
|
# Now lets isolate MNs one by one and verify that punishment/banning happens
|
2020-03-30 10:39:30 +02:00
|
|
|
online_mninfos = self.mninfo.copy()
|
|
|
|
for i in range(len(online_mninfos), len(online_mninfos) - 2, -1):
|
|
|
|
mn = online_mninfos[len(online_mninfos) - 1]
|
|
|
|
online_mninfos.remove(mn)
|
2020-03-30 10:44:09 +02:00
|
|
|
mn.node.setnetworkactive(False)
|
|
|
|
wait_until(lambda: mn.node.getconnectioncount() == 0)
|
2019-03-11 09:42:34 +01:00
|
|
|
|
2019-08-28 13:51:59 +02:00
|
|
|
t = time.time()
|
|
|
|
while (not self.check_punished(mn) or not self.check_banned(mn)) and (time.time() - t) < 120:
|
2020-03-30 10:39:30 +02:00
|
|
|
self.mine_quorum(expected_connections=1, expected_members=i-1, expected_contributions=i-1, expected_complaints=i-1, expected_commitments=i-1, mninfos=online_mninfos)
|
2019-03-11 09:42:34 +01:00
|
|
|
|
|
|
|
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()
|