Exemple #1
0
    def test_VO_TER_001_003_005(self, candidate_has_proposal, client_verifier):
        pip = candidate_has_proposal
        pip_test = client_verifier.pip
        proposalinfo_version = pip_test.get_effect_proposal_info_of_vote()
        log.info('Get proposal information :{}'.format(proposalinfo_version))
        result = pip_test.submitCancel(
            pip_test.node.node_id,
            str(time.time()),
            1,
            proposalinfo_version.get('ProposalID'),
            pip_test.node.staking_address,
            transaction_cfg=pip_test.cfg.transaction_cfg)
        log.info('Submit cancel proposal result : {}'.format(result))
        assert_code(result, 0)
        result = pip_test.submitText(
            pip_test.node.node_id,
            str(time.time()),
            pip_test.node.staking_address,
            transaction_cfg=pip_test.cfg.transaction_cfg)
        log.info('Submit text proposal result : {}'.format(result))
        assert_code(result, 0)
        result = version_proposal_vote(pip)
        log.info('Candidate node {} vote version proposal result : {}'.format(
            pip.node.node_id, result))
        assert_code(result, 302022)

        result = proposal_vote(pip, proposaltype=pip.cfg.cancel_proposal)
        log.info('Candidate node {} vote cancel proposal result : {}'.format(
            pip.node.node_id, result))
        assert_code(result, 302022)

        result = proposal_vote(pip, proposaltype=pip.cfg.text_proposal)
        log.info('Candidate node {} vote text proposal result : {}'.format(
            pip.node.node_id, result))
        assert_code(result, 302022)
Exemple #2
0
    def test_V_STA_2_to_5(self, no_vp_proposal, clients_verifier):
        pip = no_vp_proposal
        value = len(clients_verifier) - 2
        submitvpandvote(clients_verifier[:value], votingrounds=4)
        proposalinfo = pip.get_effect_proposal_info_of_vote()
        log.info('Get version proposal information : {}'.format(proposalinfo))
        result = version_proposal_vote(clients_verifier[-2].pip)
        log.info('Node {} vote proposal result : {}'.format(
            clients_verifier[-1].node.node_id, result))
        assert_code(result, 0)
        wait_block_number(pip.node, proposalinfo.get('EndVotingBlock'))
        log.info('{}'.format(
            pip.pip.getTallyResult(proposalinfo.get('ProposalID'))))
        assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')),
                    4)

        pip = clients_verifier[-1].pip
        upload_platon(pip.node, pip.cfg.PLATON_NEW_BIN)
        pip.node.restart()
        log.info('Replace the platon bin and restart the node {}'.format(
            pip.node.node_id))
        result = pip.vote(pip.node.node_id,
                          proposalinfo.get('ProposalID'),
                          pip.cfg.vote_option_yeas,
                          pip.node.staking_address,
                          transaction_cfg=pip.cfg.transaction_cfg)
        log.info('Node {} vote proposal result : {}'.format(
            clients_verifier[-1].node.node_id, result))
        assert_code(result, 302026)
        log.info('{}'.format(
            pip.pip.getTallyResult(proposalinfo.get('ProposalID'))))

        if pip.node.eth.blockNumber < pip.get_status_of_proposal(
                proposalinfo.get('ProposalID')):
            assert_code(
                pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 4)
        assert pip.get_status_of_proposal(
            proposalinfo.get('ProposalID')) == 4 or 5

        result = pip.vote(pip.node.node_id,
                          proposalinfo.get('ProposalID'),
                          pip.cfg.vote_option_yeas,
                          pip.node.staking_address,
                          transaction_cfg=pip.cfg.transaction_cfg)
        log.info('Node {} vote proposal result : {}'.format(
            clients_verifier[-1].node.node_id, result))
        assert_code(result, 302026)
        wait_block_number(pip.node, proposalinfo.get('ActiveBlock'))
        assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')),
                    5)
