github.com/platonnetwork/platon-go@v0.7.6/cases/tests/govern/test_upgrade.py (about) 1 from common.log import log 2 from tests.lib.utils import assert_code, wait_block_number, upload_platon, get_pledge_list 3 from tests.lib import Genesis 4 from dacite import from_dict 5 from tests.govern.test_voting_statistics import submittpandvote, submitcppandvote, \ 6 submitppandvote, submitcvpandvote, submitvpandvote 7 import time 8 from tests.govern.conftest import verifier_node_version 9 import pytest 10 import allure 11 from tests.govern.test_declare_version import replace_version_declare 12 13 14 def verify_proposal_status(clients, proposaltype, status): 15 pip = clients[0].pip 16 proposalinfo = pip.get_effect_proposal_info_of_vote(proposaltype) 17 log.info('Get proposal information {}'.format(proposalinfo)) 18 assert pip.get_accuverifiers_count(proposalinfo.get('ProposalID')) == [4, 1, 1, 1] 19 wait_block_number(clients[1].node, proposalinfo.get('EndVotingBlock')) 20 assert_code(pip.get_yeas_of_proposal(proposalinfo.get('ProposalID')), 1) 21 assert_code(pip.get_nays_of_proposal(proposalinfo.get('ProposalID')), 1) 22 assert_code(pip.get_abstentions_of_proposal(proposalinfo.get('ProposalID')), 1) 23 assert_code(pip.get_accu_verifiers_of_proposal(proposalinfo.get('ProposalID')), len(clients)) 24 assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), status) 25 26 27 def update_setting_rate(new_genesis_env, proposaltype, *args): 28 genesis = from_dict(data_class=Genesis, data=new_genesis_env.genesis_config) 29 if proposaltype == 3: 30 genesis.economicModel.gov.paramProposalVoteDurationSeconds = args[0] 31 genesis.economicModel.gov.paramProposalSupportRate = args[1] 32 genesis.economicModel.gov.paramProposalVoteRate = args[2] 33 34 elif proposaltype == 4: 35 genesis.economicModel.gov.cancelProposalSupportRate = args[0] 36 genesis.economicModel.gov.cancelProposalVoteRate = args[1] 37 38 elif proposaltype == 1: 39 genesis.economicModel.gov.textProposalVoteDurationSeconds = args[0] 40 genesis.economicModel.gov.textProposalSupportRate = args[1] 41 genesis.economicModel.gov.textProposalVoteRate = args[2] 42 43 elif proposaltype == 2: 44 genesis.economicModel.gov.versionProposalSupportRate = args[0] 45 genesis.economicModel.slashing.slashBlocksReward = 0 46 else: 47 raise ValueError('Prposal type error') 48 new_genesis_env.set_genesis(genesis.to_dict()) 49 new_genesis_env.deploy_all() 50 51 52 class TestSupportRateVoteRatePP: 53 @pytest.mark.P0 54 @pytest.mark.compatibility 55 @allure.title('Parameter proposal statistical function verification') 56 def test_UP_PA_001_VS_EP_002(self, new_genesis_env, clients_consensus): 57 update_setting_rate(new_genesis_env, 3, 0, 0.332, 0.751) 58 submitppandvote(clients_consensus[:3], 1, 2, 3) 59 verify_proposal_status(clients_consensus, proposaltype=3, status=3) 60 61 @pytest.mark.P1 62 @allure.title('Parameter proposal statistical function verification') 63 def test_UP_PA_002(self, new_genesis_env, clients_consensus): 64 update_setting_rate(new_genesis_env, 3, 0, 0.334, 0.749) 65 submitppandvote(clients_consensus[:3], 1, 2, 3) 66 verify_proposal_status(clients_consensus, proposaltype=3, status=3) 67 68 @pytest.mark.P1 69 @allure.title('Parameter proposal statistical function verification') 70 def test_UP_PA_003(self, new_genesis_env, clients_consensus): 71 update_setting_rate(new_genesis_env, 3, 0, 0.333, 0.751) 72 submitppandvote(clients_consensus[:3], 1, 2, 3) 73 verify_proposal_status(clients_consensus, proposaltype=3, status=3) 74 75 @pytest.mark.P1 76 @allure.title('Parameter proposal statistical function verification') 77 def test_UP_PA_004(self, new_genesis_env, clients_consensus): 78 update_setting_rate(new_genesis_env, 3, 0, 0.334, 0.75) 79 submitppandvote(clients_consensus[:3], 1, 2, 3) 80 verify_proposal_status(clients_consensus, proposaltype=3, status=3) 81 82 @pytest.mark.compatibility 83 @pytest.mark.P0 84 @allure.title('Parameter proposal statistical function verification') 85 def test_UP_PA_005(self, new_genesis_env, clients_consensus): 86 update_setting_rate(new_genesis_env, 3, 0, 0.332, 0.749) 87 submitppandvote(clients_consensus[:3], 1, 2, 3) 88 verify_proposal_status(clients_consensus, proposaltype=3, status=2) 89 90 @pytest.mark.P1 91 @allure.title('Parameter proposal statistical function verification') 92 def test_UP_PA_006(self, new_genesis_env, clients_consensus): 93 update_setting_rate(new_genesis_env, 3, 0, 0.333, 0.749) 94 submitppandvote(clients_consensus[:3], 1, 2, 3) 95 verify_proposal_status(clients_consensus, proposaltype=3, status=2) 96 97 @pytest.mark.P1 98 @allure.title('Parameter proposal statistical function verification') 99 def test_UP_PA_007(self, new_genesis_env, clients_consensus): 100 update_setting_rate(new_genesis_env, 3, 0, 0.332, 0.75) 101 submitppandvote(clients_consensus[:3], 1, 2, 3) 102 verify_proposal_status(clients_consensus, proposaltype=3, status=3) 103 104 105 class TestSupportRateVoteRateCPP: 106 @pytest.mark.P1 107 @allure.title('Cancel parameter proposal statistical function verification') 108 def test_UC_CP_001(self, new_genesis_env, clients_consensus): 109 update_setting_rate(new_genesis_env, 4, 0.332, 0.751) 110 submitcppandvote(clients_consensus[:3], [1, 2, 3]) 111 verify_proposal_status(clients_consensus, proposaltype=4, status=3) 112 113 @pytest.mark.P1 114 @allure.title('Cancel parameter proposal statistical function verification') 115 def test_UC_CP_002(self, new_genesis_env, clients_consensus): 116 update_setting_rate(new_genesis_env, 4, 0.334, 0.749) 117 submitcppandvote(clients_consensus[:3], [1, 2, 3]) 118 verify_proposal_status(clients_consensus, proposaltype=4, status=3) 119 120 @pytest.mark.P1 121 @allure.title('Cancel parameter proposal statistical function verification') 122 def test_UC_CP_003(self, new_genesis_env, clients_consensus): 123 update_setting_rate(new_genesis_env, 4, 0.333, 0.751) 124 submitcppandvote(clients_consensus[:3], [1, 2, 3]) 125 verify_proposal_status(clients_consensus, proposaltype=4, status=3) 126 127 @pytest.mark.P1 128 @allure.title('Cancel parameter proposal statistical function verification') 129 def test_UC_CP_004(self, new_genesis_env, clients_consensus): 130 update_setting_rate(new_genesis_env, 4, 0.334, 0.75) 131 submitcppandvote(clients_consensus[:3], [1, 2, 3]) 132 verify_proposal_status(clients_consensus, proposaltype=4, status=3) 133 134 @pytest.mark.compatibility 135 @pytest.mark.P0 136 @allure.title('Cancel parameter proposal statistical function verification') 137 def test_UC_CP_005(self, new_genesis_env, clients_consensus): 138 update_setting_rate(new_genesis_env, 4, 0.332, 0.749) 139 submitcppandvote(clients_consensus[:3], [1, 2, 3]) 140 verify_proposal_status(clients_consensus, proposaltype=4, status=2) 141 142 @pytest.mark.P1 143 @allure.title('Cancel parameter proposal statistical function verification') 144 def test_UC_CP_006(self, new_genesis_env, clients_consensus): 145 update_setting_rate(new_genesis_env, 4, 0.333, 0.749) 146 submitcppandvote(clients_consensus[:3], [1, 2, 3]) 147 verify_proposal_status(clients_consensus, proposaltype=4, status=2) 148 149 @pytest.mark.P1 150 @allure.title('Cancel parameter proposal statistical function verification') 151 def test_UC_CP_007(self, new_genesis_env, clients_consensus): 152 update_setting_rate(new_genesis_env, 4, 0.332, 0.75) 153 submitcppandvote(clients_consensus[:3], [1, 2, 3]) 154 verify_proposal_status(clients_consensus, proposaltype=4, status=3) 155 156 157 class TestSupportRateVoteRateCVP: 158 @pytest.mark.compatibility 159 @pytest.mark.P0 160 @allure.title('Cancel version proposal statistical function verification') 161 def test_UP_CA_001_VS_BL_2(self, new_genesis_env, clients_consensus): 162 update_setting_rate(new_genesis_env, 4, 0.332, 0.751) 163 submitcvpandvote(clients_consensus[:3], 1, 2, 3) 164 verify_proposal_status(clients_consensus, proposaltype=4, status=3) 165 166 @pytest.mark.P1 167 @allure.title('Cancel version proposal statistical function verification') 168 def test_UP_CA_002(self, new_genesis_env, clients_consensus): 169 update_setting_rate(new_genesis_env, 4, 0.334, 0.749) 170 submitcvpandvote(clients_consensus[:3], 1, 2, 3) 171 verify_proposal_status(clients_consensus, proposaltype=4, status=3) 172 173 @pytest.mark.P1 174 @allure.title('Cancel version proposal statistical function verification') 175 def test_UP_CA_003(self, new_genesis_env, clients_consensus): 176 update_setting_rate(new_genesis_env, 4, 0.333, 0.751) 177 submitcvpandvote(clients_consensus[:3], 1, 2, 3) 178 verify_proposal_status(clients_consensus, proposaltype=4, status=3) 179 180 @pytest.mark.P1 181 @allure.title('Cancel version proposal statistical function verification') 182 def test_UP_CA_004(self, new_genesis_env, clients_consensus): 183 update_setting_rate(new_genesis_env, 4, 0.334, 0.75) 184 submitcvpandvote(clients_consensus[:3], 1, 2, 3) 185 verify_proposal_status(clients_consensus, proposaltype=4, status=3) 186 187 @pytest.mark.compatibility 188 @pytest.mark.P0 189 @allure.title('Cancel version proposal statistical function verification') 190 def test_UP_CA_005(self, new_genesis_env, clients_consensus): 191 update_setting_rate(new_genesis_env, 4, 0.332, 0.749) 192 submitcvpandvote(clients_consensus[:3], 1, 2, 3) 193 verify_proposal_status(clients_consensus, proposaltype=4, status=2) 194 195 @pytest.mark.P1 196 @allure.title('Cancel version proposal statistical function verification') 197 def test_UP_CA_006(self, new_genesis_env, clients_consensus): 198 update_setting_rate(new_genesis_env, 4, 0.333, 0.749) 199 submitcvpandvote(clients_consensus[:3], 1, 2, 3) 200 verify_proposal_status(clients_consensus, proposaltype=4, status=2) 201 202 @pytest.mark.P1 203 @allure.title('Cancel version proposal statistical function verification') 204 def test_UP_CA_007(self, new_genesis_env, clients_consensus): 205 update_setting_rate(new_genesis_env, 4, 0.332, 0.75) 206 submitcvpandvote(clients_consensus[:3], 1, 2, 3) 207 verify_proposal_status(clients_consensus, proposaltype=4, status=3) 208 209 210 class TestSupportRateVoteRateTP: 211 @pytest.mark.compatibility 212 @pytest.mark.P1 213 @allure.title('Text proposal statistical function verification') 214 def test_UP_TE_001_VS_BL_3(self, new_genesis_env, clients_consensus): 215 update_setting_rate(new_genesis_env, 1, 40, 0.332, 0.75) 216 submittpandvote(clients_consensus[:3], 1, 2, 3) 217 verify_proposal_status(clients_consensus, proposaltype=1, status=3) 218 219 @pytest.mark.P1 220 @allure.title('Text proposal statistical function verification') 221 def test_UP_TE_002(self, new_genesis_env, clients_consensus): 222 update_setting_rate(new_genesis_env, 1, 40, 0.334, 0.749) 223 submittpandvote(clients_consensus[:3], 1, 2, 3) 224 verify_proposal_status(clients_consensus, proposaltype=1, status=3) 225 226 @pytest.mark.P1 227 @allure.title('Text proposal statistical function verification') 228 def test_UP_TE_003(self, new_genesis_env, clients_consensus): 229 update_setting_rate(new_genesis_env, 1, 40, 0.333, 0.751) 230 submittpandvote(clients_consensus[:3], 1, 2, 3) 231 verify_proposal_status(clients_consensus, proposaltype=1, status=3) 232 233 @pytest.mark.P1 234 @allure.title('Text proposal statistical function verification') 235 def test_UP_TE_004(self, new_genesis_env, clients_consensus): 236 update_setting_rate(new_genesis_env, 1, 40, 0.334, 0.75) 237 submittpandvote(clients_consensus[:3], 1, 2, 3) 238 verify_proposal_status(clients_consensus, proposaltype=1, status=3) 239 240 @pytest.mark.compatibility 241 @pytest.mark.P0 242 @allure.title('Text proposal statistical function verification') 243 def test_UP_TE_005(self, new_genesis_env, clients_consensus): 244 update_setting_rate(new_genesis_env, 1, 40, 0.332, 0.749) 245 submittpandvote(clients_consensus[:3], 1, 2, 3) 246 verify_proposal_status(clients_consensus, proposaltype=1, status=2) 247 248 @pytest.mark.P1 249 @allure.title('Text proposal statistical function verification') 250 def test_UP_TE_006(self, new_genesis_env, clients_consensus): 251 update_setting_rate(new_genesis_env, 1, 40, 0.333, 0.749) 252 submittpandvote(clients_consensus[:3], 1, 2, 3) 253 verify_proposal_status(clients_consensus, proposaltype=1, status=2) 254 255 @pytest.mark.P1 256 @allure.title('Text proposal statistical function verification') 257 def test_UP_TE_007(self, new_genesis_env, clients_consensus): 258 update_setting_rate(new_genesis_env, 1, 40, 0.333, 0.75) 259 submittpandvote(clients_consensus[:3], 1, 2, 3) 260 verify_proposal_status(clients_consensus, proposaltype=1, status=3) 261 262 263 class TestUpgradedST: 264 @pytest.mark.compatibility 265 @pytest.mark.P0 266 @allure.title('Chain upgrade completed, transaction function verification') 267 def test_UV_TR_001_004_to_008_011_to_017_VS_EP_001(self, new_genesis_env, clients_consensus): 268 new_genesis_env.deploy_all() 269 pip = clients_consensus[0].pip 270 submitvpandvote(clients_consensus[:3]) 271 proposalinfo_version = pip.get_effect_proposal_info_of_vote() 272 log.info('Get version proposal information {}'.format(proposalinfo_version)) 273 wait_block_number(pip.node, proposalinfo_version.get('ActiveBlock')) 274 assert pip.get_status_of_proposal(proposalinfo_version.get('ProposalID')) == 5 275 assert pip.chain_version == pip.cfg.version5 276 assert pip.get_accuverifiers_count(proposalinfo_version.get('ProposalID')) == [4, 3, 0, 0] 277 submittpandvote(clients_consensus[:2], 1, 2) 278 submitcppandvote(clients_consensus[:2], [1, 2]) 279 proposalinfo_param = pip.get_effect_proposal_info_of_vote(pip.cfg.param_proposal) 280 log.info('Get param proposal information {}'.format(proposalinfo_param)) 281 result = pip.vote(pip.node.node_id, proposalinfo_param.get('ProposalID'), pip.cfg.vote_option_yeas, 282 pip.node.staking_address, transaction_cfg=pip.cfg.transaction_cfg) 283 log.info('Vote param proposal result : {}'.format(result)) 284 assert_code(result, 0) 285 result = replace_version_declare(pip, pip.cfg.PLATON_NEW_BIN0, pip.cfg.version0) 286 assert_code(result, 302028) 287 result = replace_version_declare(pip, pip.cfg.PLATON_NEW_BIN, pip.cfg.version5) 288 assert_code(result, 0) 289 verifier_node_version(pip, pip.cfg.version5) 290 result = replace_version_declare(pip, pip.cfg.PLATON_NEW_BIN4, pip.cfg.version4) 291 assert_code(result, 0) 292 verifier_node_version(pip, pip.cfg.version4) 293 result = replace_version_declare(pip, pip.cfg.PLATON_NEW_BIN6, pip.cfg.version6) 294 assert_code(result, 0) 295 verifier_node_version(pip, pip.cfg.version6) 296 result = pip.pip.listProposal() 297 log.info('Interface listProposal result : {}'.format(result)) 298 assert_code(result, 0) 299 result = pip.pip.getProposal(proposalinfo_version.get('ProposalID')) 300 log.info('Interface getProposal result : {}'.format(result)) 301 assert_code(result, 0) 302 303 @pytest.mark.P2 304 @allure.title('Chain upgrade completed, transaction function verification') 305 def test_UV_TR_002_003_009_010(self, new_genesis_env, clients_consensus): 306 new_genesis_env.deploy_all() 307 pip = clients_consensus[0].pip 308 submitvpandvote(clients_consensus[:3]) 309 proposalinfo_version = pip.get_effect_proposal_info_of_vote() 310 log.info('Get version proposal information {}'.format(proposalinfo_version)) 311 wait_block_number(pip.node, proposalinfo_version.get('ActiveBlock')) 312 assert pip.get_status_of_proposal(proposalinfo_version.get('ProposalID')) == 5 313 assert pip.chain_version == pip.cfg.version5 314 assert pip.get_accuverifiers_count(proposalinfo_version.get('ProposalID')) 315 316 result = pip.submitVersion(pip.node.node_id, str(time.time()), pip.cfg.version8, 3, 317 pip.node.staking_address, transaction_cfg=pip.cfg.transaction_cfg) 318 log.info('Submit version proposal result : {}'.format(result)) 319 assert_code(result, 0) 320 proposalinfo_version = pip.get_effect_proposal_info_of_vote() 321 log.info('Get version proposal information : {}'.format(proposalinfo_version)) 322 result = pip.submitCancel(pip.node.node_id, str(time.time()), 1, proposalinfo_version.get('ProposalID'), 323 pip.node.staking_address, transaction_cfg=pip.cfg.transaction_cfg) 324 log.info('Submit cancel proposal result : {}'.format(result)) 325 assert_code(result, 0) 326 proposalinfo_cancel = pip.get_effect_proposal_info_of_vote(pip.cfg.cancel_proposal) 327 log.info('Get version proposal information : {}'.format(proposalinfo_cancel)) 328 329 upload_platon(pip.node, pip.cfg.PLATON_NEW_BIN8) 330 pip.node.restart() 331 332 result = pip.vote(pip.node.node_id, proposalinfo_version.get('ProposalID'), pip.cfg.vote_option_yeas, 333 pip.node.staking_address, transaction_cfg=pip.cfg.transaction_cfg) 334 log.info('Vote result : {}'.format(result)) 335 assert_code(result, 0) 336 result = pip.vote(pip.node.node_id, proposalinfo_cancel.get('ProposalID'), pip.cfg.vote_option_yeas, 337 pip.node.staking_address, transaction_cfg=pip.cfg.transaction_cfg) 338 assert_code(result, 0) 339 log.info('Node {} vote result : {}'.format(pip.node.node_id, result)) 340 341 342 class TestUpgradeVP: 343 def calculate_version(self, version): 344 ver_byte = (version).to_bytes(length=4, byteorder='big', signed=False) 345 new_ver3 = (0).to_bytes(length=1, byteorder='big', signed=False) 346 new_version_byte = ver_byte[0:3] + new_ver3 347 return int.from_bytes(new_version_byte, byteorder='big', signed=False) 348 349 @pytest.mark.compatibility 350 @pytest.mark.P0 351 @allure.title('Version proposal statistical function verification') 352 def test_UV_UPG_1_UV_UPG_2(self, new_genesis_env, clients_consensus, client_noconsensus): 353 new_genesis_env.deploy_all() 354 pip = clients_consensus[0].pip 355 pip_test = client_noconsensus.pip 356 address, _ = pip_test.economic.account.generate_account(pip_test.node.web3, 10**18 * 10000000) 357 result = client_noconsensus.staking.create_staking(0, address, address, amount=10 ** 18 * 2000000, 358 transaction_cfg=pip_test.cfg.transaction_cfg) 359 log.info('Node {} staking result : {}'.format(pip_test.node.node_id, result)) 360 programversion = client_noconsensus.staking.get_version() 361 assert_code(programversion, pip.cfg.version0) 362 pip_test.economic.wait_settlement_blocknum(pip_test.node) 363 verifier_list = get_pledge_list(clients_consensus[0].ppos.getVerifierList) 364 log.info('Get verifier list : {}'.format(verifier_list)) 365 assert pip_test.node.node_id in verifier_list 366 367 submitvpandvote(clients_consensus) 368 programversion = clients_consensus[0].staking.get_version() 369 assert_code(programversion, pip.cfg.version0) 370 proposalinfo = pip.get_effect_proposal_info_of_vote() 371 log.info('Get version proposal information : {}'.format(proposalinfo)) 372 wait_block_number(pip.node, proposalinfo.get('EndVotingBlock')) 373 assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 4) 374 validator_list = get_pledge_list(clients_consensus[0].ppos.getValidatorList) 375 log.info('Validator list : {}'.format(validator_list)) 376 wait_block_number(pip.node, proposalinfo.get('ActiveBlock')) 377 378 validator_list = get_pledge_list(clients_consensus[0].ppos.getValidatorList) 379 log.info('Validator list : {}'.format(validator_list)) 380 assert pip_test.node.node_id not in validator_list 381 382 assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 5) 383 pip.economic.wait_settlement_blocknum(pip.node) 384 validator_list = get_pledge_list(clients_consensus[0].ppos.getValidatorList) 385 log.info('Validator list : {}'.format(validator_list)) 386 assert pip_test.node.node_id not in validator_list 387 verifier_list = get_pledge_list(clients_consensus[0].ppos.getVerifierList) 388 log.info('Get verifier list : {}'.format(verifier_list)) 389 assert pip_test.node.node_id not in verifier_list 390 balance_before = pip.node.eth.getBalance(address, 2 * pip.economic.settlement_size - 1) 391 log.info('Block number {} address balace {}'.format(2 * pip.economic.settlement_size - 1, balance_before)) 392 balance_after = pip.node.eth.getBalance(address, 2 * pip.economic.settlement_size) 393 log.info('Block number {} address balace {}'.format(2 * pip.economic.settlement_size, balance_after)) 394 _, staking_reward = pip_test.economic.get_current_year_reward(pip_test.node, verifier_num=5) 395 assert balance_after - balance_before == staking_reward 396 397 @pytest.mark.P0 398 def test_UV_UPG_2(self, new_genesis_env, clients_consensus, client_noconsensus): 399 new_genesis_env.deploy_all() 400 pip = clients_consensus[0].pip 401 pip_test = client_noconsensus.pip 402 address, _ = pip_test.economic.account.generate_account(pip_test.node.web3, 10 ** 18 * 10000000) 403 result = client_noconsensus.staking.create_staking(0, address, address, amount=10 ** 18 * 2000000, 404 transaction_cfg=pip_test.cfg.transaction_cfg) 405 log.info('Node {} staking result : {}'.format(pip_test.node.node_id, result)) 406 programversion = client_noconsensus.staking.get_version() 407 assert_code(programversion, pip.cfg.version0) 408 pip_test.economic.wait_settlement_blocknum(pip_test.node) 409 verifier_list = get_pledge_list(clients_consensus[0].ppos.getVerifierList) 410 log.info('Get verifier list : {}'.format(verifier_list)) 411 assert pip_test.node.node_id in verifier_list 412 413 submitvpandvote(clients_consensus) 414 programversion = clients_consensus[0].staking.get_version() 415 assert_code(programversion, pip.cfg.version0) 416 proposalinfo = pip.get_effect_proposal_info_of_vote() 417 log.info('Get version proposal information : {}'.format(proposalinfo)) 418 replace_version_declare(pip_test, pip_test.cfg.PLATON_NEW_BIN, pip_test.cfg.version5) 419 assert_code(result, 0) 420 programversion = client_noconsensus.staking.get_version() 421 assert_code(programversion, pip.cfg.version0) 422 wait_block_number(pip.node, proposalinfo.get('EndVotingBlock')) 423 verifier_node_version(pip, proposalinfo.get('NewVersion')) 424 assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 4) 425 validator_list = get_pledge_list(clients_consensus[0].ppos.getValidatorList) 426 log.info('Validator list : {}'.format(validator_list)) 427 wait_block_number(pip.node, proposalinfo.get('ActiveBlock')) 428 429 validator_list = get_pledge_list(clients_consensus[0].ppos.getValidatorList) 430 log.info('Validator list : {}'.format(validator_list)) 431 assert pip_test.node.node_id in validator_list 432 433 assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 5) 434 pip.economic.wait_settlement_blocknum(pip.node) 435 validator_list = get_pledge_list(clients_consensus[0].ppos.getValidatorList) 436 log.info('Validator list : {}'.format(validator_list)) 437 assert pip_test.node.node_id in validator_list 438 verifier_list = get_pledge_list(clients_consensus[0].ppos.getVerifierList) 439 log.info('Get verifier list : {}'.format(verifier_list)) 440 assert pip_test.node.node_id in verifier_list 441 programversion = clients_consensus[0].staking.get_version() 442 assert_code(programversion, pip.cfg.version5) 443 programversion = client_noconsensus.staking.get_version() 444 assert_code(programversion, pip_test.cfg.version5) 445 446 @pytest.mark.P1 447 @allure.title('Version proposal statistical function verification') 448 def test_UV_NO_1(self, new_genesis_env, clients_consensus): 449 update_setting_rate(new_genesis_env, 2, 0.251) 450 pip = clients_consensus[0].pip 451 submitvpandvote([clients_consensus[0]]) 452 node_version = verifier_node_version(pip) 453 proposalinfo = pip.get_effect_proposal_info_of_vote() 454 log.info('Get version proposal infomation {}'.format(proposalinfo)) 455 wait_block_number(pip.node, proposalinfo.get('EndVotingBlock')) 456 verifier_node_version(pip, node_version) 457 assert pip.get_accuverifiers_count(proposalinfo.get('ProposalID')) == [4, 1, 0, 0] 458 assert pip.get_accu_verifiers_of_proposal(proposalinfo.get('ProposalID')) == len(clients_consensus) 459 assert pip.get_yeas_of_proposal(proposalinfo.get('ProposalID')) == 1 460 assert pip.get_nays_of_proposal(proposalinfo.get('ProposalID')) == 0 461 assert pip.get_abstentions_of_proposal(proposalinfo.get('ProposalID')) == 0 462 assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 3) 463 464 @pytest.mark.P1 465 @allure.title('Version proposal statistical function verification') 466 def test_UV_UP_1(self, new_genesis_env, clients_consensus): 467 update_setting_rate(new_genesis_env, 2, 0.25) 468 pip = clients_consensus[0].pip 469 submitvpandvote([clients_consensus[0]]) 470 proposalinfo = pip.get_effect_proposal_info_of_vote() 471 log.info('Get version proposal infomation {}'.format(proposalinfo)) 472 wait_block_number(pip.node, proposalinfo.get('EndVotingBlock')) 473 verifier_node_version(pip, proposalinfo.get('NewVersion')) 474 assert pip.get_accuverifiers_count(proposalinfo.get('ProposalID')) == [4, 1, 0, 0] 475 assert pip.get_accu_verifiers_of_proposal(proposalinfo.get('ProposalID')) == len(clients_consensus) 476 assert pip.get_yeas_of_proposal(proposalinfo.get('ProposalID')) == 1 477 assert pip.get_nays_of_proposal(proposalinfo.get('ProposalID')) == 0 478 assert pip.get_abstentions_of_proposal(proposalinfo.get('ProposalID')) == 0 479 assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 4) 480 wait_block_number(pip.node, proposalinfo.get('ActiveBlock')) 481 assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 5) 482 483 def test_1(self, new_genesis_env, clients_consensus): 484 pip = clients_consensus[-1].pip 485 submitvpandvote(clients_consensus[0:2]) 486 replace_version_declare(pip, pip.cfg.PLATON_NEW_BIN, pip.cfg.version5) 487 proposalinfo = pip.get_effect_proposal_info_of_vote() 488 wait_block_number(pip.node, proposalinfo.get('EndVotingBlock')) 489 submitvpandvote(clients_consensus[:3]) 490 proposalinfo = pip.get_effect_proposal_info_of_vote() 491 wait_block_number(pip.node, proposalinfo.get('EndVotingBlock')) 492 verifier_list = get_pledge_list(clients_consensus[0].ppos.getVerifierList) 493 log.info(verifier_list) 494 assert pip.node.node_id in verifier_list 495 496 def test_2(self, new_genesis_env, clients_consensus): 497 new_genesis_env.deploy_all() 498 pip = clients_consensus[0].pip 499 submitvpandvote(clients_consensus[0:2]) 500 # replace_version_declare(pip, pip.cfg.PLATON_NEW_BIN, pip.cfg.version5) 501 proposalinfo = pip.get_effect_proposal_info_of_vote() 502 wait_block_number(pip.node, proposalinfo.get('EndVotingBlock')) 503 assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 3) 504 submitvpandvote(clients_consensus[1:4]) 505 proposalinfo = pip.get_effect_proposal_info_of_vote() 506 wait_block_number(pip.node, proposalinfo.get('EndVotingBlock')) 507 assert_code(pip.get_status_of_proposal(proposalinfo.get('ProposalID')), 4) 508 pip.economic.wait_consensus_blocknum(pip.node) 509 validator = get_pledge_list(clients_consensus[0].ppos.getValidatorList) 510 log.info(validator) 511 assert pip.node.node_id not in validator 512 programversion = clients_consensus[0].staking.get_version() 513 log.info(programversion) 514 515 programversion = clients_consensus[1].staking.get_version() 516 log.info(programversion) 517 518 programversion = clients_consensus[2].staking.get_version() 519 log.info(programversion) 520 521 programversion = clients_consensus[3].staking.get_version() 522 log.info(programversion) 523 524 verifier_list = get_pledge_list(clients_consensus[0].ppos.getVerifierList) 525 log.info(verifier_list)