Esempio n. 1
0
    def test_TR_IN_011_TR_IN_012(self, new_genesis_env, clients_consensus):
        genesis = from_dict(data_class=Genesis, data=new_genesis_env.genesis_config)
        genesis.economicModel.gov.paramProposalVoteDurationSeconds = 0
        new_genesis_env.set_genesis(genesis.to_dict())
        new_genesis_env.deploy_all()
        pip = clients_consensus[0].pip
        submitcppandvote(clients_consensus, [1, 1, 1, 3])
        proposalinfo_param = pip.get_effect_proposal_info_of_vote(pip.cfg.param_proposal)
        log.info('Param proposal information {}'.format(proposalinfo_param))
        proposalinfo_cancel = pip.get_effect_proposal_info_of_vote(pip.cfg.cancel_proposal)
        log.info('Cancel proposal information {}'.format(proposalinfo_cancel))

        wait_block_number(pip.node, proposalinfo_cancel.get('EndVotingBlock'))

        assert pip.get_canceledby_of_proposal(proposalinfo_cancel.get('ProposalID')) == cancelby
        assert pip.get_canceledby_of_proposal(proposalinfo_param.get('ProposalID')) == proposalinfo_cancel.get('ProposalID')

        assert pip.get_status_of_proposal(proposalinfo_cancel.get('ProposalID')) == 2
        assert pip.get_yeas_of_proposal(proposalinfo_cancel.get('ProposalID')) == 3
        assert pip.get_nays_of_proposal(proposalinfo_cancel.get('ProposalID')) == 0
        assert pip.get_abstentions_of_proposal(proposalinfo_cancel.get('ProposalID')) == 1
        assert pip.get_accu_verifiers_of_proposal(proposalinfo_cancel.get('ProposalID')) == len(clients_consensus)

        assert pip.get_status_of_proposal(proposalinfo_param.get('ProposalID')) == 6
        assert pip.get_yeas_of_proposal(proposalinfo_param.get('ProposalID')) == 0
        assert pip.get_nays_of_proposal(proposalinfo_param.get('ProposalID')) == 0
        assert pip.get_abstentions_of_proposal(proposalinfo_param.get('ProposalID')) == 0
        assert pip.get_accu_verifiers_of_proposal(proposalinfo_param.get('ProposalID')) == len(clients_consensus)
Esempio n. 2
0
def preactive_bv_proposal_pipobj_list(global_test_env, client_list_obj):
    if client_list_obj[0].pip.is_exist_effective_proposal() or client_list_obj[0].pip.chain_version != \
            client_list_obj[0].pip.cfg.version0:
        log.info('There is effective version proposal, restart the chain')
        global_test_env.deploy_all()
    verifier_list = get_pledge_list(client_list_obj[0].ppos.getVerifierList)
    log.info('verifierlist :{}'.format(verifier_list))
    client_verifier_list_obj = get_client_obj_list(verifier_list,
                                                   client_list_obj)
    pip_list_obj = [client_obj.pip for client_obj in client_verifier_list_obj]
    result = pip_list_obj[0].submitVersion(
        pip_list_obj[0].node.node_id,
        str(time.time_ns()),
        pip_list_obj[0].cfg.version8,
        2,
        pip_list_obj[0].node.staking_address,
        transaction_cfg=pip_list_obj[0].cfg.transaction_cfg)
    log.info('submit version proposal, result : {}'.format(result))
    proposalinfo = pip_list_obj[0].get_effect_proposal_info_of_vote()
    log.info('Version proposalinfo: {}'.format(proposalinfo))
    for pip_obj in pip_list_obj:
        result = version_proposal_vote(pip_obj)
        assert_code(result, 0)
    wait_block_number(pip_obj.node, proposalinfo.get('EndVotingBlock'))
    assert pip_obj.get_status_of_proposal(proposalinfo.get('ProposalID')) == 4
    return pip_list_obj
Esempio n. 3
0
    def test_TR_IN_010_005(self, new_genesis_env, clients_consensus):
        genesis = from_dict(data_class=Genesis,
                            data=new_genesis_env.genesis_config)
        genesis.economicModel.gov.paramProposalVoteDurationSeconds = 0
        new_genesis_env.set_genesis(genesis.to_dict())
        new_genesis_env.deploy_all()
        pip = clients_consensus[0].pip
        submitppandvote(clients_consensus[0:-1], 1, 2, 3)
        proposalinfo = clients_consensus[
            0].pip.get_effect_proposal_info_of_vote(
                clients_consensus[0].pip.cfg.param_proposal)
        log.info('Param proposal information {}'.format(proposalinfo))
        log.info('listparam {}'.format(
            clients_consensus[0].pip.pip.listGovernParam()))
        result = pip.pip.getTallyResult(proposalinfo.get('ProposalID'))
        log.info('Interface getTallyResult info : {}'.format(result))
        assert_code(result, 302030)
        wait_block_number(pip.node, proposalinfo.get('EndVotingBlock'))

        assert pip.get_canceledby_of_proposal(
            proposalinfo.get('ProposalID')) == cancelby
        assert pip.get_status_of_proposal(proposalinfo.get('ProposalID')) == 3
        assert pip.get_yeas_of_proposal(proposalinfo.get('ProposalID')) == 1
        assert pip.get_nays_of_proposal(proposalinfo.get('ProposalID')) == 1
        assert pip.get_abstentions_of_proposal(
            proposalinfo.get('ProposalID')) == 1
        assert pip.get_accu_verifiers_of_proposal(
            proposalinfo.get('ProposalID')) == len(clients_consensus)