Exemple #3
0
 def test_VO_TER_003_VO_TER_007_VO_TER_005_PP_VO_013(
         self, no_vp_proposal, client_candidate, client_verifier):
     ca_pip = client_candidate.pip
     ve_pip = client_verifier.pip
     submittpandvote([client_verifier], 2)
     submitvpandvote([client_verifier], votingrounds=1)
     proposalinfo_version = ve_pip.get_effect_proposal_info_of_vote()
     log.info(
         'Version proposal information {}'.format(proposalinfo_version))
     result = version_proposal_vote(ca_pip)
     assert_code(result, 302022)
     result = proposal_vote(ca_pip, proposaltype=ca_pip.cfg.text_proposal)
     assert_code(result, 302022)
     wait_block_number(ca_pip.node,
                       proposalinfo_version.get('EndVotingBlock'))
     submitcppandvote([client_verifier], [2])
     result = proposal_vote(ca_pip, proposaltype=ca_pip.cfg.param_proposal)
     assert_code(result, 302022)
     result = proposal_vote(ca_pip, proposaltype=ca_pip.cfg.cancel_proposal)
     assert_code(result, 302022)
    def test_AC_IN_001_002_004_to_006_012_to_014(self, new_genesis_env,
                                                 clients_consensus):
        # genesis = from_dict(data_class=Genesis, data=new_genesis_env.genesis_config)
        # genesis.economicModel.slashing.maxEvidenceAge = 1
        # new_genesis_env.set_genesis(genesis.to_dict())
        new_genesis_env.deploy_all()
        pip = clients_consensus[-1].pip
        result = pip.submitVersion(pip.node.node_id,
                                   str(time.time()),
                                   pip.cfg.version5,
                                   12,
                                   pip.node.staking_address,
                                   transaction_cfg=pip.cfg.transaction_cfg)
        log.info('Submit version proposal result : {}'.format(result))
        assert_code(result, 0)
        proposalinfo_version = pip.get_effect_proposal_info_of_vote()
        log.info('Get version proposal information : {}'.format(
            proposalinfo_version))

        result = pip.submitCancel(pip.node.node_id,
                                  str(time.time()),
                                  10,
                                  proposalinfo_version.get('ProposalID'),
                                  pip.node.staking_address,
                                  transaction_cfg=pip.cfg.transaction_cfg)
        log.info('Submit cancel proposal result : {}'.format(result))
        assert_code(result, 0)
        proposalinfo_cancel = pip.get_effect_proposal_info_of_vote(
            pip.cfg.cancel_proposal)
        log.info('Get cancel proposal information : {}'.format(
            proposalinfo_version))

        for index in range(3):
            log.info(f'index == {index}')
            client = clients_consensus[index]
            result = version_proposal_vote(client.pip)
            assert_code(result, 0)
            result = client.pip.vote(client.node.node_id,
                                     proposalinfo_cancel.get('ProposalID'),
                                     index + 1,
                                     client.node.staking_address,
                                     transaction_cfg=pip.cfg.transaction_cfg)
            log.info('Node {} vote cancel proposal result : {}'.format(
                client.node.node_id, result))
            assert_code(result, 0)
        log.info(f'blocknumber0000 == {pip.node.block_number}')
        log.info(f'getCandidateList == {pip.node.ppos.getCandidateList()}')
        assert pip.get_accuverifiers_count(
            proposalinfo_version.get('ProposalID')) == [4, 3, 0, 0]
        assert pip.get_accuverifiers_count(
            proposalinfo_cancel.get('ProposalID')) == [4, 1, 1, 1]
        log.info('Stop the node {}'.format(clients_consensus[0].node.node_id))
        clients_consensus[0].node.stop()
        pip.economic.wait_consensus(pip.node, 2)
        log.info(pip.node.debug.getWaitSlashingNodeList())
        log.info(pip.pip.listGovernParam())
        log.info(clients_consensus[1].ppos.getCandidateInfo(
            pip.node.node_id, pip.node.staking_address))
        assert pip.get_accuverifiers_count(
            proposalinfo_version.get('ProposalID')) == [4, 3, 0, 0]
        assert pip.get_accuverifiers_count(
            proposalinfo_cancel.get('ProposalID')) == [4, 1, 1, 1]

        log.info(f'blocknumber1111 == {pip.node.block_number}')
        report_information = mock_duplicate_sign(
            1, clients_consensus[1].node.nodekey,
            clients_consensus[1].node.blsprikey, 41)
        log.info("Report information: {}".format(report_information))
        address, _ = pip.economic.account.generate_account(
            pip.node.web3, 10**18 * 1000)
        result = clients_consensus[-1].duplicatesign.reportDuplicateSign(
            1, report_information, address)
        log.info('Node duplicate block result : {}'.format(result))
        assert_code(result, 0)
        log.info(f'blocknumber2222 == {pip.node.block_number}')
        assert pip.get_accuverifiers_count(
            proposalinfo_version.get('ProposalID')) == [4, 2, 0, 0]
        assert pip.get_accuverifiers_count(
            proposalinfo_cancel.get('ProposalID')) == [4, 1, 0, 1]

        report_information = mock_duplicate_sign(
            2, clients_consensus[2].node.nodekey,
            clients_consensus[2].node.blsprikey, 41)
        log.info("Report information: {}".format(report_information))
        address, _ = pip.economic.account.generate_account(
            pip.node.web3, 10**18 * 1000)
        result = clients_consensus[-1].duplicatesign.reportDuplicateSign(
            2, report_information, address)
        log.info('Node duplicate block result : {}'.format(result))
        assert_code(result, 0)
        assert pip.get_accuverifiers_count(
            proposalinfo_version.get('ProposalID')) == [4, 1, 0, 0]
        assert pip.get_accuverifiers_count(
            proposalinfo_cancel.get('ProposalID')) == [4, 1, 0, 0]
