Exemplo n.º 1
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))
Exemplo n.º 2
0
    def test_UV_UPG_1_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_mark, result))
        programversion = client_noconsensus.staking.get_version()
        assert_code(programversion, pip.cfg.version0)
        pip_test.economic.wait_settlement(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, 5)
        upload_platon(pip_test.node, pip_test.cfg.PLATON_NEW_BIN)
        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))
        wait_block_number(pip.node, proposalinfo.get('EndVotingBlock') - 1)
        validator_list = get_pledge_list(clients_consensus[0].ppos.getValidatorList)
        wait_block_number(pip.node, proposalinfo.get('EndVotingBlock'))
        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 not in validator_list
        assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 5)
        block_reward, staking_reward = pip_test.economic.get_current_year_reward(pip_test.node, verifier_num=5)
        pip.economic.wait_settlement(client_noconsensus.node)

        count = get_block_count_number(client_noconsensus.node, 320)
        validator_list = get_pledge_list(clients_consensus[0].ppos.getValidatorList)
        log.info('Validator list : {}'.format(validator_list))
        assert pip_test.node.node_id not 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 not in verifier_list

        block_reward, staking_reward = pip.economic.get_current_year_reward(pip.node, 5)
        log.info(f'block_reward == {block_reward}, staking_reward == {staking_reward}')
        balance_before = pip.node.eth.getBalance(address, 2 * pip.economic.settlement_size - 1)
        log.info('Block number {} address balace {}'.format(2 * pip.economic.settlement_size - 1, balance_before))
        pip.economic.wait_consensus(pip.node)
        balance_after = pip.node.eth.getBalance(address, 2 * pip.economic.settlement_size)
        log.info('Block number {} address balace {}'.format(2 * pip.economic.settlement_size, balance_after))
        log.info('Staking reward : {}'.format(staking_reward))
        assert balance_after - balance_before == staking_reward
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 6
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, pip.economic.create_staking_limit * 3)
        result = client_noconsensus.staking.create_staking(0, address, address, amount=pip.economic.create_staking_limit * 2,
                                                           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(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, 5)
        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(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)
Exemplo n.º 7
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()
     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)
Exemplo n.º 8
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)
Exemplo n.º 9
0
 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
Exemplo n.º 10
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)