Esempio n. 4
0
def preactive_proposal_pips(all_clients):
    if all_clients[0].pip.is_exist_effective_proposal() or all_clients[0].pip.chain_version != \
            all_clients[0].pip.cfg.version0 or all_clients[0].pip.is_exist_effective_proposal_for_vote(
        all_clients[0].pip.cfg.param_proposal
    ):
        log.info('There is effective version proposal, restart the chain')
        all_clients[0].economic.env.deploy_all()
    verifier_list = get_pledge_list(all_clients[0].ppos.getVerifierList)
    log.info('verifierlist :{}'.format(verifier_list))
    client_verifiers = get_clients_by_nodeid(verifier_list, all_clients)
    pips = [client_verifier.pip for client_verifier in client_verifiers]
    log.info('pips :{}'.format(pips))
    result = pips[0].submitVersion(pips[0].node.node_id,
                                   str(time.time()),
                                   pips[0].cfg.version5,
                                   8,
                                   pips[0].node.staking_address,
                                   transaction_cfg=pips[0].cfg.transaction_cfg)
    log.info('submit version proposal, result : {}'.format(result))
    proposalinfo = pips[0].get_effect_proposal_info_of_vote()
    log.info('Version proposalinfo: {}'.format(proposalinfo))
    for pip in pips:
        result = version_proposal_vote(pip)
        assert_code(result, 0)
    wait_block_number(pips[0].node, proposalinfo.get('EndVotingBlock'))
    assert pips[0].get_status_of_proposal(proposalinfo.get('ProposalID')) == 4
    return pips
Esempio n. 5
0
 def test_VE_AD_003(self, new_genesis_env, clients_consensus, all_clients):
     submitvpandvote(clients_consensus)
     proposalinfo = clients_consensus[
         0].pip.get_effect_proposal_info_of_vote()
     log.info('Get version proposal information : {}'.format(proposalinfo))
     wait_block_number(clients_consensus[0].node,
                       proposalinfo.get('ActiveBlock'))
     consensus_node = new_genesis_env.get_rand_node()
     test_node = new_genesis_env.get_a_normal_node()
     test_node.clean()
     test_node.deploy_me(new_genesis_env.cfg.genesis_tmp)
     test_node.admin.addPeer(consensus_node.enode)
     time.sleep(5)
     assert test_node.web3.net.peerCount > 0, 'Join the chain failed'
     assert test_node.block_number > 0, "Non-consensus node sync block failed, block height: {}".format(
         test_node.block_number)
     time.sleep(5)
     client = get_client_by_nodeid(test_node.node_id, all_clients)
     address, _ = client.economic.account.generate_account(
         client.node.web3, 10**18 * 10000000)
     result = client.staking.create_staking(0, address, address)
     assert_code(result, 301004)
     upload_platon(test_node, client.pip.cfg.PLATON_NEW_BIN)
     test_node.restart()
     result = client.staking.create_staking(0, address, address)
     assert_code(result, 0)
Esempio n. 6
0
    def test_UV_TR_002_003_009_010(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'))

        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_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()), 1, 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 version proposal information : {}'.format(proposalinfo_cancel))

        upload_platon(pip.node, pip.cfg.PLATON_NEW_BIN8)
        pip.node.restart()

        result = pip.vote(pip.node.node_id, proposalinfo_version.get('ProposalID'), pip.cfg.vote_option_yeas,
                          pip.node.staking_address, transaction_cfg=pip.cfg.transaction_cfg)
        log.info('Vote result : {}'.format(result))
        assert_code(result, 0)
        result = pip.vote(pip.node.node_id, proposalinfo_cancel.get('ProposalID'), pip.cfg.vote_option_yeas,
                          pip.node.staking_address, transaction_cfg=pip.cfg.transaction_cfg)
        assert_code(result, 0)
        log.info('Node {} vote result : {}'.format(pip.node.node_id, result))
Esempio n. 7
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)
Esempio n. 8
0
def test_PP_VO_003_PP_VO_004_VS_EP_002_VS_EP_003(new_genesis_env, client_con_list_obj):
    genesis = from_dict(data_class=Genesis, data=new_genesis_env.genesis_config)
    genesis.economicModel.gov.paramProposalVoteDurationSeconds = 0
    new_genesis_env.set_genesis(genesis.to_dict())
    new_genesis_env.deploy_all()
    pip_obj = client_con_list_obj[0].pip
    result = pip_obj.submitParam(pip_obj.node.node_id, str(time.time()), 'slashing', 'slashBlocksReward', '123',
                                 pip_obj.node.staking_address, transaction_cfg=pip_obj.cfg.transaction_cfg)
    log.info('Submit param proposal result : {}'.format(result))
    assert_code(result, 0)
    proposalinfo = pip_obj.get_effect_proposal_info_of_vote(pip_obj.cfg.param_proposal)
    log.info('param proposal info {}'.format(proposalinfo))
    wait_block_number(pip_obj.node, proposalinfo.get('EndVotingBlock') - 10)
    result = proposal_vote(pip_obj)
    assert_code(result, 0)
    result = pip_obj.pip.getTallyResult(proposalinfo.get('ProposalID'))
    log.info('Interface getTallyResult result is {}'.format(result))
    assert_code(result, 302030)
    wait_block_number(pip_obj.node, proposalinfo.get('EndVotingBlock'))
    result = pip_obj.vote(pip_obj.node.node_id, proposalinfo.get('ProposalID'), pip_obj.cfg.vote_option_yeas,
                          pip_obj.node.staking_address, transaction_cfg=pip_obj.cfg.transaction_cfg)
    log.info('Node {} vote param proposal result : {}'.format(pip_obj.node.node_id, result))
    result = pip_obj.pip.getTallyResult(proposalinfo.get('ProposalID'))
    log.info('Interface getTallyResult result is {}'.format(result))
    assert_code(result, 0)
