Ejemplo n.º 1
0
 def test_UV_NO_1(self, new_genesis_env, clients_consensus):
     update_setting_rate(new_genesis_env, 2, 2501)
     pip = clients_consensus[0].pip
     submitvpandvote([clients_consensus[0]])
     node_version = verifier_node_version(pip)
     proposalinfo = pip.get_effect_proposal_info_of_vote()
     log.info('Get version proposal infomation  {}'.format(proposalinfo))
     wait_block_number(pip.node, proposalinfo.get('EndVotingBlock'))
     verifier_node_version(pip, node_version)
     assert pip.get_accuverifiers_count(proposalinfo.get('ProposalID')) == [4, 1, 0, 0]
     assert pip.get_accu_verifiers_of_proposal(proposalinfo.get('ProposalID')) == len(clients_consensus)
     assert pip.get_yeas_of_proposal(proposalinfo.get('ProposalID')) == 1
     assert pip.get_nays_of_proposal(proposalinfo.get('ProposalID')) == 0
     assert pip.get_abstentions_of_proposal(proposalinfo.get('ProposalID')) == 0
     assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 3)
Ejemplo n.º 2
0
    def test_UV_UPG_2(self, new_genesis_env, clients_consensus, client_noconsensus):
        new_genesis_env.deploy_all()
        pip = clients_consensus[0].pip
        pip_test = client_noconsensus.pip
        address, _ = pip_test.economic.account.generate_account(pip_test.node.web3, 10 ** 18 * 10000000)
        result = client_noconsensus.staking.create_staking(0, address, address, amount=10 ** 18 * 2000000,
                                                           transaction_cfg=pip_test.cfg.transaction_cfg)
        log.info('Node {} staking result : {}'.format(pip_test.node.node_id, result))
        programversion = client_noconsensus.staking.get_version()
        assert_code(programversion, pip.cfg.version0)
        pip_test.economic.wait_settlement_blocknum(pip_test.node)
        verifier_list = get_pledge_list(clients_consensus[0].ppos.getVerifierList)
        log.info('Get verifier list : {}'.format(verifier_list))
        assert pip_test.node.node_id in verifier_list

        submitvpandvote(clients_consensus)
        programversion = clients_consensus[0].staking.get_version()
        assert_code(programversion, pip.cfg.version0)
        proposalinfo = pip.get_effect_proposal_info_of_vote()
        log.info('Get version proposal information : {}'.format(proposalinfo))
        replace_version_declare(pip_test, pip_test.cfg.PLATON_NEW_BIN, pip_test.cfg.version5)
        assert_code(result, 0)
        programversion = client_noconsensus.staking.get_version()
        assert_code(programversion, pip.cfg.version0)
        wait_block_number(pip.node, proposalinfo.get('EndVotingBlock'))
        verifier_node_version(pip, proposalinfo.get('NewVersion'))
        assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 4)
        validator_list = get_pledge_list(clients_consensus[0].ppos.getValidatorList)
        log.info('Validator list : {}'.format(validator_list))
        wait_block_number(pip.node, proposalinfo.get('ActiveBlock'))

        validator_list = get_pledge_list(clients_consensus[0].ppos.getValidatorList)
        log.info('Validator list : {}'.format(validator_list))
        assert pip_test.node.node_id in validator_list

        assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 5)
        pip.economic.wait_settlement_blocknum(pip.node)
        validator_list = get_pledge_list(clients_consensus[0].ppos.getValidatorList)
        log.info('Validator list : {}'.format(validator_list))
        assert pip_test.node.node_id in validator_list
        verifier_list = get_pledge_list(clients_consensus[0].ppos.getVerifierList)
        log.info('Get verifier list : {}'.format(verifier_list))
        assert pip_test.node.node_id in verifier_list
        programversion = clients_consensus[0].staking.get_version()
        assert_code(programversion, pip.cfg.version5)
        programversion = client_noconsensus.staking.get_version()
        assert_code(programversion, pip_test.cfg.version5)
Ejemplo n.º 3
0
 def test_UV_TR_001_004_to_008_011_to_017_VS_EP_001(self, new_genesis_env, clients_consensus):
     new_genesis_env.deploy_all()
     pip = clients_consensus[0].pip
     submitvpandvote(clients_consensus[:3])
     proposalinfo_version = pip.get_effect_proposal_info_of_vote()
     log.info('Get version proposal information {}'.format(proposalinfo_version))
     wait_block_number(pip.node, proposalinfo_version.get('ActiveBlock'))
     assert pip.get_status_of_proposal(proposalinfo_version.get('ProposalID')) == 5
     assert pip.chain_version == pip.cfg.version5
     assert pip.get_accuverifiers_count(proposalinfo_version.get('ProposalID')) == [4, 3, 0, 0]
     submittpandvote(clients_consensus[:2], 1, 2)
     submitcppandvote(clients_consensus[:2], [1, 2])
     proposalinfo_param = pip.get_effect_proposal_info_of_vote(pip.cfg.param_proposal)
     log.info('Get param proposal information {}'.format(proposalinfo_param))
     result = pip.vote(pip.node.node_id, proposalinfo_param.get('ProposalID'), pip.cfg.vote_option_yeas,
                       pip.node.staking_address, transaction_cfg=pip.cfg.transaction_cfg)
     log.info('Vote param proposal result : {}'.format(result))
     assert_code(result, 0)
     result = replace_version_declare(pip, pip.cfg.PLATON_NEW_BIN0, pip.cfg.version0)
     assert_code(result, 302028)
     result = replace_version_declare(pip, pip.cfg.PLATON_NEW_BIN, pip.cfg.version5)
     assert_code(result, 0)
     verifier_node_version(pip, pip.cfg.version5)
     result = replace_version_declare(pip, pip.cfg.PLATON_NEW_BIN4, pip.cfg.version4)
     assert_code(result, 0)
     verifier_node_version(pip, pip.cfg.version4)
     result = replace_version_declare(pip, pip.cfg.PLATON_NEW_BIN6, pip.cfg.version6)
     assert_code(result, 0)
     verifier_node_version(pip, pip.cfg.version6)
     result = pip.pip.listProposal()
     log.info('Interface listProposal result : {}'.format(result))
     assert_code(result, 0)
     result = pip.pip.getProposal(proposalinfo_version.get('ProposalID'))
     log.info('Interface getProposal result : {}'.format(result))
     assert_code(result, 0)
Ejemplo n.º 4
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,
                               2,
                               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)