Exemple #5
0
    def test_VO_VE_001_002_VO_CA_001_002_VO_TER_002_VO_TER_004(
            self, new_genesis_env, clients_consensus, client_noconsensus):
        pip = clients_consensus[0].pip
        genesis = from_dict(data_class=Genesis,
                            data=new_genesis_env.genesis_config)
        genesis.economicModel.gov.versionProposalVoteDurationSeconds = 3200
        genesis.economicModel.staking.unStakeFreezeDuration = 2
        new_genesis_env.set_genesis(genesis.to_dict())
        new_genesis_env.deploy_all()
        result = pip.submitVersion(pip.node.node_id,
                                   str(time.time()),
                                   pip.cfg.version5,
                                   20,
                                   pip.node.staking_address,
                                   transaction_cfg=pip.cfg.transaction_cfg)
        log.info('Submit version proposal information : {}'.format(result))
        assert_code(result, 0)
        proposalinfo_version = pip.get_effect_proposal_info_of_vote(
            pip.cfg.version_proposal)
        log.info(
            'Get param proposal information : {}'.format(proposalinfo_version))

        result = pip.submitCancel(pip.node.node_id,
                                  str(time.time()),
                                  10,
                                  proposalinfo_version.get('ProposalID'),
                                  pip.node.staking_address,
                                  transaction_cfg=pip.cfg.transaction_cfg)
        log.info('Submit cancel proposal information : {}'.format(result))
        assert_code(result, 0)
        proposalinfo_cancel = pip.get_effect_proposal_info_of_vote(
            pip.cfg.cancel_proposal)
        log.info(
            'Get cancel proposal information : {}'.format(proposalinfo_cancel))

        result = clients_consensus[0].staking.withdrew_staking(
            clients_consensus[0].node.staking_address)
        log.info('Node {} withdrew staking result {}'.format(
            clients_consensus[0].node.node_id, result))
        assert_code(result, 0)
        address = clients_consensus[0].node.staking_address

        result = version_proposal_vote(pip)
        log.info('node vote version proposal result {}'.format(result))
        assert_code(result, 302020)

        result = proposal_vote(pip, proposaltype=pip.cfg.cancel_proposal)
        log.info('node vote cancel proposal result {}'.format(result))
        assert_code(result, 302020)

        address_test, _ = pip.economic.account.generate_account(
            pip.node.web3, 10**18 * 100000)
        result = client_noconsensus.pip.vote(
            client_noconsensus.node.node_id,
            proposalinfo_version.get('ProposalID'),
            pip.cfg.vote_option_yeas,
            address_test,
            transaction_cfg=pip.cfg.transaction_cfg)
        log.info('node {} vote param proposal result {}'.format(
            client_noconsensus.node.node_id, result))
        assert_code(result, 302022)

        result = client_noconsensus.pip.vote(
            client_noconsensus.node.node_id,
            proposalinfo_cancel.get('ProposalID'),
            pip.cfg.vote_option_yeas,
            address_test,
            transaction_cfg=pip.cfg.transaction_cfg)
        log.info('node {} vote cancel proposal result {}'.format(
            client_noconsensus.node.node_id, result))
        assert_code(result, 302022)

        pip.economic.wait_settlement(pip.node,
                                     pip.economic.unstaking_freeze_ratio)
        result = pip.vote(pip.node.node_id,
                          proposalinfo_version.get('ProposalID'),
                          pip.cfg.vote_option_yeas,
                          address,
                          transaction_cfg=pip.cfg.transaction_cfg)
        log.info('Exited node vote version proposal result {}'.format(result))
        assert_code(result, 302022)

        result = pip.vote(pip.node.node_id,
                          proposalinfo_cancel.get('ProposalID'),
                          pip.cfg.vote_option_nays,
                          address,
                          transaction_cfg=pip.cfg.transaction_cfg)
        log.info('Exited node vote cancel proposal result {}'.format(result))
        assert_code(result, 302022)