Esempio n. 9
0
 def test_PP_VO_009_PP_VO_010_V0_TE_001_V0_TE_002(self, submit_param, client_list_obj):
     pip_obj = submit_param
     result = pip_obj.submitText(pip_obj.node.node_id, str(time.time()), pip_obj.node.staking_address,
                                 transaction_cfg=pip_obj.cfg.transaction_cfg)
     log.info('Submit text proposal result : {}'.format(result))
     assert_code(result, 0)
     address = pip_obj.node.staking_address
     client_obj = get_client_obj(pip_obj.node.node_id, client_list_obj)
     result = client_obj.staking.withdrew_staking(pip_obj.node.staking_address)
     endblock = get_refund_to_account_block(pip_obj)
     log.info('Node {} withdrew staking result {}'.format(pip_obj.node.node_id, result))
     assert_code(result, 0)
     proposalinfo = pip_obj.get_effect_proposal_info_of_vote(pip_obj.cfg.param_proposal)
     log.info('Cancel proposal info : {}'.format(proposalinfo))
     proposalinfo_text = pip_obj.get_effect_proposal_info_of_vote(pip_obj.cfg.param_proposal)
     log.info('Text proposal info : {}'.format(proposalinfo_text))
     result = proposal_vote(pip_obj)
     assert_code(result, 302020)
     result = proposal_vote(pip_obj, proposaltype=pip_obj.cfg.text_proposal)
     assert_code(result, 302020)
     wait_block_number(pip_obj.node, endblock)
     result = pip_obj.vote(pip_obj.node.node_id, proposalinfo.get('ProposalID'), pip_obj.cfg.vote_option_nays, address,
                           transaction_cfg=pip_obj.cfg.transaction_cfg)
     assert_code(result, 302022)
     result = pip_obj.vote(pip_obj.node.node_id, proposalinfo_text.get('ProposalID'), pip_obj.cfg.vote_option_yeas,
                           address, transaction_cfg=pip_obj.cfg.transaction_cfg)
     assert_code(result, 302022)
Esempio n. 10
0
    def test_2(self, new_genesis_env, clients_consensus):
        new_genesis_env.deploy_all()
        pip = clients_consensus[0].pip
        submitvpandvote(clients_consensus[0:2])
        # replace_version_declare(pip, pip.cfg.PLATON_NEW_BIN, pip.cfg.version5)
        proposalinfo = pip.get_effect_proposal_info_of_vote()
        wait_block_number(pip.node, proposalinfo.get('EndVotingBlock'))
        assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 3)
        submitvpandvote(clients_consensus[1:4])
        proposalinfo = pip.get_effect_proposal_info_of_vote()
        wait_block_number(pip.node, proposalinfo.get('EndVotingBlock'))
        assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 4)
        pip.economic.wait_consensus_blocknum(pip.node)
        validator = get_pledge_list(clients_consensus[0].ppos.getValidatorList)
        log.info(validator)
        assert pip.node.node_id not in validator
        programversion = clients_consensus[0].staking.get_version()
        log.info(programversion)

        programversion = clients_consensus[1].staking.get_version()
        log.info(programversion)

        programversion = clients_consensus[2].staking.get_version()
        log.info(programversion)

        programversion = clients_consensus[3].staking.get_version()
        log.info(programversion)

        verifier_list = get_pledge_list(clients_consensus[0].ppos.getVerifierList)
        log.info(verifier_list)
