<commit_before>#!/usr/bin/env python3
# Copyright (c) 2015-2020 The Dash Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

#
# Test deterministic masternodes
#
from test_framework.blocktools import create_block, create_coinbase, get_masternode_payment
from test_framework.messages import CTransaction, ToHex, FromHex, COIN, CTxOut
from test_framework.test_framework import SyscoinTestFramework
from test_framework.util import *
from test_framework.script import (
    CScript,
    OP_RETURN,
)
class Masternode(object):
    pass

class DIP3Test(SyscoinTestFramework):
    def set_test_params(self):
        self.num_initial_mn = 11 # Should be >= 11 to make sure quorums are not always the same MNs
        self.num_nodes = 1 + self.num_initial_mn + 2 # +1 for controller, +1 for mn-qt, +1 for mn created after dip3 activation
        self.setup_clean_chain = True

        self.extra_args = ["-sporkkey=<KEY>"]
        self.extra_args += ["-dip3params=150:150"]
        self.extra_args += ["-mncollateral=100"]
        self.extra_args += ["-segwitheight=150"]
        


    def setup_network(self):
        self.add_nodes(1)
        self.start_controller_node()

    def start_controller_node(self):
        self.log.info("starting controller node")
        self.start_node(0, extra_args=self.extra_args)
        for i in range(1, self.num_nodes):
            if i < len(self.nodes) and self.nodes[i] is not None and self.nodes[i].process is not None:
                connect_nodes(self.nodes[i], 0)

    def stop_controller_node(self):
        self.log.info("stopping controller node")
        self.stop_node(0)

    def restart_controller_node(self):
        self.stop_controller_node()
        self.start_controller_node()

    def run_test(self):
        self.log.info("funding controller node")
        while self.nodes[0].getbalance() < (self.num_initial_mn + 3) * 100:
            self.nodes[0].generatetoaddress(10, self.nodes[0].getnewaddress()) # generate enough for collaterals
        self.log.info("controller node has {} syscoin".format(self.nodes[0].getbalance()))

        # Make sure we're below block 135 (which activates dip3)
        self.log.info("testing rejection of ProTx before dip3 activation")
        assert(self.nodes[0].getblockchaininfo()['blocks'] < 135)

        mns = []

        # prepare mn which should still be accepted later when dip3 activates
        self.log.info("creating collateral for mn-before-dip3")
        before_dip3_mn = self.prepare_mn(self.nodes[0], 1, 'mn-before-dip3')
        self.create_mn_collateral(self.nodes[0], before_dip3_mn)
        mns.append(before_dip3_mn)

        # block 150 starts enforcing DIP3 MN payments
        self.nodes[0].generate(150 - self.nodes[0].getblockcount())
        assert(self.nodes[0].getblockcount() == 150)<commit_msg>use height 432<commit_after>#!/usr/bin/env python3
# Copyright (c) 2015-2020 The Dash Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

#
# Test deterministic masternodes
#
from test_framework.blocktools import create_block, create_coinbase, get_masternode_payment
from test_framework.messages import CTransaction, ToHex, FromHex, COIN, CTxOut
from test_framework.test_framework import SyscoinTestFramework
from test_framework.util import *
from test_framework.script import (
    CScript,
    OP_RETURN,
)
class Masternode(object):
    pass

class DIP3Test(SyscoinTestFramework):
    def set_test_params(self):
        self.num_initial_mn = 11 # Should be >= 11 to make sure quorums are not always the same MNs
        self.num_nodes = 1 + self.num_initial_mn + 2 # +1 for controller, +1 for mn-qt, +1 for mn created after dip3 activation
        self.setup_clean_chain = True

        self.extra_args = ["-sporkkey=<KEY>"]
        self.extra_args += ["-mncollateral=100"]
        


    def setup_network(self):
        self.add_nodes(1)
        self.start_controller_node()

    def start_controller_node(self):
        self.log.info("starting controller node")
        self.start_node(0, extra_args=self.extra_args)
        for i in range(1, self.num_nodes):
            if i < len(self.nodes) and self.nodes[i] is not None and self.nodes[i].process is not None:
                connect_nodes(self.nodes[i], 0)

    def stop_controller_node(self):
        self.log.info("stopping controller node")
        self.stop_node(0)

    def restart_controller_node(self):
        self.stop_controller_node()
        self.start_controller_node()

    def run_test(self):
        self.log.info("funding controller node")
        while self.nodes[0].getbalance() < (self.num_initial_mn + 3) * 100:
            self.nodes[0].generatetoaddress(10, self.nodes[0].getnewaddress()) # generate enough for collaterals
        self.log.info("controller node has {} syscoin".format(self.nodes[0].getbalance()))

        # Make sure we're below block 432 (which activates dip3)
        self.log.info("testing rejection of ProTx before dip3 activation")
        assert(self.nodes[0].getblockchaininfo()['blocks'] < 432)

        mns = []

        # prepare mn which should still be accepted later when dip3 activates
        self.log.info("creating collateral for mn-before-dip3")
        before_dip3_mn = self.prepare_mn(self.nodes[0], 1, 'mn-before-dip3')
        self.create_mn_collateral(self.nodes[0], before_dip3_mn)
        mns.append(before_dip3_mn)

        # block 432 starts enforcing DIP3 MN payments
        self.nodes[0].generate(432 - self.nodes[0].getblockcount())
        assert(self.nodes[0].getblockcount() == 432)
{'fraction_non_alphanumeric': 0.1058044274010807, 'fraction_numerical': 0.02632037650339899, 'mean_word_length': 3.304576144036009, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3423512', 'n_tokens_mistral': 1880, 'n_tokens_neox': 1734, 'n_words': 423}