Exemple #6
0
def test_VO_VO_001_V0_RE_001_V0_WA_001_V_STA_1_VO_OP_001_VO_OP_002(
        no_vp_proposal):
    pip = no_vp_proposal
    result = pip.submitVersion(pip.node.node_id,
                               str(time.time()),
                               pip.cfg.version8,
                               3,
                               pip.node.staking_address,
                               transaction_cfg=pip.cfg.transaction_cfg)
    log.info('Submit version proposal result : {}'.format(result))
    assert_code(result, 0)
    proposalinfo = pip.get_effect_proposal_info_of_vote()
    log.info('Get version proposalinfo {}'.format(proposalinfo))

    upload_platon(pip.node, pip.cfg.PLATON_NEW_BIN)
    log.info('Replace the node platon package to {}'.format(pip.cfg.version5))
    pip.node.restart()
    log.info('Restart the node {}'.format(pip.node.node_id))
    address, _ = pip.economic.account.generate_account(pip.node.web3,
                                                       10**18 * 10000)
    result = pip.vote(pip.node.node_id,
                      proposalinfo.get('ProposalID'),
                      pip.cfg.vote_option_yeas,
                      address,
                      transaction_cfg=pip.cfg.transaction_cfg)
    log.info('Not staking address vote result : {}'.format(result))
    assert_code(result, 302021)

    result = pip.vote(pip.node.node_id,
                      proposalinfo.get('ProposalID'),
                      pip.cfg.vote_option_nays,
                      pip.node.staking_address,
                      transaction_cfg=pip.cfg.transaction_cfg)
    log.info('vote option {} result {}'.format(pip.cfg.vote_option_nays,
                                               result))
    assert_code(result, 302002)

    result = pip.vote(pip.node.node_id,
                      proposalinfo.get('ProposalID'),
                      pip.cfg.vote_option_Abstentions,
                      pip.node.staking_address,
                      transaction_cfg=pip.cfg.transaction_cfg)
    log.info('vote option {} result {}'.format(pip.cfg.vote_option_Abstentions,
                                               result))
    assert_code(result, 302002)

    result = pip.vote(pip.node.node_id,
                      proposalinfo.get('ProposalID'),
                      0,
                      pip.node.staking_address,
                      transaction_cfg=pip.cfg.transaction_cfg)
    log.info('vote option {} result {}'.format(0, result))
    assert_code(result, 302002)

    result = pip.vote(pip.node.node_id,
                      proposalinfo.get('ProposalID'),
                      'a',
                      pip.node.staking_address,
                      transaction_cfg=pip.cfg.transaction_cfg)
    log.info('vote option {} result {}'.format(pip.cfg.vote_option_nays,
                                               result))
    assert_code(result, 302002)

    address, _ = pip.economic.account.generate_account(pip.node.web3,
                                                       10**18 * 10000)
    result = pip.vote(pip.node.node_id,
                      proposalinfo.get('ProposalID'),
                      pip.cfg.vote_option_yeas,
                      address,
                      transaction_cfg=pip.cfg.transaction_cfg)
    assert_code(result, 302021)

    node_version = verifier_node_version(pip)
    result = version_proposal_vote(pip)
    assert_code(result, 0)
    verifier_node_version(pip, node_version)

    result = pip.vote(pip.node.node_id,
                      proposalinfo.get('ProposalID'),
                      pip.cfg.vote_option_yeas,
                      pip.node.staking_address,
                      transaction_cfg=pip.cfg.transaction_cfg)
    log.info('vote duplicated result: {}'.format(result))
    assert_code(result, 302027)

    wait_block_number(pip.node, proposalinfo.get('EndVotingBlock'))
    result = pip.vote(pip.node.node_id,
                      proposalinfo.get('ProposalID'),
                      pip.cfg.vote_option_yeas,
                      pip.node.staking_address,
                      transaction_cfg=pip.cfg.transaction_cfg)
    log.info('endblock vote result: {}'.format(result))
    assert_code(result, 302026)