Esempio n. 11
0
def test_VO_VO_003_V_STA_9_V_STA_10_V_STA_11_V0_WA_003_V0_RE_003(voting_proposal_te_pipobj, client_verifier_obj_list):
    pip_obj = voting_proposal_te_pipobj
    proposalinfo = pip_obj.get_effect_proposal_info_of_vote(pip_obj.cfg.text_proposal)
    address, _ = pip_obj.economic.account.generate_account(pip_obj.node.web3, 10**18 * 10000)
    result = pip_obj.vote(pip_obj.node.node_id, proposalinfo.get('ProposalID'), pip_obj.cfg.vote_option_yeas, address,
                          transaction_cfg=pip_obj.cfg.transaction_cfg)
    log.info('Not staking address vote result {}'.format(result))
    assert_code(result, 302021)

    result = text_proposal_vote(pip_obj)
    log.info('vote result {}'.format(result))
    assert_code(result, 0)

    result = text_proposal_vote(pip_obj)
    log.info('Repeat vote  result {}'.format(result))
    assert_code(result, 302027)
    for client_obj in client_verifier_obj_list:
        if client_obj.node.node_id != pip_obj.node.node_id:
            pip_obj_test = client_obj.pip
            break

    wait_block_number(pip_obj.node, proposalinfo.get('EndVotingBlock') - 10)
    result = text_proposal_vote(pip_obj_test)
    log.info('Node {} vote result {}'.format(pip_obj_test.node.node_id, result))
    assert_code(result, 0)

    wait_block_number(pip_obj.node, proposalinfo.get('EndVotingBlock'))
    result = pip_obj.vote(pip_obj.node.node_id, proposalinfo.get('ProposalID'), pip_obj.cfg.vote_option_nays,
                          pip_obj.node.staking_address, transaction_cfg=pip_obj.cfg.transaction_cfg)
    log.info('Endvoting block vote result {}'.format(result))
    assert_code(result, 302026)
Esempio n. 12
0
def param_governance_verify(client,
                            module,
                            name,
                            newvalue,
                            effectiveflag=True):
    """
    effectiveflag indicates whether it takes effect
    """
    if isinstance(client, Client):
        pip = client.pip
    else:
        raise Exception("client must Client class")
    if pip.is_exist_effective_proposal_for_vote(pip.cfg.param_proposal) or \
            pip.is_exist_effective_proposal_for_vote(pip.cfg.version_proposal):
        raise Exception(
            'There is effective param proposal or version proposal')
    result = pip.submitParam(pip.node.node_id,
                             str(time.time()),
                             module,
                             name,
                             newvalue,
                             pip.node.staking_address,
                             transaction_cfg=pip.cfg.transaction_cfg)
    log.info('submit param proposal result : {}'.format(result))
    assert_code(result, 0)
    proposalinfo = pip.get_effect_proposal_info_of_vote(pip.cfg.param_proposal)
    log.info('param proposalinfo : {}'.format(proposalinfo))
    all_clients = []
    for node_obj in pip.economic.env.get_all_nodes():
        all_clients.append(
            Client(
                pip.economic.env, node_obj,
                StakingConfig("externalId", "nodeName", "website", "details")))
    client = get_client_by_nodeid(pip.node.node_id, all_clients)
    verifier_list = get_pledge_list(client.ppos.getVerifierList)
    log.info('verifierlist : {}'.format(verifier_list))
    clients_verifier = get_clients_by_nodeid(verifier_list, all_clients)
    if effectiveflag:
        blocknum = 0
        for client in clients_verifier:
            if client.node.block_number < blocknum and blocknum != 0:
                wait_block_number(client.node, blocknum)
            result = client.pip.vote(
                client.node.node_id,
                proposalinfo.get('ProposalID'),
                client.pip.cfg.vote_option_yeas,
                client.node.staking_address,
                transaction_cfg=client.pip.cfg.transaction_cfg)
            log.info('Node {} vote proposal result : {}'.format(
                client.node.node_id, result))
            blocknum = client.node.block_number
    wait_block_number(pip.node, proposalinfo.get('EndVotingBlock'))
    if effectiveflag:
        assert pip.get_status_of_proposal(proposalinfo.get('ProposalID')) == 2
        log.info("blockNumber {}, the {} has become {}".format(
            proposalinfo.get('EndVotingBlock'), name, newvalue))
    else:
        assert pip.get_status_of_proposal(proposalinfo.get('ProposalID')) == 3
        log.info("{} retains the original value".format(name))
Esempio n. 13
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_obj = no_vp_proposal
    result = pip_obj.submitVersion(pip_obj.node.node_id, str(time.time()), pip_obj.cfg.version8, 2,
                                   pip_obj.node.staking_address, transaction_cfg=pip_obj.cfg.transaction_cfg)
    log.info('Submit version proposal result : {}'.format(result))
    assert_code(result, 0)
    proposalinfo = pip_obj.get_effect_proposal_info_of_vote()
    log.info('Get version proposalinfo {}'.format(proposalinfo))

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

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

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

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

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

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

    result = version_proposal_vote(pip_obj)
    assert_code(result, 0)

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

    wait_block_number(pip_obj.node, proposalinfo.get('EndVotingBlock'))
    result = pip_obj.vote(pip_obj.node.node_id, proposalinfo.get('ProposalID'), pip_obj.cfg.vote_option_yeas,
                          pip_obj.node.staking_address, transaction_cfg=pip_obj.cfg.transaction_cfg)
    log.info('endblock vote result: {}'.format(result))
    assert_code(result, 302026)
Esempio n. 14
0
 def test_AV_IN_002_003(self, clients_verifier):
     pip = clients_verifier[0].pip
     submitvpandvote(clients_verifier)
     proposalinfo = pip.get_effect_proposal_info_of_vote()
     log.info('Version proposal information : {}'.format(proposalinfo))
     wait_block_number(pip.node, proposalinfo.get('EndVotingBlock'))
     assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 4)
     assert_code(pip.chain_version, pip.cfg.version0)
     wait_block_number(pip.node, proposalinfo.get('ActiveBlock'))
     assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 5)
     assert_code(pip.chain_version, pip.cfg.version5)
Esempio n. 15
0
def verify_proposal_status(clients, proposaltype, status):
    pip = clients[0].pip
    proposalinfo = pip.get_effect_proposal_info_of_vote(proposaltype)
    log.info('Get proposal information {}'.format(proposalinfo))
    assert pip.get_accuverifiers_count(proposalinfo.get('ProposalID')) == [4, 1, 1, 1]
    wait_block_number(clients[1].node, proposalinfo.get('EndVotingBlock'))
    assert_code(pip.get_yeas_of_proposal(proposalinfo.get('ProposalID')), 1)
    assert_code(pip.get_nays_of_proposal(proposalinfo.get('ProposalID')), 1)
    assert_code(pip.get_abstentions_of_proposal(proposalinfo.get('ProposalID')), 1)
    assert_code(pip.get_accu_verifiers_of_proposal(proposalinfo.get('ProposalID')), len(clients))
    assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), status)
Esempio n. 16
0
 def test_1(self, new_genesis_env, clients_consensus):
     pip = clients_consensus[-1].pip
     submitvpandvote(clients_consensus[0:2])
     replace_version_declare(pip, pip.cfg.PLATON_NEW_BIN, pip.cfg.version5)
     proposalinfo = pip.get_effect_proposal_info_of_vote()
     wait_block_number(pip.node, proposalinfo.get('EndVotingBlock'))
     submitvpandvote(clients_consensus[:3])
     proposalinfo = pip.get_effect_proposal_info_of_vote()
     wait_block_number(pip.node, proposalinfo.get('EndVotingBlock'))
     verifier_list = get_pledge_list(clients_consensus[0].ppos.getVerifierList)
     log.info(verifier_list)
     assert pip.node.node_id in verifier_list
Esempio n. 17
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)
Esempio n. 18
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)
Esempio n. 19
0
 def test_V_STA_6_7(self, submit_cancel, client_verifier_obj_list):
     pip_obj = submit_cancel
     proposalinfo = pip_obj.get_effect_proposal_info_of_vote(pip_obj.cfg.cancel_proposal)
     log.info('Cancel proposal info : {}'.format(proposalinfo))
     wait_block_number(pip_obj.node, proposalinfo.get('EndVotingBlock') - 10)
     result = cancel_proposal_vote(pip_obj)
     assert_code(result, 0)
     wait_block_number(pip_obj.node, proposalinfo.get('EndVotingBlock'))
     for client_obj in client_verifier_obj_list:
         if client_obj.node.node_id != pip_obj.node.node_id:
             pip_obj_test = client_obj.pip
             break
     result = pip_obj_test.vote(pip_obj_test.node.node_id, proposalinfo.get('ProposalID'), pip_obj_test.cfg.vote_option_Abstentions,
                                pip_obj_test.node.staking_address, transaction_cfg=pip_obj_test.cfg.transaction_cfg)
     log.info('Node {} vote result {}'.format(pip_obj_test.node.node_id, result))
     assert_code(result, 302026)
Esempio n. 20
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)
Esempio n. 21
0
def test_PP_VO_001_PP_VO_006_PP_VO_007_VS_EP_001(submit_cancel_param):
    pip_obj = submit_cancel_param
    proposalinfo = pip_obj.get_effect_proposal_info_of_vote(pip_obj.cfg.cancel_proposal)
    log.info('cancel proposal info {}'.format(proposalinfo))
    wait_block_number(pip_obj.node, proposalinfo.get('EndVotingBlock') - 8)
    result = cancel_proposal_vote(pip_obj)
    assert_code(result, 0)
    result = pip_obj.pip.getTallyResult(proposalinfo.get('ProposalID'))
    log.info('Interface getTallyResult result is {}'.format(result))
    assert_code(result, 302030)
    wait_block_number(pip_obj.node, proposalinfo.get('EndVotingBlock'))
    result = pip_obj.vote(pip_obj.node.node_id, proposalinfo.get('ProposalID'), pip_obj.cfg.vote_option_yeas,
                          pip_obj.node.staking_address, transaction_cfg=pip_obj.cfg.transaction_cfg)
    log.info('Node {} vote cancel proposal result : {}'.format(pip_obj.node.node_id, result))
    result = pip_obj.pip.getTallyResult(proposalinfo.get('ProposalID'))
    log.info('Interface getTallyResult result is {}'.format(result))
    assert_code(result, 0)
Esempio n. 22
0
 def test_VO_TER_003_VO_TER_007_VO_TER_005_PP_VO_013(self, no_vp_proposal, client_candidate_obj, client_verifier_obj):
     ca_pip_obj = client_candidate_obj.pip
     ve_pip_obj = client_verifier_obj.pip
     submittpandvote([client_verifier_obj], 2)
     submitvpandvote([client_verifier_obj], votingrounds=1)
     proposalinfo_version = ve_pip_obj.get_effect_proposal_info_of_vote()
     log.info('Version proposal information {}'.format(proposalinfo_version))
     result = version_proposal_vote(ca_pip_obj)
     assert_code(result, 302022)
     result = proposal_vote(ca_pip_obj, proposaltype=ca_pip_obj.cfg.text_proposal)
     assert_code(result, 302022)
     wait_block_number(ca_pip_obj.node, proposalinfo_version.get('EndVotingBlock'))
     submitcppandvote([client_verifier_obj], [2])
     result = proposal_vote(ca_pip_obj, proposaltype=ca_pip_obj.cfg.param_proposal)
     assert_code(result, 302022)
     result = proposal_vote(ca_pip_obj, proposaltype=ca_pip_obj.cfg.cancel_proposal)
     assert_code(result, 302022)
Esempio n. 23
0
 def test_UV_NO_1(self, new_genesis_env, client_con_list_obj):
     genesis = from_dict(data_class=Genesis, data=new_genesis_env.genesis_config)
     genesis.economicModel.gov.versionProposalSupportRate = 0.249
     genesis.economicModel.slashing.slashBlocksReward = 0
     new_genesis_env.set_genesis(genesis.to_dict())
     new_genesis_env.deploy_all()
     pip_obj = client_con_list_obj[0].pip
     submitvpandvote([client_con_list_obj[0]])
     proposalinfo = pip_obj.get_effect_proposal_info_of_vote()
     log.info('Get version proposal infomation  {}'.format(proposalinfo))
     wait_block_number(pip_obj.node, proposalinfo.get('EndVotingBlock'))
     assert pip_obj.get_accuverifiers_count(proposalinfo.get('ProposalID')) == [4, 1, 0, 0]
     assert pip_obj.get_accu_verifiers_of_proposal(proposalinfo.get('ProposalID')) == len(client_con_list_obj)
     assert pip_obj.get_yeas_of_proposal(proposalinfo.get('ProposalID')) == 1
     assert pip_obj.get_nays_of_proposal(proposalinfo.get('ProposalID')) == 0
     assert pip_obj.get_abstentions_of_proposal(proposalinfo.get('ProposalID')) == 0
     assert_code(pip_obj.get_status_of_proposal(proposalinfo.get('ProposalID')), 3)
Esempio n. 24
0
 def test_UP_PA_005(self, new_genesis_env, client_con_list_obj):
     genesis = from_dict(data_class=Genesis, data=new_genesis_env.genesis_config)
     genesis.economicModel.gov.paramProposalVoteDurationSeconds = 0
     genesis.economicModel.gov.paramProposalSupportRate = 0.332
     genesis.economicModel.gov.paramProposalVoteRate = 0.749
     new_genesis_env.set_genesis(genesis.to_dict())
     new_genesis_env.deploy_all()
     submitppandvote(client_con_list_obj[:3], 1, 2, 3)
     pip_obj = client_con_list_obj[0].pip
     proposalinfo = pip_obj.get_effect_proposal_info_of_vote(pip_obj.cfg.param_proposal)
     log.info('Get param proposal information {}'.format(proposalinfo))
     assert pip_obj.get_accuverifiers_count(proposalinfo.get('ProposalID')) == [4, 1, 1, 1]
     wait_block_number(client_con_list_obj[1].node, proposalinfo.get('EndVotingBlock'))
     assert_code(pip_obj.get_yeas_of_proposal(proposalinfo.get('ProposalID')), 1)
     assert_code(pip_obj.get_nays_of_proposal(proposalinfo.get('ProposalID')), 1)
     assert_code(pip_obj.get_abstentions_of_proposal(proposalinfo.get('ProposalID')), 1)
     assert_code(pip_obj.get_accu_verifiers_of_proposal(proposalinfo.get('ProposalID')), len(client_con_list_obj))
     assert_code(pip_obj.get_status_of_proposal(proposalinfo.get('ProposalID')), 2)
 def test_VE_AD_003(self, new_genesis_env, clients_consensus, all_clients):
     submitvpandvote(clients_consensus)
     proposalinfo = clients_consensus[
         0].pip.get_effect_proposal_info_of_vote()
     log.info('Get version proposal information : {}'.format(proposalinfo))
     wait_block_number(clients_consensus[0].node,
                       proposalinfo.get('ActiveBlock'))
     consensus_node = new_genesis_env.get_rand_node()
     test_node = new_genesis_env.get_a_normal_node()
     client = get_client_by_nodeid(test_node.node_id, all_clients)
     upload_platon(test_node, client.pip.cfg.PLATON_NEW_BIN)
     test_node.restart()
     test_node.admin.addPeer(consensus_node.enode)
     time.sleep(5)
     address, _ = client.economic.account.generate_account(
         client.node.web3, 10**18 * 10000000)
     result = client.staking.create_staking(0, address, address)
     assert_code(result, 0)
Esempio n. 26
0
    def test_TR_IN_002_TR_IN_003(self, no_vp_proposal,
                                 client_verifier_obj_list):
        pip_obj = no_vp_proposal
        submitcvpandvote(client_verifier_obj_list, 1, 1, 1, 2)
        proposalinfo_cancel = pip_obj.get_effect_proposal_info_of_vote(
            pip_obj.cfg.cancel_proposal)
        log.info('Cancel proposal information {}'.format(proposalinfo_cancel))
        proposalinfo_version = pip_obj.get_effect_proposal_info_of_vote(
            pip_obj.cfg.version_proposal)
        log.info(
            'Version proposal information {}'.format(proposalinfo_version))
        wait_block_number(pip_obj.node,
                          proposalinfo_version.get('EndVotingBlock'))
        assert pip_obj.get_canceledby_of_proposal(proposalinfo_cancel.get('ProposalID')) == \
            "0x0000000000000000000000000000000000000000000000000000000000000000"
        assert pip_obj.get_status_of_proposal(
            proposalinfo_cancel.get('ProposalID')) == 2
        assert pip_obj.get_yeas_of_proposal(
            proposalinfo_cancel.get('ProposalID')) == 3
        assert pip_obj.get_nays_of_proposal(
            proposalinfo_cancel.get('ProposalID')) == 1
        assert pip_obj.get_abstentions_of_proposal(
            proposalinfo_cancel.get('ProposalID')) == 0
        assert pip_obj.get_accu_verifiers_of_proposal(
            proposalinfo_cancel.get('ProposalID')) == len(
                client_verifier_obj_list)

        assert pip_obj.get_canceledby_of_proposal(
            proposalinfo_version.get('ProposalID')) == proposalinfo_cancel.get(
                'ProposalID')
        assert pip_obj.get_status_of_proposal(
            proposalinfo_version.get('ProposalID')) == 6
        assert pip_obj.get_yeas_of_proposal(
            proposalinfo_version.get('ProposalID')) == 0
        assert pip_obj.get_nays_of_proposal(
            proposalinfo_version.get('ProposalID')) == 0
        assert pip_obj.get_abstentions_of_proposal(
            proposalinfo_version.get('ProposalID')) == 0
        assert pip_obj.get_accu_verifiers_of_proposal(
            proposalinfo_version.get('ProposalID')) == len(
                client_verifier_obj_list)
 def test_VE_AD_004(self, new_genesis_env, clients_consensus):
     submitvpandvote(clients_consensus)
     proposalinfo = clients_consensus[
         0].pip.get_effect_proposal_info_of_vote()
     log.info('Get version proposal information : {}'.format(proposalinfo))
     wait_block_number(clients_consensus[0].node,
                       proposalinfo.get('ActiveBlock'))
     genesis = from_dict(data_class=Genesis,
                         data=new_genesis_env.genesis_config)
     genesis.config.genesisVersion = 2049
     file = os.path.join(os.path.dirname(new_genesis_env.cfg.genesis_tmp),
                         'genesis_tmp2.json')
     genesis.to_file(file)
     consensus_node = new_genesis_env.get_rand_node()
     test_node = new_genesis_env.get_a_normal_node()
     test_node.clean()
     test_node.deploy_me(file)
     test_node.admin.addPeer(consensus_node.enode)
     time.sleep(5)
     assert test_node.web3.net.peerCount == 0
     assert test_node.block_number == 0
Esempio n. 28
0
    def test_TR_IN_001(self, no_vp_proposal, clients_verifier):
        pip = no_vp_proposal
        submitcvpandvote(clients_verifier, 1, 2, 3, 3)
        proposalinfo_cancel = pip.get_effect_proposal_info_of_vote(pip.cfg.cancel_proposal)
        log.info('Cancel proposal information {}'.format(proposalinfo_cancel))
        proposalinfo_version = pip.get_effect_proposal_info_of_vote(pip.cfg.version_proposal)
        log.info('Version proposal information {}'.format(proposalinfo_version))
        wait_block_number(pip.node, proposalinfo_version.get('EndVotingBlock'))
        assert pip.get_canceledby_of_proposal(proposalinfo_cancel.get('ProposalID')) == cancelby
        assert pip.get_status_of_proposal(proposalinfo_cancel.get('ProposalID')) == 3
        assert pip.get_yeas_of_proposal(proposalinfo_cancel.get('ProposalID')) == 1
        assert pip.get_nays_of_proposal(proposalinfo_cancel.get('ProposalID')) == 1
        assert pip.get_abstentions_of_proposal(proposalinfo_cancel.get('ProposalID')) == 2
        assert pip.get_accu_verifiers_of_proposal(proposalinfo_cancel.get('ProposalID')) == len(clients_verifier)

        assert pip.get_canceledby_of_proposal(proposalinfo_version.get('ProposalID')) == cancelby
        assert pip.get_status_of_proposal(proposalinfo_version.get('ProposalID')) == 3
        assert pip.get_yeas_of_proposal(proposalinfo_version.get('ProposalID')) == 0
        assert pip.get_nays_of_proposal(proposalinfo_version.get('ProposalID')) == 0
        assert pip.get_abstentions_of_proposal(proposalinfo_version.get('ProposalID')) == 0
        assert pip.get_accu_verifiers_of_proposal(proposalinfo_version.get('ProposalID')) == len(clients_verifier)
Esempio n. 29
0
    def test_UV_UPG_1_UV_UPG_2(self, new_genesis_env, client_con_list_obj, client_noconsensus_obj):
        new_genesis_env.deploy_all()
        pip_obj = client_con_list_obj[0].pip
        pip_obj_test = client_noconsensus_obj.pip
        address, _ = pip_obj_test.economic.account.generate_account(pip_obj_test.node.web3, 10**18 * 10000000)
        result = client_noconsensus_obj.staking.create_staking(0, address, address, amount=10**18 * 2000000,
                                                               transaction_cfg=pip_obj_test.cfg.transaction_cfg)
        log.info('Node {} staking result : {}'.format(pip_obj_test.node.node_id, result))
        pip_obj_test.economic.wait_settlement_blocknum(pip_obj_test.node)
        verifier_list = get_pledge_list(client_con_list_obj[0].ppos.getVerifierList)
        log.info('Get verifier list : {}'.format(verifier_list))
        assert pip_obj_test.node.node_id in verifier_list

        submitvpandvote(client_con_list_obj)
        proposalinfo = pip_obj.get_effect_proposal_info_of_vote()
        log.info('Get version proposal information : {}'.format(proposalinfo))
        wait_block_number(pip_obj.node, proposalinfo.get('EndVotingBlock'))
        assert_code(pip_obj.get_status_of_proposal(proposalinfo.get('ProposalID')), 4)
        validator_list = get_pledge_list(client_con_list_obj[0].ppos.getValidatorList)
        log.info('Validator list : {}'.format(validator_list))
        wait_block_number(pip_obj.node, proposalinfo.get('ActiveBlock'))

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

        assert_code(pip_obj.get_status_of_proposal(proposalinfo.get('ProposalID')), 5)
        pip_obj.economic.wait_settlement_blocknum(pip_obj.node)
        validator_list = get_pledge_list(client_con_list_obj[0].ppos.getValidatorList)
        log.info('Validator list : {}'.format(validator_list))
        assert pip_obj_test.node.node_id not in validator_list
        verifier_list = get_pledge_list(client_con_list_obj[0].ppos.getVerifierList)
        log.info('Get verifier list : {}'.format(verifier_list))
        assert pip_obj_test.node.node_id not in verifier_list
        balance_before = pip_obj.node.eth.getBalance(address, 2 * pip_obj.economic.settlement_size - 1)
        log.info('Block number {} address balace {}'.format(2 * pip_obj.economic.settlement_size - 1, balance_before))
        balance_after = pip_obj.node.eth.getBalance(address, 2 * pip_obj.economic.settlement_size)
        log.info('Block number {} address balace {}'.format(2 * pip_obj.economic.settlement_size, balance_after))
        _, staking_reward = pip_obj_test.economic.get_current_year_reward(pip_obj_test.node, verifier_num=5)
        assert balance_after - balance_before == staking_reward
Esempio n. 30
0
 def test_V_STA_2_to_5(self, no_vp_proposal, client_verifier_obj_list):
     pip_obj = no_vp_proposal
     result = pip_obj.submitVersion(pip_obj.node.node_id, str(time.time()), pip_obj.cfg.version5, 2,
                                    pip_obj.node.staking_address, transaction_cfg=pip_obj.cfg.transaction_cfg)
     log.info('Submit Version proposal result : {}'.format(result))
     assert_code(result, 0)
     proposalinfo = pip_obj.get_effect_proposal_info_of_vote(pip_obj.cfg.version_proposal)
     log.info('Get version proposal information : {}'.format(proposalinfo))
     for client_obj in client_verifier_obj_list[:2]:
         result = version_proposal_vote(client_obj.pip)
         log.info('Node {} vote proposal result : {}'.format(client_obj.node.node_id, result))
         assert_code(result, 0)
     upload_platon(client_verifier_obj_list[-2].node, pip_obj.cfg.PLATON_NEW_BIN)
     client_verifier_obj_list[-2].node.restart()
     log.info('Replace the platon of the Node {}, restart the node'.format(client_verifier_obj_list[-2].node.node_id))
     wait_block_number(pip_obj.node, proposalinfo.get('EndVotingBlock') - 10)
     result = client_verifier_obj_list[-2].pip.vote(client_verifier_obj_list[-2].pip.node.node_id, proposalinfo.get('ProposalID'),
                                                    client_verifier_obj_list[-2].pip.cfg.vote_option_yeas,
                                                    client_verifier_obj_list[-2].pip.node.staking_address, transaction_cfg=pip_obj.cfg.transaction_cfg)
     log.info('Node {} vote proposal result : {}'.format(client_verifier_obj_list[-1].node.node_id, result))
     assert_code(result, 0)
     wait_block_number(pip_obj.node, proposalinfo.get('EndVotingBlock'))
     pip_obj = client_verifier_obj_list[-1].pip
     result = pip_obj.vote(pip_obj.node.node_id, proposalinfo.get('ProposalID'), pip_obj.cfg.vote_option_yeas,
                           pip_obj.node.staking_address, transaction_cfg=pip_obj.cfg.transaction_cfg)
     log.info('Node {} vote proposal result : {}'.format(client_verifier_obj_list[-1].node.node_id, result))
     assert_code(pip_obj.get_status_of_proposal(proposalinfo.get('ProposalID')), 4)
     wait_block_number(pip_obj.node, proposalinfo.get('ActiveBlock'))
     assert_code(pip_obj.get_status_of_proposal(proposalinfo.get('ProposalID')), 5)
     result = pip_obj.vote(pip_obj.node.node_id, proposalinfo.get('ProposalID'), pip_obj.cfg.vote_option_yeas,
                           pip_obj.node.staking_address, transaction_cfg=pip_obj.cfg.transaction_cfg)
     log.info('Node {} vote proposal result : {}'.format(client_verifier_obj_list[-1].node.node_id, result))