github.com/platonnetwork/platon-go@v0.7.6/cases/tests/ppos/test_locked_position.py (about) 1 import time 2 import pytest 3 import allure 4 import rlp 5 from client_sdk_python.utils.transactions import send_obj_transaction 6 from dacite import from_dict 7 from common.key import get_pub_key, mock_duplicate_sign 8 from common.log import log 9 from client_sdk_python import Web3 10 from decimal import Decimal 11 from tests.lib import EconomicConfig, Genesis, StakingConfig, Staking, check_node_in_list, assert_code, von_amount, \ 12 get_governable_parameter_value, get_the_dynamic_parameter_gas_fee 13 14 15 @pytest.mark.P0 16 @pytest.mark.compatibility 17 def test_LS_FV_001(client_consensus): 18 """ 19 查看锁仓账户计划 20 :param client_consensus: 21 :return: 22 """ 23 # Reset environment 24 client_consensus.economic.env.deploy_all() 25 # view Lock in contract amount 26 lock_up_amount = client_consensus.node.eth.getBalance(EconomicConfig.FOUNDATION_LOCKUP_ADDRESS) 27 log.info("Lock in contract amount: {}".format(lock_up_amount)) 28 # view Lockup plan 29 result = client_consensus.ppos.getRestrictingInfo(EconomicConfig.INCENTIVEPOOL_ADDRESS) 30 assert_code(result, 304005) 31 # release_plans_list = result['Ret']['plans'] 32 # assert_code(result, 0) 33 # log.info("Lockup plan information: {}".format(result)) 34 # # assert louck up amount 35 # for i in range(len(release_plans_list)): 36 # assert release_plans_list[i] == EconomicConfig.release_info[ 37 # i], "Year {} Height of block to be released: {} Release amount: {}".format(i + 1, release_plans_list[i][ 38 # 'blockNumber'], release_plans_list[i]['amount']) 39 40 41 def create_restrictingplan(client, epoch, amount, multiple=2): 42 # create restricting plan 43 address, _ = client.economic.account.generate_account(client.node.web3, 44 client.economic.create_staking_limit * multiple) 45 benifit_address, _ = client.economic.account.generate_account(client.node.web3, 46 client.node.web3.toWei(1000, 47 'ether')) 48 plan = [{'Epoch': epoch, 'Amount': client.node.web3.toWei(amount, 'ether')}] 49 result = client.restricting.createRestrictingPlan(benifit_address, plan, address) 50 return result, address, benifit_address 51 52 53 @pytest.mark.P1 54 @pytest.mark.compatibility 55 def test_LS_UPV_001(client_new_node): 56 """ 57 锁仓参数的有效性验证: 58 None, 59 "" 60 :param client_new_node: 61 :return: 62 """ 63 client = client_new_node 64 economic = client.economic 65 node = client.node 66 status = True 67 # create restricting plan 68 address, _ = economic.account.generate_account(node.web3, economic.create_staking_limit) 69 plan = [{'Epoch': 1, 'Amount': ""}] 70 result = client.restricting.createRestrictingPlan(address, plan, address) 71 assert_code(result, 304011) 72 73 # create restricting plan 74 address, _ = economic.account.generate_account(node.web3, economic.create_staking_limit) 75 plan = [{'Epoch': 1, 'Amount': None}] 76 try: 77 client.restricting.createRestrictingPlan(address, plan, address) 78 status = False 79 except Exception as e: 80 log.info("Use case success, exception information:{} ".format(str(e))) 81 assert status, "ErrMsg: create restricting result {}".format(status) 82 83 84 @pytest.mark.P2 85 def test_LS_UPV_002_1(client_new_node): 86 """ 87 创建锁仓计划Gas费- 单个解锁次数 88 :param client_new_node: 89 :return: 90 """ 91 client = client_new_node 92 economic = client.economic 93 node = client.node 94 # create restricting plan 95 address, _ = economic.account.generate_account(node.web3, economic.create_staking_limit) 96 lock_amount = node.web3.toWei(1000, 'ether') 97 plan = [{'Epoch': 1, 'Amount': lock_amount}] 98 address_hash = address[2:] 99 log.info("address: {}".format(address_hash)) 100 plan_list = [] 101 for dict_ in plan: 102 v = [dict_[k] for k in dict_] 103 plan_list.append(v) 104 rlp_list = rlp.encode(plan_list) 105 data = rlp.encode([rlp.encode(int(4000)), rlp.encode(bytes.fromhex(address_hash)), rlp_list]) 106 transaction_data = {"to": address, "data": data} 107 aa = node.eth.estimateGas(transaction_data) 108 dynamic_gas = get_the_dynamic_parameter_gas_fee(data) 109 gas_total = 21000 + 18000 + 8000 + 21000 + dynamic_gas 110 log.info("gas_total: {}".format(gas_total)) 111 balance = node.eth.getBalance(address) 112 # Create a lockout plan 113 result = client.restricting.createRestrictingPlan(address, plan, address) 114 assert_code(result, 0) 115 balance1 = node.eth.getBalance(address) 116 transaction_fees = gas_total * node.eth.gasPrice 117 assert balance - balance1 - lock_amount == transaction_fees, "ErrMsg: transaction fees {}".format(transaction_fees) 118 119 120 @pytest.mark.P2 121 def test_LS_UPV_002_2(client_new_node): 122 """ 123 创建锁仓计划Gas费 - 多个解锁次数 124 :param client_new_node: 125 :return: 126 """ 127 client = client_new_node 128 economic = client.economic 129 node = client.node 130 # create restricting plan 131 address, _ = economic.account.generate_account(node.web3, economic.create_staking_limit) 132 lock_amount = node.web3.toWei(1000, 'ether') 133 plan = [{'Epoch': 1, 'Amount': lock_amount}, {'Epoch': 2, 'Amount': lock_amount}] 134 address_hash = address[2:] 135 log.info("address: {}".format(address_hash)) 136 plan_list = [] 137 for dict_ in plan: 138 v = [dict_[k] for k in dict_] 139 plan_list.append(v) 140 rlp_list = rlp.encode(plan_list) 141 data = rlp.encode([rlp.encode(int(4000)), rlp.encode(bytes.fromhex(address_hash)), rlp_list]) 142 dynamic_gas = get_the_dynamic_parameter_gas_fee(data) 143 gas_total = 21000 + 18000 + 8000 + 21000 * 2 + dynamic_gas 144 log.info("gas_total: {}".format(gas_total)) 145 balance = node.eth.getBalance(address) 146 # Create a lockout plan 147 result = client.restricting.createRestrictingPlan(address, plan, address) 148 assert_code(result, 0) 149 balance1 = node.eth.getBalance(address) 150 transaction_fees = gas_total * node.eth.gasPrice 151 assert balance - balance1 - lock_amount * 2 == transaction_fees, "ErrMsg: transaction fees {}".format( 152 transaction_fees) 153 154 155 @pytest.mark.P1 156 @pytest.mark.compatibility 157 def test_LS_UPV_003(client_new_node): 158 """ 159 正常创建锁仓计划 160 :param client_new_node: 161 :return: 162 """ 163 result, address, benifit_address = create_restrictingplan(client_new_node, 1, 1000) 164 assert_code(result, 0) 165 restricting_info = client_new_node.ppos.getRestrictingInfo(benifit_address) 166 assert_code(restricting_info, 0) 167 assert restricting_info['Ret']['balance'] == client_new_node.node.web3.toWei(1000, 'ether') 168 169 170 @pytest.mark.P1 171 def test_LS_UPV_004_1(client_new_node): 172 """ 173 锁仓参数的有效性验证:number 1, amount 0.1 174 number 0.1, amount 10 175 :param client_new_node: 176 :return: 177 """ 178 status = True 179 # number 1, amount 0.1 180 result, address, benifit_address = create_restrictingplan(client_new_node, 1, 0.1) 181 log.info('result: {}'.format(result)) 182 assert_code(result, 304003) 183 # number 0.1, amount 10 184 try: 185 result = create_restrictingplan(client_new_node, 0.1, 10) 186 log.info('result: {}'.format(result)) 187 status = False 188 except Exception as e: 189 log.info("Use case success, exception information:{} ".format(str(e))) 190 assert status, "ErrMsg: create restricting result {}".format(status) 191 192 193 @pytest.mark.parametrize('epoch, amount', [(-1, 10), (1, -10)]) 194 @pytest.mark.P1 195 def test_LS_UPV_004_2(client_new_node, epoch, amount): 196 """ 197 锁仓参数的有效性验证:epoch -1, amount 10 198 epoch 1, amount -10 199 :param client_new_node: 200 :return: 201 """ 202 status = True 203 # create restricting plan 204 address, _ = client_new_node.economic.account.generate_account(client_new_node.node.web3, 205 client_new_node.economic.create_staking_limit) 206 plan = [{'Epoch': epoch, 'Amount': amount}] 207 try: 208 client_new_node.restricting.createRestrictingPlan(address, plan, address) 209 status = False 210 except Exception as e: 211 log.info("Use case success, exception information:{} ".format(str(e))) 212 assert status, "ErrMsg: create restricting result {}".format(status) 213 214 215 @pytest.mark.P1 216 def test_LS_UPV_005(client_new_node): 217 """ 218 锁仓参数的有效性验证:epoch 0, amount 10 219 :param client_new_node: 220 :return: 221 """ 222 result, address, benifit_address = create_restrictingplan(client_new_node, 0, 10) 223 assert_code(result, 304001) 224 225 226 @pytest.mark.P1 227 @pytest.mark.parametrize('number', [1, 5, 36]) 228 def test_LS_UPV_006(client_new_node, number): 229 """ 230 创建锁仓计划1<= 释放计划个数N <=36 231 :param client_new_node: 232 :return: 233 """ 234 # create restricting plan 235 address, _ = client_new_node.economic.account.generate_account(client_new_node.node.web3, 236 client_new_node.economic.create_staking_limit) 237 plan = [] 238 for i in range(number): 239 plan.append({'Epoch': i + 1, 'Amount': client_new_node.node.web3.toWei(10, 'ether')}) 240 log.info("Create lock plan parameters:{}".format(plan)) 241 result = client_new_node.restricting.createRestrictingPlan(address, plan, address) 242 assert_code(result, 0) 243 244 245 @pytest.mark.P1 246 def test_LS_UPV_007(client_new_node): 247 """ 248 创建锁仓计划-释放计划的锁定期个数 > 36 249 :param client_new_node: 250 :return: 251 """ 252 # create restricting plan 253 address, _ = client_new_node.economic.account.generate_account(client_new_node.node.web3, 254 client_new_node.economic.create_staking_limit) 255 plan = [] 256 for i in range(37): 257 plan.append({'Epoch': i + 1, 'Amount': client_new_node.node.web3.toWei(10, 'ether')}) 258 log.info("Create lock plan parameters:{}".format(plan)) 259 result = client_new_node.restricting.createRestrictingPlan(address, plan, address) 260 assert_code(result, 304002) 261 262 263 @pytest.mark.P1 264 def test_LS_UPV_008(client_new_node): 265 """ 266 锁仓参数的有效性验证:epoch 1, amount 0 267 :param client_new_node: 268 :return: 269 """ 270 # create restricting plan 271 result, address, benifit_address = create_restrictingplan(client_new_node, 1, 0) 272 assert_code(result, 304011) 273 274 275 @pytest.mark.P2 276 def test_LS_UPV_009(client_new_node): 277 """ 278 创建锁仓计划-锁仓金额中文、特殊字符字符测试 279 :param client_new_node: 280 :return: 281 """ 282 # create restricting plan 283 address, _ = client_new_node.economic.account.generate_account(client_new_node.node.web3, 284 client_new_node.economic.create_staking_limit) 285 plan = [{'Epoch': 1, 'Amount': '测试 @!'}] 286 result = client_new_node.restricting.createRestrictingPlan(address, plan, address) 287 assert_code(result, 304004) 288 289 290 @pytest.mark.P1 291 def test_LS_RV_001(client_new_node): 292 """ 293 创建锁仓计划-单个释放锁定期金额大于账户金额 294 :param client_new_node: 295 :return: 296 """ 297 client = client_new_node 298 economic = client.economic 299 node = client.node 300 # create restricting plan 301 address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether')) 302 plan = [{'Epoch': 1, 'Amount': node.web3.toWei(1001, 'ether')}] 303 result = client_new_node.restricting.createRestrictingPlan(address, plan, address) 304 assert_code(result, 304004) 305 306 307 @pytest.mark.P1 308 @pytest.mark.parametrize('balance1, balance2', [(0, 0), (300, 300), (500, 500), (500, 600)]) 309 def test_LS_RV_002(client_new_node, balance1, balance2): 310 """ 311 创建锁仓计划-多个释放锁定期合计金额大于账户金额 312 :param client_new_node: 313 :return: 314 """ 315 # create restricting plan 316 address, _ = client_new_node.economic.account.generate_account(client_new_node.node.web3, 317 client_new_node.node.web3.toWei(1000, 318 'ether')) 319 lock_up_balance1 = client_new_node.node.web3.toWei(balance1, 'ether') 320 lock_up_balance2 = client_new_node.node.web3.toWei(balance2, 'ether') 321 plan = [{'Epoch': 1, 'Amount': lock_up_balance1}, {'Epoch': 2, 'Amount': lock_up_balance2}] 322 result = client_new_node.restricting.createRestrictingPlan(address, plan, address) 323 if 0 < balance1 + balance2 < 1000: 324 assert_code(result, 0) 325 elif 1000 <= balance1 + balance2: 326 assert_code(result, 304004) 327 else: 328 assert_code(result, 304011) 329 330 331 def create_restricting_plan(client, plan, benifit_address, address): 332 """ 333 create restricting plan 334 :param client: 335 :param plan: 336 :param benifit_address: 337 :param address: 338 :return: 339 """ 340 # create restricting 341 result = client.restricting.createRestrictingPlan(benifit_address, plan, address) 342 assert_code(result, 0) 343 # view restricting plan 344 restricting_info = client.ppos.getRestrictingInfo(benifit_address) 345 log.info("Restricting information: {}".format(restricting_info)) 346 assert_code(restricting_info, 0) 347 return restricting_info 348 349 350 @pytest.mark.P1 351 def test_LS_RV_003(client_new_node): 352 """ 353 创建锁仓计划-锁仓计划里两个锁仓计划的解锁期相同 354 :param client_new_node: 355 :return: 356 """ 357 # create account 358 address, _ = client_new_node.economic.account.generate_account(client_new_node.node.web3, 359 client_new_node.node.web3.toWei(1000, 360 'ether')) 361 louk_up_balace = client_new_node.node.web3.toWei(100, 'ether') 362 plan = [{'Epoch': 1, 'Amount': louk_up_balace}, {'Epoch': 1, 'Amount': louk_up_balace}] 363 # create restricting plan 364 restricting_info = create_restricting_plan(client_new_node, plan, address, address) 365 # assert restricting plan 366 assert restricting_info['Ret']['balance'] == louk_up_balace * 2, "ErrMsg:Restricting balance:{}".format( 367 restricting_info['Ret']['balance']) 368 assert restricting_info['Ret']['plans'][0][ 369 'blockNumber'] == client_new_node.economic.get_settlement_switchpoint( 370 client_new_node.node), "ErrMsg:Restricting blockNumber {}".format( 371 restricting_info['Ret']['plans'][0]['blockNumber']) 372 assert restricting_info['Ret']['plans'][0][ 373 'amount'] == louk_up_balace * 2, "ErrMsg:Restricting amount {}".format( 374 restricting_info['Ret']['plans'][0]['amount']) 375 376 377 @pytest.mark.P1 378 def test_LS_RV_004(client_new_node): 379 """ 380 创建锁仓计划-新建锁仓计划里两个锁仓计划的解锁期不同 381 :param client_new_node: 382 :return: 383 """ 384 address, _ = client_new_node.economic.account.generate_account(client_new_node.node.web3, 385 client_new_node.node.web3.toWei(1000, 386 'ether')) 387 388 louk_up_balace = client_new_node.node.web3.toWei(100, 'ether') 389 plan = [{'Epoch': 1, 'Amount': louk_up_balace}, {'Epoch': 2, 'Amount': louk_up_balace}] 390 # create restricting plan 391 restricting_info = create_restricting_plan(client_new_node, plan, address, address) 392 # assert restricting plan 393 assert restricting_info['Ret']['balance'] == louk_up_balace * 2, "ErrMsg:Restricting balance:{}".format( 394 restricting_info['Ret']['balance']) 395 assert restricting_info['Ret']['plans'][0][ 396 'blockNumber'] == client_new_node.economic.get_settlement_switchpoint( 397 client_new_node.node), "ErrMsg:Restricting blockNumber {}".format( 398 restricting_info['Ret']['plans'][0]['blockNumber']) 399 assert restricting_info['Ret']['plans'][0][ 400 'amount'] == louk_up_balace, "ErrMsg:Restricting amount {}".format( 401 restricting_info['Ret']['plans'][0]['amount']) 402 assert restricting_info['Ret']['plans'][1][ 403 'amount'] == louk_up_balace, "ErrMsg:Restricting amount {}".format( 404 restricting_info['Ret']['plans'][1]['amount']) 405 406 407 @pytest.mark.P1 408 def test_LS_RV_005(client_new_node): 409 """ 410 创建锁仓计划-创建不同锁仓计划里2个相同解锁期 411 :param client_new_node: 412 :return: 413 """ 414 # create account 415 address, _ = client_new_node.economic.account.generate_account(client_new_node.node.web3, 416 client_new_node.node.web3.toWei(1000, 417 'ether')) 418 419 louk_up_balace = client_new_node.node.web3.toWei(100, 'ether') 420 plan = [{'Epoch': 1, 'Amount': louk_up_balace}] 421 # create restricting plan 422 restricting_info = create_restricting_plan(client_new_node, plan, address, address) 423 # create restricting plan 424 restricting_info = create_restricting_plan(client_new_node, plan, address, address) 425 # assert restricting plan 426 assert restricting_info['Ret']['balance'] == louk_up_balace * 2, "ErrMsg:Restricting balance:{}".format( 427 restricting_info['Ret']['balance']) 428 assert restricting_info['Ret']['plans'][0][ 429 'blockNumber'] == client_new_node.economic.get_settlement_switchpoint( 430 client_new_node.node), "ErrMsg:Restricting blockNumber {}".format( 431 restricting_info['Ret']['plans'][0]['blockNumber']) 432 assert restricting_info['Ret']['plans'][0][ 433 'amount'] == louk_up_balace * 2, "ErrMsg:Restricting amount {}".format( 434 restricting_info['Ret']['plans'][0]['amount']) 435 436 437 def create_lock_release_amount(client, first_amount, second_amount): 438 # create first_address 439 first_address, _ = client.economic.account.generate_account(client.node.web3, first_amount) 440 # create second_address 441 second_address, _ = client.economic.account.generate_account(client.node.web3, second_amount) 442 return first_address, second_address 443 444 445 @pytest.mark.P1 446 def test_LS_RV_006(client_new_node): 447 """ 448 创建锁仓计划-不同个账户创建不同锁仓计划里有相同解锁期 449 :param client_new_node: 450 :return: 451 """ 452 # create account 453 amount1 = client_new_node.node.web3.toWei(1000, 'ether') 454 amount2 = client_new_node.node.web3.toWei(1000, 'ether') 455 address1, address2 = create_lock_release_amount(client_new_node, amount1, amount2) 456 louk_up_balace = client_new_node.node.web3.toWei(100, 'ether') 457 plan = [{'Epoch': 1, 'Amount': louk_up_balace}, {'Epoch': 2, 'Amount': louk_up_balace}] 458 # create restricting plan1 459 restricting_info = create_restricting_plan(client_new_node, plan, address1, address1) 460 # create restricting plan2 461 restricting_info = create_restricting_plan(client_new_node, plan, address1, address2) 462 # assert restricting plan1 463 assert restricting_info['Ret']['balance'] == louk_up_balace * 4, "ErrMsg:Restricting balance:{}".format( 464 restricting_info['Ret']['balance']) 465 assert restricting_info['Ret']['plans'][0][ 466 'blockNumber'] == client_new_node.economic.get_settlement_switchpoint( 467 client_new_node.node), "ErrMsg:Restricting blockNumber {}".format( 468 restricting_info['Ret']['plans'][0]['blockNumber']) 469 assert restricting_info['Ret']['plans'][0][ 470 'amount'] == louk_up_balace * 2, "ErrMsg:Restricting amount {}".format( 471 restricting_info['Ret']['plans'][0]['amount']) 472 assert restricting_info['Ret']['plans'][1][ 473 'amount'] == louk_up_balace * 2, "ErrMsg:Restricting amount {}".format( 474 restricting_info['Ret']['plans'][1]['amount']) 475 476 477 @pytest.mark.P1 478 def test_LS_RV_007(client_new_node): 479 """ 480 创建锁仓计划-不同账户创建不同锁仓计划里有不相同解锁期 481 :param client_new_node: 482 :return: 483 """ 484 # create account 485 amount1 = client_new_node.node.web3.toWei(1000, 'ether') 486 amount2 = client_new_node.node.web3.toWei(1000, 'ether') 487 address1, address2 = create_lock_release_amount(client_new_node, amount1, amount2) 488 louk_up_balace = client_new_node.node.web3.toWei(100, 'ether') 489 plan1 = [{'Epoch': 1, 'Amount': louk_up_balace}, {'Epoch': 2, 'Amount': louk_up_balace}] 490 plan2 = [{'Epoch': 1, 'Amount': louk_up_balace}, {'Epoch': 3, 'Amount': louk_up_balace}] 491 # create restricting plan1 492 restricting_info = create_restricting_plan(client_new_node, plan1, address1, address1) 493 # create restricting plan2 494 restricting_info = create_restricting_plan(client_new_node, plan2, address1, address2) 495 # assert restricting plan1 496 assert restricting_info['Ret']['balance'] == louk_up_balace * 4, "ErrMsg:Restricting balance:{}".format( 497 restricting_info['Ret']['balance']) 498 assert restricting_info['Ret']['plans'][0][ 499 'blockNumber'] == client_new_node.economic.get_settlement_switchpoint( 500 client_new_node.node), "ErrMsg:Restricting blockNumber {}".format( 501 restricting_info['Ret']['plans'][0]['blockNumber']) 502 assert restricting_info['Ret']['plans'][0][ 503 'amount'] == louk_up_balace * 2, "ErrMsg:Restricting amount {}".format( 504 restricting_info['Ret']['plans'][0]['amount']) 505 assert restricting_info['Ret']['plans'][1][ 506 'amount'] == louk_up_balace, "ErrMsg:Restricting amount {}".format( 507 restricting_info['Ret']['plans'][1]['amount']) 508 assert restricting_info['Ret']['plans'][2][ 509 'amount'] == louk_up_balace, "ErrMsg:Restricting amount {}".format( 510 restricting_info['Ret']['plans'][2]['amount']) 511 512 513 def create_restricting_plan_and_staking(client, economic, node): 514 # create account 515 amount1 = von_amount(economic.create_staking_limit, 4) 516 amount2 = client.node.web3.toWei(1000, 'ether') 517 address1, address2 = create_lock_release_amount(client, amount1, amount2) 518 # create Restricting Plan 519 plan = [{'Epoch': 1, 'Amount': economic.create_staking_limit}] 520 result = client.restricting.createRestrictingPlan(address2, plan, address1) 521 assert_code(result, 0) 522 # create staking 523 result = client.staking.create_staking(1, address2, address2) 524 assert_code(result, 0) 525 # view Restricting Plan 526 restricting_info1 = client.ppos.getRestrictingInfo(address2) 527 log.info("restricting info: {}".format(restricting_info1)) 528 assert_code(restricting_info1, 0) 529 info = restricting_info1['Ret'] 530 assert info['Pledge'] == economic.create_staking_limit, 'ErrMsg: restricting Pledge amount {}'.format( 531 info['Pledge']) 532 # wait settlement block 533 economic.wait_settlement_blocknum(node) 534 restricting_info2 = client.ppos.getRestrictingInfo(address2) 535 log.info("current block: {}".format(node.block_number)) 536 log.info("restricting info: {}".format(restricting_info2)) 537 info = restricting_info2['Ret'] 538 assert info['debt'] == economic.create_staking_limit, 'ErrMsg: restricting debt amount {}'.format( 539 info['debt']) 540 return address1, address2 541 542 543 @pytest.mark.P1 544 def test_LS_RV_008(client_new_node): 545 """ 546 创建锁仓计划-锁仓欠释放金额<新增锁仓计划总金额 547 :param client_new_node: 548 :return: 549 """ 550 client = client_new_node 551 economic = client.economic 552 node = client.node 553 address1, address2 = create_restricting_plan_and_staking(client, economic, node) 554 # create Restricting Plan again 555 plan = [{'Epoch': 1, 'Amount': von_amount(economic.create_staking_limit, 2)}] 556 result = client.restricting.createRestrictingPlan(address2, plan, address1) 557 assert_code(result, 0) 558 # view Restricting Plan 559 restricting_info = client.ppos.getRestrictingInfo(address2) 560 log.info("restricting info: {}".format(restricting_info)) 561 assert_code(restricting_info, 0) 562 info = restricting_info['Ret'] 563 assert info['debt'] == 0, "rrMsg: restricting debt amount {}".format(info['debt']) 564 565 566 @pytest.mark.P1 567 def test_LS_RV_009(client_new_node): 568 """ 569 创建锁仓计划-锁仓欠释放金额>新增锁仓计划总金额 570 :param client_new_node: 571 :return: 572 """ 573 client = client_new_node 574 economic = client.economic 575 node = client.node 576 address1, address2 = create_restricting_plan_and_staking(client, economic, node) 577 # create Restricting Plan again 578 plan = [{'Epoch': 1, 'Amount': von_amount(economic.create_staking_limit, 0.8)}] 579 result = client.restricting.createRestrictingPlan(address2, plan, address1) 580 assert_code(result, 0) 581 # view Restricting Plan 582 restricting_info = client.ppos.getRestrictingInfo(address2) 583 log.info("restricting info: {}".format(restricting_info)) 584 assert_code(restricting_info, 0) 585 info = restricting_info['Ret'] 586 assert info['debt'] == economic.create_staking_limit - von_amount(economic.create_staking_limit, 587 0.8), "rrMsg: restricting debt amount {}".format( 588 info['debt']) 589 590 591 @pytest.mark.P1 592 def test_LS_RV_010(client_new_node): 593 """ 594 创建锁仓计划-锁仓欠释放金额=新增锁仓计划总金额 595 :param client_new_node: 596 :return: 597 """ 598 client = client_new_node 599 economic = client.economic 600 node = client.node 601 address1, address2 = create_restricting_plan_and_staking(client, economic, node) 602 # create Restricting Plan again 603 plan = [{'Epoch': 1, 'Amount': von_amount(economic.create_staking_limit, 1)}] 604 result = client.restricting.createRestrictingPlan(address2, plan, address1) 605 assert_code(result, 0) 606 # view Restricting Plan 607 restricting_info = client.ppos.getRestrictingInfo(address2) 608 log.info("restricting info: {}".format(restricting_info)) 609 assert_code(restricting_info, 0) 610 info = restricting_info['Ret'] 611 assert info['debt'] == 0, "rrMsg: restricting debt amount {}".format(info['debt']) 612 613 614 def create_restricting_plan_and_entrust(client, node, economic): 615 # create account 616 amount1 = von_amount(economic.create_staking_limit, 2) 617 amount2 = client.node.web3.toWei(1000, 'ether') 618 address1, address2 = create_lock_release_amount(client, amount1, amount2) 619 # create Restricting Plan 620 plan = [{'Epoch': 1, 'Amount': von_amount(economic.delegate_limit, 1)}] 621 result = client.restricting.createRestrictingPlan(address2, plan, address1) 622 assert_code(result, 0) 623 # create staking 624 result = client.staking.create_staking(0, address1, address1) 625 assert_code(result, 0) 626 # Application for Commission 627 result = client.delegate.delegate(1, address2) 628 assert_code(result, 0) 629 # view Restricting Plan 630 restricting_info = client.ppos.getRestrictingInfo(address2) 631 log.info("restricting info: {}".format(restricting_info)) 632 assert_code(restricting_info, 0) 633 info = restricting_info['Ret'] 634 assert info['Pledge'] == economic.delegate_limit, 'ErrMsg: restricting Pledge amount {}'.format( 635 info['Pledge']) 636 # wait settlement block 637 economic.wait_settlement_blocknum(node) 638 log.info("current block: {}".format(node.block_number)) 639 # view Restricting Plan 640 restricting_info = client.ppos.getRestrictingInfo(address2) 641 log.info("restricting info: {}".format(restricting_info)) 642 assert_code(restricting_info, 0) 643 info = restricting_info['Ret'] 644 assert info['debt'] == economic.delegate_limit, 'ErrMsg: restricting debt amount {}'.format( 645 info['debt']) 646 return address1, address2 647 648 649 @pytest.mark.P1 650 def test_LS_RV_011(client_new_node): 651 """ 652 创建锁仓计划-锁仓委托释放后再次创建锁仓计划 653 :param client_new_node: 654 :return: 655 """ 656 client = client_new_node 657 economic = client.economic 658 node = client.node 659 address1, address2 = create_restricting_plan_and_entrust(client, node, economic) 660 # create Restricting Plan again 661 plan = [{'Epoch': 1, 'Amount': von_amount(economic.delegate_limit, 2)}] 662 result = client.restricting.createRestrictingPlan(address2, plan, address1) 663 assert_code(result, 0) 664 # view Restricting Plan 665 restricting_info = client.ppos.getRestrictingInfo(address2) 666 log.info("restricting info: {}".format(restricting_info)) 667 assert_code(restricting_info, 0) 668 info = restricting_info['Ret'] 669 assert info['debt'] == 0, "rrMsg: restricting debt amount {}".format(info['debt']) 670 671 672 @pytest.mark.P1 673 def test_LS_RV_012(new_genesis_env, clients_new_node): 674 """ 675 创建锁仓计划-锁仓质押释放后被处罚再次创建锁仓计划(处罚金额大于质押金额) 676 :param:client_new_node: 677 :return: 678 """ 679 # Change configuration parameters 680 genesis = from_dict(data_class=Genesis, data=new_genesis_env.genesis_config) 681 genesis.economicModel.slashing.slashBlocksReward = 30 682 new_file = new_genesis_env.cfg.env_tmp + "/genesis.json" 683 genesis.to_file(new_file) 684 new_genesis_env.deploy_all(new_file) 685 686 client1 = clients_new_node[0] 687 log.info("Current linked client1: {}".format(client1.node.node_mark)) 688 client2 = clients_new_node[1] 689 log.info("Current linked client2: {}".format(client2.node.node_mark)) 690 economic = client1.economic 691 node = client1.node 692 # create restricting plan and staking 693 address1, address2 = create_restricting_plan_and_staking(client1, economic, node) 694 # view 695 candidate_info = client1.ppos.getCandidateInfo(node.node_id) 696 pledge_amount = candidate_info['Ret']['Shares'] 697 log.info("pledge_amount: {}".format(pledge_amount)) 698 # Obtain pledge reward and block out reward 699 block_reward, staking_reward = client1.economic.get_current_year_reward(node) 700 log.info("block_reward: {} staking_reward: {}".format(block_reward, staking_reward)) 701 # Get 0 block rate penalties 702 slash_blocks = get_governable_parameter_value(client1, 'slashBlocksReward') 703 log.info("Current block height: {}".format(client2.node.eth.blockNumber)) 704 # stop node 705 node.stop() 706 # Waiting 2 consensus block 707 client2.economic.wait_consensus_blocknum(client2.node, 3) 708 log.info("Current block height: {}".format(client2.node.eth.blockNumber)) 709 # view verifier list 710 verifier_list = client2.ppos.getVerifierList() 711 log.info("Current settlement cycle verifier list: {}".format(verifier_list)) 712 # Amount of penalty 713 punishment_amonut = int(Decimal(str(block_reward)) * Decimal(str(slash_blocks))) 714 log.info("punishment_amonut: {}".format(punishment_amonut)) 715 # view Restricting Plan 716 restricting_info = client2.ppos.getRestrictingInfo(address2) 717 log.info("restricting info: {}".format(restricting_info)) 718 assert_code(restricting_info, 304005) 719 720 721 @pytest.mark.P1 722 def test_LS_RV_019(new_genesis_env, clients_noconsensus): 723 """ 724 创建锁仓计划-锁仓质押释放后被处罚再次创建锁仓计划 725 :param new_genesis_env: 726 :return: 727 """ 728 # Change configuration parameters 729 genesis = from_dict(data_class=Genesis, data=new_genesis_env.genesis_config) 730 genesis.economicModel.slashing.slashBlocksReward = 5 731 new_file = new_genesis_env.cfg.env_tmp + "/genesis.json" 732 genesis.to_file(new_file) 733 new_genesis_env.deploy_all(new_file) 734 735 client1 = clients_noconsensus[0] 736 log.info("Current linked client1: {}".format(client1.node.node_mark)) 737 client2 = clients_noconsensus[1] 738 log.info("Current linked client2: {}".format(client2.node.node_mark)) 739 economic = client1.economic 740 node = client1.node 741 # create restricting plan and staking 742 address1, address2 = create_restricting_plan_and_staking(client1, economic, node) 743 # view 744 candidate_info = client1.ppos.getCandidateInfo(node.node_id) 745 pledge_amount = candidate_info['Ret']['Shares'] 746 log.info("pledge_amount: {}".format(pledge_amount)) 747 # Obtain pledge reward and block out reward 748 block_reward, staking_reward = client1.economic.get_current_year_reward(node) 749 log.info("block_reward: {} staking_reward: {}".format(block_reward, staking_reward)) 750 # Get 0 block rate penalties 751 slash_blocks = get_governable_parameter_value(client1, 'slashBlocksReward') 752 log.info("Current block height: {}".format(client2.node.eth.blockNumber)) 753 # stop node 754 node.stop() 755 # Waiting 2 consensus block 756 client2.economic.wait_consensus_blocknum(client2.node, 3) 757 log.info("Current block height: {}".format(client2.node.eth.blockNumber)) 758 # view verifier list 759 verifier_list = client2.ppos.getVerifierList() 760 log.info("Current settlement cycle verifier list: {}".format(verifier_list)) 761 # Amount of penalty 762 punishment_amonut = int(Decimal(str(block_reward)) * Decimal(str(slash_blocks))) 763 log.info("punishment_amonut: {}".format(punishment_amonut)) 764 # view Restricting Plan 765 restricting_info = client2.ppos.getRestrictingInfo(address2) 766 log.info("restricting info: {}".format(restricting_info)) 767 info = restricting_info['Ret'] 768 assert (info['Pledge'] == pledge_amount - punishment_amonut * 2) or (info['Pledge'] == pledge_amount - punishment_amonut), 'ErrMsg: restricting Pledge amount {}'.format( 769 info['Pledge']) 770 assert (info['balance'] == pledge_amount - punishment_amonut * 2) or (info['balance'] == pledge_amount - punishment_amonut), 'ErrMsg: restricting balance amount {}'.format( 771 info['balance']) 772 # create Restricting Plan again 773 staking_amount = von_amount(economic.create_staking_limit, 2) 774 plan = [{'Epoch': 1, 'Amount': staking_amount}] 775 result = client2.restricting.createRestrictingPlan(address2, plan, address1) 776 assert_code(result, 0) 777 # view Restricting Plan 778 restricting_info3 = client2.ppos.getRestrictingInfo(address2) 779 log.info("restricting info: {}".format(restricting_info3)) 780 assert_code(restricting_info3, 0) 781 info2 = restricting_info3['Ret'] 782 assert info2['balance'] == staking_amount + info['balance'] - info[ 783 'debt'], "rrMsg: restricting balance amount {}".format(info2['balance']) 784 assert info2['debt'] == 0, "rrMsg: restricting debt amount {}".format(info2['debt']) 785 assert info2['plans'][0]['amount'] == staking_amount, "rrMsg: restricting plans amount {}".format( 786 info2['plans'][0]['amount']) 787 assert info2['Pledge'] == info['Pledge'], "rrMsg: restricting Pledge amount {}".format(info['Pledge']) 788 # Waiting for the end of the 2 settlement 789 client2.economic.wait_settlement_blocknum(client2.node, 2) 790 # view Restricting Plan 791 restricting_info3 = client2.ppos.getRestrictingInfo(address2) 792 log.info("restricting info: {}".format(restricting_info3)) 793 assert_code(restricting_info3, 304005) 794 795 796 @pytest.mark.P1 797 def test_LS_RV_013(client_new_node): 798 """ 799 同个账号锁仓给多个人 800 :param client_new_node: 801 :return: 802 """ 803 client = client_new_node 804 economic = client.economic 805 node = client.node 806 # create account 807 address1, _ = economic.account.generate_account(node.web3, economic.create_staking_limit) 808 address2, _ = economic.account.generate_account(node.web3, 0) 809 address3, _ = economic.account.generate_account(node.web3, 0) 810 # create Restricting Plan1 811 plan = [{'Epoch': 1, 'Amount': economic.delegate_limit}] 812 result = client.restricting.createRestrictingPlan(address2, plan, address1) 813 assert_code(result, 0) 814 restricting_info = client.ppos.getRestrictingInfo(address2) 815 assert_code(restricting_info, 0) 816 # create Restricting Plan1 817 plan = [{'Epoch': 1, 'Amount': economic.delegate_limit}] 818 result = client.restricting.createRestrictingPlan(address3, plan, address1) 819 assert_code(result, 0) 820 restricting_info = client.ppos.getRestrictingInfo(address3) 821 assert_code(restricting_info, 0) 822 823 824 def create_a_multiplayer_lockout_plan(client): 825 economic = client.economic 826 node = client.node 827 # create account 828 first_address, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2)) 829 second_address, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2)) 830 locked_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether')) 831 # create Restricting Plan1 832 plan = [{'Epoch': 1, 'Amount': economic.create_staking_limit}] 833 result = client.restricting.createRestrictingPlan(locked_address, plan, first_address) 834 assert_code(result, 0) 835 restricting_info = client.ppos.getRestrictingInfo(locked_address) 836 assert_code(restricting_info, 0) 837 # create Restricting Plan1 838 plan = [{'Epoch': 1, 'Amount': economic.create_staking_limit}] 839 result = client.restricting.createRestrictingPlan(locked_address, plan, second_address) 840 assert_code(result, 0) 841 restricting_info = client.ppos.getRestrictingInfo(locked_address) 842 return locked_address, restricting_info 843 844 845 @pytest.mark.P1 846 def test_LS_RV_014(client_new_node): 847 """ 848 同个账号被多个人锁仓 849 :param client_new_node: 850 :return: 851 """ 852 client = client_new_node 853 locked_address, restricting_info = create_a_multiplayer_lockout_plan(client) 854 assert_code(restricting_info, 0) 855 856 857 @pytest.mark.P1 858 def test_LS_RV_015(client_new_node): 859 """ 860 使用多人锁仓金额质押 861 :param client_new_node: 862 :return: 863 """ 864 client = client_new_node 865 locked_address, restricting_info = create_a_multiplayer_lockout_plan(client) 866 # create staking 867 result = client.staking.create_staking(1, locked_address, locked_address) 868 assert_code(result, 0) 869 870 871 @pytest.mark.P1 872 def test_LS_RV_016(client_new_node): 873 """ 874 使用多人锁仓金额委托 875 :param client_new_node: 876 :return: 877 """ 878 client = client_new_node 879 economic = client.economic 880 node = client.node 881 locked_address, restricting_info = create_a_multiplayer_lockout_plan(client) 882 # create account 883 pledge_address, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2)) 884 # create staking 885 result = client.staking.create_staking(0, pledge_address, pledge_address) 886 assert_code(result, 0) 887 # Application for Commission 888 result = client.delegate.delegate(1, locked_address, amount=economic.create_staking_limit) 889 assert_code(result, 0) 890 891 892 @pytest.mark.P1 893 def test_LS_RV_017(client_new_node): 894 """ 895 使用多人锁仓金额增持 896 :param client_new_node: 897 :return: 898 """ 899 client = client_new_node 900 locked_address, restricting_info = create_a_multiplayer_lockout_plan(client) 901 # create staking 902 result = client.staking.create_staking(1, locked_address, locked_address) 903 assert_code(result, 0) 904 # Apply for additional pledge 905 result = client.staking.increase_staking(1, locked_address) 906 assert_code(result, 0) 907 908 909 @pytest.mark.P2 910 def test_LS_RV_018(clients_new_node, reset_environment): 911 """ 912 验证人非正常状态下创建锁仓计划(节点退出创建锁仓) 913 :param clients_new_node: 914 :return: 915 """ 916 client1 = clients_new_node[0] 917 log.info("Current linked client1: {}".format(client1.node.node_mark)) 918 client2 = clients_new_node[1] 919 log.info("Current linked client2: {}".format(client2.node.node_mark)) 920 economic = client1.economic 921 node = client1.node 922 # create account 923 address1, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2)) 924 # create staking 925 result = client1.staking.create_staking(0, address1, address1) 926 assert_code(result, 0) 927 # Waiting settlement block 928 client1.economic.wait_settlement_blocknum(client1.node) 929 # stop node 930 client1.node.stop() 931 # Waiting 2 consensus block 932 client2.economic.wait_consensus_blocknum(client2.node, 2) 933 log.info("Current block height: {}".format(client2.node.eth.blockNumber)) 934 # create Restricting Plan1 935 plan = [{'Epoch': 1, 'Amount': economic.delegate_limit}] 936 result = client2.restricting.createRestrictingPlan(address1, plan, address1) 937 assert_code(result, 0) 938 939 940 def create_account_restricting_plan(client, economic, node): 941 # create account 942 address1, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2)) 943 address2, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether')) 944 # create Restricting Plan 945 amount = economic.create_staking_limit 946 plan = [{'Epoch': 1, 'Amount': amount}] 947 result = client.restricting.createRestrictingPlan(address2, plan, address1) 948 assert_code(result, 0) 949 # view restricting info 950 restricting_info = client.ppos.getRestrictingInfo(address2) 951 log.info("restricting info: {}".format(restricting_info)) 952 assert_code(restricting_info, 0) 953 info = restricting_info['Ret'] 954 assert info['balance'] == amount, 'ErrMsg: restricting balance amount {}'.format(info['balance']) 955 assert info['Pledge'] == 0, 'ErrMsg: restricting Pledge amount {}'.format(info['Pledge']) 956 return address2 957 958 959 @pytest.mark.P1 960 @pytest.mark.compatibility 961 def test_LS_PV_001(client_new_node): 962 """ 963 锁仓账户质押正常节点 964 :param client_new_node: 965 :return: 966 """ 967 client = client_new_node 968 economic = client.economic 969 node = client.node 970 # create account restricting plan 971 address2 = create_account_restricting_plan(client, economic, node) 972 # create staking 973 result = client.staking.create_staking(1, address2, address2) 974 assert_code(result, 0) 975 # view restricting info 976 restricting_info = client.ppos.getRestrictingInfo(address2) 977 log.info("restricting info: {}".format(restricting_info)) 978 assert_code(restricting_info, 0) 979 info = restricting_info['Ret'] 980 assert info['Pledge'] == economic.create_staking_limit, 'ErrMsg: restricting Pledge amount {}'.format( 981 info['Pledge']) 982 983 984 @pytest.mark.P1 985 def test_LS_PV_002(client_new_node): 986 """ 987 创建计划质押-未找到锁仓信息 988 :param client_new_node: 989 :return: 990 """ 991 client = client_new_node 992 economic = client.economic 993 node = client.node 994 # create account 995 address1, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2)) 996 address2, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether')) 997 # create staking 998 result = client.staking.create_staking(1, address2, address2) 999 assert_code(result, 304005) 1000 1001 1002 @pytest.mark.P1 1003 @pytest.mark.compatibility 1004 def test_LS_PV_003(client_new_node): 1005 """ 1006 创建计划质押-锁仓计划质押金额<0 1007 :param client_new_node: 1008 :return: 1009 """ 1010 client = client_new_node 1011 economic = client.economic 1012 node = client.node 1013 status = True 1014 # create account restricting plan 1015 address2 = create_account_restricting_plan(client, economic, node) 1016 try: 1017 # create staking 1018 client.staking.create_staking(1, address2, address2, amount=-1) 1019 status = False 1020 except Exception as e: 1021 log.info("Use case success, exception information:{} ".format(str(e))) 1022 assert status, "ErrMsg: create restricting result {}".format(status) 1023 1024 1025 @pytest.mark.P1 1026 def test_LS_PV_004(client_new_node): 1027 """ 1028 创建计划质押-锁仓计划质押金额=0 1029 :param client_new_node: 1030 :return: 1031 """ 1032 client = client_new_node 1033 economic = client.economic 1034 node = client.node 1035 # create account restricting plan 1036 address2 = create_account_restricting_plan(client, economic, node) 1037 # create staking 1038 result = client.staking.create_staking(1, address2, address2, amount=0) 1039 assert_code(result, 301100) 1040 1041 1042 @pytest.mark.P1 1043 def test_LS_PV_005(client_new_node): 1044 """ 1045 创建计划质押-锁仓计划质押金额小于最低门槛 1046 :param client_new_node: 1047 :return: 1048 """ 1049 client = client_new_node 1050 economic = client.economic 1051 node = client.node 1052 # create account restricting plan 1053 address2 = create_account_restricting_plan(client, economic, node) 1054 # create staking 1055 staking_amount = von_amount(economic.create_staking_limit, 0.8) 1056 result = client.staking.create_staking(1, address2, address2, amount=staking_amount) 1057 assert_code(result, 301100) 1058 1059 1060 @pytest.mark.P2 1061 def test_LS_PV_006(client_new_node): 1062 """ 1063 创建计划质押-锁仓账户余额为0的情况下申请质押 1064 :param client_new_node: 1065 :return: 1066 """ 1067 client = client_new_node 1068 economic = client.economic 1069 node = client.node 1070 status = True 1071 # create account 1072 address1, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2)) 1073 address2, _ = economic.account.generate_account(node.web3, 0) 1074 # create Restricting Plan 1075 amount = economic.create_staking_limit 1076 plan = [{'Epoch': 1, 'Amount': amount}] 1077 result = client.restricting.createRestrictingPlan(address2, plan, address1) 1078 assert_code(result, 0) 1079 try: 1080 # create staking 1081 client.staking.create_staking(1, address2, address2) 1082 status = False 1083 except Exception as e: 1084 log.info("Use case success, exception information:{} ".format(str(e))) 1085 assert status, "ErrMsg: create restricting result {}".format(status) 1086 1087 1088 @pytest.mark.P1 1089 def test_LS_PV_007(clients_new_node): 1090 """ 1091 创建计划退回质押-退回质押金额>锁仓质押金额 1092 :param clients_new_node: 1093 :return: 1094 """ 1095 client1 = clients_new_node[0] 1096 log.info("Current linked client1: {}".format(client1.node.node_mark)) 1097 client2 = clients_new_node[1] 1098 log.info("Current linked client2: {}".format(client2.node.node_mark)) 1099 economic = client1.economic 1100 node = client1.node 1101 # create account 1102 amount1 = von_amount(economic.create_staking_limit, 2) 1103 amount2 = von_amount(economic.create_staking_limit, 2) 1104 address1, address2 = create_lock_release_amount(client1, amount1, amount2) 1105 # create Restricting Plan 1106 plan = [{'Epoch': 1, 'Amount': economic.create_staking_limit}] 1107 result = client1.restricting.createRestrictingPlan(address2, plan, address1) 1108 assert_code(result, 0) 1109 # create Restricting amount staking 1110 result = client1.staking.create_staking(1, address2, address2) 1111 assert_code(result, 0) 1112 time.sleep(3) 1113 # create Free amount staking 1114 result = client2.staking.create_staking(0, address2, address2) 1115 assert_code(result, 0) 1116 # withdrew staking 1117 result = client2.staking.withdrew_staking(address2) 1118 assert_code(result, 0) 1119 1120 1121 @pytest.mark.P1 1122 def test_LS_PV_008(client_new_node): 1123 """ 1124 创建计划退回质押-欠释放金额=回退金额 1125 :param client_new_node: 1126 :return: 1127 """ 1128 client = client_new_node 1129 economic = client.economic 1130 node = client.node 1131 # create restricting plan and staking 1132 address1, address2 = create_restricting_plan_and_staking(client, economic, node) 1133 # withdrew staking 1134 result = client.staking.withdrew_staking(address2) 1135 assert_code(result, 0) 1136 1137 1138 @pytest.mark.P1 1139 def test_LS_PV_009(client_new_node): 1140 """ 1141 创建计划退回质押-欠释放金额<回退金额 1142 :param client_new_node: 1143 :return: 1144 """ 1145 client1 = client_new_node 1146 log.info("Current linked client1: {}".format(client1.node.node_mark)) 1147 economic = client1.economic 1148 node = client1.node 1149 # create account 1150 amount1 = von_amount(economic.create_staking_limit, 2) 1151 amount2 = von_amount(economic.create_staking_limit, 2) 1152 address1, address2 = create_lock_release_amount(client1, amount1, amount2) 1153 # create Restricting Plan 1154 plan = [{'Epoch': 1, 'Amount': economic.create_staking_limit}] 1155 result = client1.restricting.createRestrictingPlan(address2, plan, address1) 1156 assert_code(result, 0) 1157 # create Restricting amount staking 1158 result = client1.staking.create_staking(1, address2, address2) 1159 assert_code(result, 0) 1160 # wait settlement block 1161 economic.wait_settlement_blocknum(node) 1162 # view restricting info 1163 restricting_info = client1.ppos.getRestrictingInfo(address2) 1164 info = restricting_info['Ret'] 1165 assert info['debt'] == economic.create_staking_limit, "rrMsg: restricting debt amount {}".format(info['debt']) 1166 # create Free amount staking 1167 result = client1.staking.increase_staking(0, address2) 1168 assert_code(result, 0) 1169 # withdrew staking 1170 result = client1.staking.withdrew_staking(address2) 1171 assert_code(result, 0) 1172 # view Restricting plan 1173 restricting_info = client1.ppos.getRestrictingInfo(address2) 1174 assert_code(restricting_info, 0) 1175 info = restricting_info['Ret'] 1176 assert info['debt'] == economic.create_staking_limit, "errMsg: restricting debt amount {}".format(info['debt']) 1177 1178 1179 @pytest.mark.P2 1180 def test_LS_PV_010(client_new_node): 1181 """ 1182 创建计划退回质押-锁仓账户余额不足的情况下申请退回质押 1183 :param client_new_node: 1184 :return: 1185 """ 1186 client = client_new_node 1187 economic = client.economic 1188 node = client.node 1189 status = True 1190 # create account 1191 amount1 = von_amount(economic.create_staking_limit, 2) 1192 amount2 = node.web3.toWei(0.000009, 'ether') 1193 address1, address2 = create_lock_release_amount(client, amount1, amount2) 1194 # create Restricting Plan 1195 plan = [{'Epoch': 1, 'Amount': economic.create_staking_limit}] 1196 result = client.restricting.createRestrictingPlan(address2, plan, address1) 1197 assert_code(result, 0) 1198 # create Restricting amount staking 1199 result = client.staking.create_staking(1, address2, address2) 1200 assert_code(result, 0) 1201 log.info("address amount: {}".format(node.eth.getBalance(address2))) 1202 try: 1203 # withdrew staking 1204 client.staking.withdrew_staking(address2) 1205 status = False 1206 except Exception as e: 1207 log.info("Use case success, exception information:{} ".format(str(e))) 1208 assert status, "ErrMsg: create restricting result {}".format(status) 1209 1210 1211 @pytest.mark.P2 1212 def test_LS_PV_011(client_new_node): 1213 """ 1214 锁仓账户退回质押金中,申请质押节点 1215 :param client_new_node: 1216 :return: 1217 """ 1218 client = client_new_node 1219 economic = client.economic 1220 node = client.node 1221 # create restricting plan and staking 1222 address1, address2 = create_restricting_plan_and_staking(client, economic, node) 1223 # withdrew staking 1224 result = client.staking.withdrew_staking(address2) 1225 assert_code(result, 0) 1226 # create Restricting amount staking 1227 result = client.staking.create_staking(1, address2, address2) 1228 assert_code(result, 301101) 1229 1230 1231 @pytest.mark.P2 1232 def test_LS_PV_012(client_new_node): 1233 """ 1234 锁仓账户申请完质押后又退回质押金(犹豫期) 1235 :param client_new_node: 1236 :return: 1237 """ 1238 client = client_new_node 1239 economic = client.economic 1240 node = client.node 1241 # create account restricting plan 1242 address2 = create_account_restricting_plan(client, economic, node) 1243 # create staking 1244 result = client.staking.create_staking(1, address2, address2) 1245 assert_code(result, 0) 1246 # withdrew staking 1247 result = client.staking.withdrew_staking(address2) 1248 assert_code(result, 0) 1249 1250 1251 @pytest.mark.P1 1252 def test_LS_PV_013(client_new_node): 1253 """ 1254 锁仓账户申请完质押后又退回质押金(锁定期) 1255 :param client_new_node: 1256 :return: 1257 """ 1258 client = client_new_node 1259 economic = client.economic 1260 node = client.node 1261 # create account restricting plan 1262 address2 = create_account_restricting_plan(client, economic, node) 1263 # create staking 1264 result = client.staking.create_staking(1, address2, address2) 1265 assert_code(result, 0) 1266 # wait settlement block 1267 economic.wait_settlement_blocknum(node) 1268 # withdrew staking 1269 result = client.staking.withdrew_staking(address2) 1270 assert_code(result, 0) 1271 # wait settlement block 1272 economic.wait_settlement_blocknum(node, 2) 1273 # view restricting info 1274 restricting_info = client.ppos.getRestrictingInfo(address2) 1275 log.info("restricting info: {}".format(restricting_info)) 1276 assert_code(restricting_info, 304005) 1277 1278 1279 def create_free_pledge(client, economic): 1280 # create account 1281 amount1 = von_amount(economic.create_staking_limit, 2) 1282 amount2 = client.node.web3.toWei(1000, 'ether') 1283 address1, address2 = create_lock_release_amount(client, amount1, amount2) 1284 # create Restricting Plan 1285 plan = [{'Epoch': 1, 'Amount': von_amount(economic.delegate_limit, 10)}] 1286 result = client.restricting.createRestrictingPlan(address2, plan, address1) 1287 assert_code(result, 0) 1288 # view Restricting Plan informtion 1289 restricting_info = client.ppos.getRestrictingInfo(address2) 1290 log.info("Restricting Plan informtion: {}".format(restricting_info)) 1291 # create staking 1292 result = client.staking.create_staking(0, address1, address1) 1293 assert_code(result, 0) 1294 return address2 1295 1296 1297 @pytest.mark.P1 1298 def test_LS_EV_001(client_new_node): 1299 """ 1300 创建计划委托-委托正常节点 1301 :param client_new_node: 1302 :return: 1303 """ 1304 client = client_new_node 1305 economic = client.economic 1306 address2 = create_free_pledge(client, economic) 1307 # Application for Commission 1308 result = client.delegate.delegate(1, address2) 1309 assert_code(result, 0) 1310 # view Restricting Plan 1311 restricting_info = client.ppos.getRestrictingInfo(address2) 1312 log.info("restricting info: {}".format(restricting_info)) 1313 assert_code(restricting_info, 0) 1314 info = restricting_info['Ret'] 1315 assert info['Pledge'] == economic.delegate_limit, 'ErrMsg: restricting Pledge amount {}'.format( 1316 info['Pledge']) 1317 1318 1319 @pytest.mark.P1 1320 def test_LS_EV_002(client_new_node): 1321 """ 1322 创建计划委托-未找到锁仓信息 1323 :param client_new_node: 1324 :return: 1325 """ 1326 client = client_new_node 1327 economic = client.economic 1328 node = client.node 1329 # create account 1330 amount1 = von_amount(economic.create_staking_limit, 2) 1331 amount2 = client.node.web3.toWei(1000, 'ether') 1332 address1, address2 = create_lock_release_amount(client, amount1, amount2) 1333 # create staking 1334 result = client.staking.create_staking(0, address1, address1) 1335 assert_code(result, 0) 1336 # Application for Commission 1337 result = client.delegate.delegate(1, address2) 1338 assert_code(result, 304005) 1339 1340 1341 @pytest.mark.P1 1342 def test_LS_EV_003(client_new_node, client_consensus): 1343 """ 1344 锁仓账户委托基金会节点 1345 :param client_new_node: 1346 :param client_consensus: 1347 :return: 1348 """ 1349 client = client_new_node 1350 economic = client.economic 1351 address2 = create_free_pledge(client, economic) 1352 # Application for Commission 1353 result = client_consensus.delegate.delegate(1, address2) 1354 assert_code(result, 301107) 1355 1356 1357 @pytest.mark.P1 1358 def test_LS_EV_004(client_new_node): 1359 """ 1360 锁仓账户委托非候选节点(锁定期) 1361 :param client_new_node: 1362 :return: 1363 """ 1364 client = client_new_node 1365 economic = client.economic 1366 node = client.node 1367 # create account 1368 pledge_acount = von_amount(economic.create_staking_limit, 2) 1369 lock_acount = node.web3.toWei(1000, 'ether') 1370 pledge_address, lock_address = create_lock_release_amount(client, pledge_acount, lock_acount) 1371 # create staking 1372 result = client.staking.create_staking(0, pledge_address, pledge_address) 1373 assert_code(result, 0) 1374 # Waiting for the end of the settlement 1375 economic.wait_settlement_blocknum(node) 1376 # create Restricting Plan 1377 plan = [{'Epoch': 1, 'Amount': von_amount(economic.delegate_limit, 10)}] 1378 result = client.restricting.createRestrictingPlan(lock_address, plan, pledge_address) 1379 assert_code(result, 0) 1380 # Application for Commission 1381 result = client.delegate.delegate(1, lock_address) 1382 assert_code(result, 0) 1383 # view Restricting Plan 1384 restricting_info = client.ppos.getRestrictingInfo(lock_address) 1385 log.info("restricting info: {}".format(restricting_info)) 1386 assert_code(restricting_info, 0) 1387 info = restricting_info['Ret'] 1388 assert info['Pledge'] == economic.delegate_limit, 'ErrMsg: restricting Pledge amount {}'.format( 1389 info['Pledge']) 1390 1391 1392 @pytest.mark.P1 1393 def test_LS_EV_005(client_new_node): 1394 """ 1395 锁仓账户委托金额小于最低委托金 1396 :param client_new_node: 1397 :return: 1398 """ 1399 client = client_new_node 1400 economic = client.economic 1401 address2 = create_free_pledge(client, economic) 1402 # Application for Commission 1403 delegate_amount = von_amount(economic.delegate_limit, 0.8) 1404 result = client.delegate.delegate(1, address2, amount=delegate_amount) 1405 assert_code(result, 301105) 1406 1407 1408 @pytest.mark.P1 1409 def test_LS_EV_006(client_new_node): 1410 """ 1411 有锁仓可用金额,但是账户余额为0的情况下申请委托 1412 :param client_new_node: 1413 :return: 1414 """ 1415 client = client_new_node 1416 economic = client.economic 1417 status = True 1418 # create account 1419 amount1 = von_amount(economic.create_staking_limit, 2) 1420 address1, address2 = create_lock_release_amount(client, amount1, 0) 1421 # create Restricting Plan 1422 plan = [{'Epoch': 1, 'Amount': economic.delegate_limit}] 1423 result = client.restricting.createRestrictingPlan(address2, plan, address1) 1424 assert_code(result, 0) 1425 # create staking 1426 result = client.staking.create_staking(0, address1, address1) 1427 assert_code(result, 0) 1428 try: 1429 # Application for Commission 1430 client.delegate.delegate(1, address2) 1431 status = False 1432 except Exception as e: 1433 log.info("Use case success, exception information:{} ".format(str(e))) 1434 assert status, "ErrMsg:Transfer result {}".format(status) 1435 1436 1437 @pytest.mark.P1 1438 def test_LS_EV_007(client_new_node): 1439 """ 1440 创建计划委托-锁仓计划委托金额<0 1441 :param client_new_node: 1442 :return: 1443 """ 1444 client = client_new_node 1445 economic = client.economic 1446 address2 = create_free_pledge(client, economic) 1447 status = True 1448 try: 1449 # Application for Commission 1450 # delegate_amount = von_amount(economic.delegate_limit, -8) 1451 result = client.delegate.delegate(1, address2, amount=-8) 1452 log.info("result: {}".format(result)) 1453 status = False 1454 except Exception as e: 1455 log.info("Use case success, exception information:{} ".format(str(e))) 1456 assert status, "ErrMsg:Transfer result {}".format(status) 1457 1458 1459 @pytest.mark.P1 1460 def test_LS_EV_008(client_new_node): 1461 """ 1462 创建计划委托-锁仓计划委托金额=0 1463 :param client_new_node: 1464 :return: 1465 """ 1466 client = client_new_node 1467 economic = client.economic 1468 address2 = create_free_pledge(client, economic) 1469 # Application for Commission 1470 result = client.delegate.delegate(1, address2, amount=0) 1471 assert_code(result, 301105) 1472 1473 1474 def create_delegation_information(client, economic, node, base): 1475 address2 = create_free_pledge(client, economic) 1476 # Application for Commission 1477 delegate_amount = von_amount(economic.delegate_limit, base) 1478 result = client.delegate.delegate(1, address2, amount=delegate_amount) 1479 assert_code(result, 0) 1480 # view restricting info 1481 restricting_info = client.ppos.getRestrictingInfo(address2) 1482 assert_code(restricting_info, 0) 1483 info = restricting_info['Ret'] 1484 assert info['Pledge'] == delegate_amount, 'ErrMsg: restricting Pledge amount {}'.format(info['Pledge']) 1485 # get Pledge node information 1486 candidate_info = client.ppos.getCandidateInfo(node.node_id) 1487 info = candidate_info['Ret'] 1488 staking_blocknum = info['StakingBlockNum'] 1489 return address2, delegate_amount, staking_blocknum 1490 1491 1492 @pytest.mark.P2 1493 def test_LS_EV_009(client_new_node): 1494 """ 1495 锁仓账户发起委托之后赎回部分委托验证(犹豫期) 1496 :param client_new_node: 1497 :return: 1498 """ 1499 client = client_new_node 1500 economic = client.economic 1501 node = client.node 1502 # create delegation information 1503 address2, delegate_amount, staking_blocknum = create_delegation_information(client, economic, node, 10) 1504 # withdrew delegate 1505 redemption_amount = von_amount(economic.delegate_limit, 5) 1506 result = client.delegate.withdrew_delegate(staking_blocknum, address2, amount=redemption_amount) 1507 assert_code(result, 0) 1508 # view restricting info again 1509 restricting_info = client.ppos.getRestrictingInfo(address2) 1510 assert_code(restricting_info, 0) 1511 info = restricting_info['Ret'] 1512 assert info['Pledge'] == delegate_amount - redemption_amount, 'ErrMsg: restricting Pledge amount {}'.format( 1513 info['Pledge']) 1514 1515 1516 @pytest.mark.P2 1517 def test_LS_EV_010(client_new_node): 1518 """ 1519 锁仓账户发起委托之后赎回全部委托验证(犹豫期) 1520 :param client_new_node: 1521 :return: 1522 """ 1523 client = client_new_node 1524 economic = client.economic 1525 node = client.node 1526 # create delegation information 1527 address2, delegate_amount, staking_blocknum = create_delegation_information(client, economic, node, 10) 1528 # withdrew delegate 1529 redemption_amount = von_amount(economic.delegate_limit, 10) 1530 client.delegate.withdrew_delegate(staking_blocknum, address2, amount=redemption_amount) 1531 # view restricting info again 1532 restricting_info = client.ppos.getRestrictingInfo(address2) 1533 assert_code(restricting_info, 0) 1534 info = restricting_info['Ret'] 1535 assert info['Pledge'] == delegate_amount - redemption_amount, 'ErrMsg: restricting Pledge amount {}'.format( 1536 info['Pledge']) 1537 1538 1539 @pytest.mark.P2 1540 def test_LS_EV_011(client_new_node): 1541 """ 1542 锁仓账户发起委托之后赎回委托验证(锁定期) 1543 :param client_new_node: 1544 :return: 1545 """ 1546 client = client_new_node 1547 economic = client.economic 1548 node = client.node 1549 # create delegation information 1550 address2, delegate_amount, staking_blocknum = create_delegation_information(client, economic, node, 10) 1551 # Waiting for the end of the settlement cycle 1552 economic.wait_settlement_blocknum(node) 1553 # withdrew delegate 1554 redemption_amount = von_amount(economic.delegate_limit, 10) 1555 client.delegate.withdrew_delegate(staking_blocknum, address2, amount=redemption_amount) 1556 # view restricting info again 1557 restricting_info = client.ppos.getRestrictingInfo(address2) 1558 assert_code(restricting_info, 304005) 1559 1560 1561 @pytest.mark.P1 1562 def test_LS_EV_012(client_new_node): 1563 """ 1564 锁仓赎回委托金额小于委托最低门槛 1565 :param client_new_node: 1566 :return: 1567 """ 1568 client = client_new_node 1569 economic = client.economic 1570 node = client.node 1571 # create delegation information 1572 address2, delegate_amount, staking_blocknum = create_delegation_information(client, economic, node, 10) 1573 # withdrew delegate 1574 redemption_amount = von_amount(economic.delegate_limit, 0.8) 1575 result = client.delegate.withdrew_delegate(staking_blocknum, address2, amount=redemption_amount) 1576 assert_code(result, 301108) 1577 1578 1579 @pytest.mark.P1 1580 def test_LS_EV_013(client_new_node): 1581 """ 1582 锁仓赎回委托后剩余委托小于委托最低门槛 1583 :param client_new_node: 1584 :return: 1585 """ 1586 client = client_new_node 1587 economic = client.economic 1588 node = client.node 1589 # create delegation information 1590 address2, delegate_amount, staking_blocknum = create_delegation_information(client, economic, node, 2) 1591 # view restricting plan information 1592 restricting_info = client.ppos.getRestrictingInfo(address2) 1593 log.info("restricting plan information: {}".format(restricting_info)) 1594 info = restricting_info['Ret'] 1595 assert info['Pledge'] == von_amount(economic.delegate_limit, 2), 'ErrMsg: restricting Pledge amount {}'.format( 1596 info['Pledge']) 1597 # withdrew delegate 1598 redemption_amount = von_amount(economic.delegate_limit, 1.5) 1599 result = client.delegate.withdrew_delegate(staking_blocknum, address2, amount=redemption_amount) 1600 assert_code(result, 0) 1601 # view restricting plan information again 1602 restricting_info = client.ppos.getRestrictingInfo(address2) 1603 log.info("restricting plan information: {}".format(restricting_info)) 1604 info = restricting_info['Ret'] 1605 assert info['Pledge'] == 0, 'ErrMsg: restricting Pledge amount {}'.format(info['Pledge']) 1606 1607 1608 @pytest.mark.P2 1609 def test_LS_EV_014(clients_new_node, reset_environment): 1610 """ 1611 锁仓账户委托节点状态异常验证人(节点已挂) 1612 :param clients_new_node: 1613 :param reset_environment: 1614 :return: 1615 """ 1616 client1 = clients_new_node[0] 1617 log.info("Current linked client1: {}".format(client1.node.node_mark)) 1618 client2 = clients_new_node[1] 1619 log.info("Current linked client2: {}".format(client2.node.node_mark)) 1620 economic = client1.economic 1621 node = client1.node 1622 # create free pledge 1623 address2 = create_free_pledge(client1, economic) 1624 # stop pledge node 1625 node.stop() 1626 # Wait for the consensus round to end 1627 client2.economic.wait_consensus_blocknum(client2.node) 1628 # Application for Commission 1629 result = client2.delegate.delegate(1, address2, node_id=node.node_id) 1630 assert_code(result, 0) 1631 1632 1633 @pytest.mark.P2 1634 def test_LS_EV_015(client_new_node): 1635 """ 1636 创建计划委托-锁仓账户余额为0的情况下申请委托 1637 :param client_new_node: 1638 :return: 1639 """ 1640 client = client_new_node 1641 economic = client.economic 1642 status = True 1643 # create account 1644 amount1 = von_amount(economic.create_staking_limit, 2) 1645 address1, address2 = create_lock_release_amount(client, amount1, 0) 1646 # create Restricting Plan 1647 plan = [{'Epoch': 1, 'Amount': von_amount(economic.delegate_limit, 10)}] 1648 result = client.restricting.createRestrictingPlan(address2, plan, address1) 1649 assert_code(result, 0) 1650 # create staking 1651 result = client.staking.create_staking(0, address1, address1) 1652 assert_code(result, 0) 1653 try: 1654 # Application for Commission 1655 client.delegate.delegate(1, address2) 1656 status = False 1657 except Exception as e: 1658 log.info("Use case success, exception information:{} ".format(str(e))) 1659 assert status, "ErrMsg:Transfer result {}".format(status) 1660 1661 1662 @pytest.mark.P1 1663 def test_LS_EV_016(client_new_node): 1664 """ 1665 创建计划退回委托-锁仓计划退回委托金额<0 1666 :param client_new_node: 1667 :return: 1668 """ 1669 client = client_new_node 1670 economic = client.economic 1671 node = client.node 1672 status = True 1673 # create delegation information 1674 address2, delegate_amount, staking_blocknum = create_delegation_information(client, economic, node, 10) 1675 try: 1676 # withdrew delegate 1677 client.delegate.withdrew_delegate(staking_blocknum, address2, amount=-100) 1678 status = False 1679 except Exception as e: 1680 log.info("Use case success, exception information:{} ".format(str(e))) 1681 assert status, "ErrMsg:Transfer result {}".format(status) 1682 1683 1684 @pytest.mark.P1 1685 def test_LS_EV_017(client_new_node): 1686 """ 1687 创建计划退回委托-锁仓计划退回委托金额=0 1688 :param client_new_node: 1689 :return: 1690 """ 1691 client = client_new_node 1692 economic = client.economic 1693 node = client.node 1694 # create delegation information 1695 address2, delegate_amount, staking_blocknum = create_delegation_information(client, economic, node, 10) 1696 # withdrew delegate 1697 result = client.delegate.withdrew_delegate(staking_blocknum, address2, amount=0) 1698 assert_code(result, 301108) 1699 1700 1701 @pytest.mark.P1 1702 def test_LS_EV_018(client_new_node): 1703 """ 1704 创建计划退回委托-锁仓计划退回委托金额>锁仓委托金额 1705 :param client_new_node: 1706 :return: 1707 """ 1708 client = client_new_node 1709 economic = client.economic 1710 node = client.node 1711 # create delegation information 1712 address2, delegate_amount, staking_blocknum = create_delegation_information(client, economic, node, 10) 1713 # withdrew delegate 1714 redemption_amount = von_amount(economic.delegate_limit, 11) 1715 result = client.delegate.withdrew_delegate(staking_blocknum, address2, amount=redemption_amount) 1716 assert_code(result, 301113) 1717 1718 1719 @pytest.mark.P1 1720 def test_LS_EV_019(client_new_node): 1721 """ 1722 创建计划退回委托-欠释放金额>赎回委托金额 1723 :param client_new_node: 1724 :return: 1725 """ 1726 client = client_new_node 1727 economic = client.economic 1728 node = client.node 1729 address2, delegate_amount, staking_blocknum = create_delegation_information(client, economic, node, 10) 1730 # Waiting for the end of the settlement cycle 1731 economic.wait_settlement_blocknum(node) 1732 # view restricting plan informtion 1733 restricting_info = client.ppos.getRestrictingInfo(address2) 1734 log.info("restricting plan informtion: {}".format(restricting_info)) 1735 info = restricting_info['Ret'] 1736 assert info['debt'] == von_amount(economic.delegate_limit, 10), "rrMsg: restricting debt amount {}".format( 1737 info['debt']) 1738 # withdrew delegate 1739 redemption_amount = von_amount(economic.delegate_limit, 5) 1740 result = client.delegate.withdrew_delegate(staking_blocknum, address2, amount=redemption_amount) 1741 assert_code(result, 0) 1742 # view restricting plan informtion again 1743 restricting_info = client.ppos.getRestrictingInfo(address2) 1744 log.info("restricting plan informtion: {}".format(restricting_info)) 1745 info = restricting_info['Ret'] 1746 assert info['debt'] == von_amount(economic.delegate_limit, 1747 10) - redemption_amount, "rrMsg: restricting debt amount {}".format(info['debt']) 1748 1749 1750 @pytest.mark.P1 1751 def test_LS_EV_020(client_new_node): 1752 """ 1753 创建计划退回委托-欠释放金额=撤销委托金额 1754 :param client_new_node: 1755 :return: 1756 """ 1757 client = client_new_node 1758 economic = client.economic 1759 node = client.node 1760 address2, delegate_amount, staking_blocknum = create_delegation_information(client, economic, node, 10) 1761 # Waiting for the end of the settlement cycle 1762 economic.wait_settlement_blocknum(node) 1763 # view restricting plan informtion 1764 restricting_info = client.ppos.getRestrictingInfo(address2) 1765 log.info("restricting plan informtion: {}".format(restricting_info)) 1766 info = restricting_info['Ret'] 1767 assert info['debt'] == von_amount(economic.delegate_limit, 10), "rrMsg: restricting debt amount {}".format( 1768 info['debt']) 1769 # withdrew delegate 1770 redemption_amount = von_amount(economic.delegate_limit, 10) 1771 result = client.delegate.withdrew_delegate(staking_blocknum, address2, amount=redemption_amount) 1772 assert_code(result, 0) 1773 # view restricting plan informtion again 1774 restricting_info = client.ppos.getRestrictingInfo(address2) 1775 log.info("restricting plan informtion: {}".format(restricting_info)) 1776 assert_code(restricting_info, 304005) 1777 1778 1779 @pytest.mark.P1 1780 def test_LS_EV_021(client_new_node): 1781 """ 1782 创建计划退回委托-欠释放金额<撤销委托金额 1783 :param client_new_node: 1784 :return: 1785 """ 1786 client = client_new_node 1787 economic = client.economic 1788 node = client.node 1789 address2, delegate_amount, staking_blocknum = create_delegation_information(client, economic, node, 5) 1790 # Waiting for the end of the settlement cycle 1791 economic.wait_settlement_blocknum(node) 1792 # view restricting plan informtion 1793 restricting_info = client.ppos.getRestrictingInfo(address2) 1794 log.info("restricting plan informtion: {}".format(restricting_info)) 1795 info = restricting_info['Ret'] 1796 assert info['debt'] == von_amount(economic.delegate_limit, 5), "rrMsg: restricting debt amount {}".format( 1797 info['debt']) 1798 # Application for Commission 1799 delegate_amount2 = von_amount(economic.delegate_limit, 5) 1800 result = client.delegate.delegate(0, address2, amount=delegate_amount2) 1801 assert_code(result, 0) 1802 # withdrew delegate 1803 redemption_amount = von_amount(economic.delegate_limit, 10) 1804 result = client.delegate.withdrew_delegate(staking_blocknum, address2, amount=redemption_amount) 1805 assert_code(result, 0) 1806 # view restricting plan informtion again 1807 restricting_info = client.ppos.getRestrictingInfo(address2) 1808 log.info("restricting plan informtion: {}".format(restricting_info)) 1809 assert_code(restricting_info, 304005) 1810 1811 1812 @pytest.mark.P1 1813 def test_LS_EV_022(client_new_node): 1814 """ 1815 创建计划退回委托-锁仓账户余额不足的情况下申请退回委托 1816 :param client_new_node: 1817 :return: 1818 """ 1819 client = client_new_node 1820 economic = client.economic 1821 node = client.node 1822 status = True 1823 # create account 1824 amount1 = von_amount(economic.create_staking_limit, 2) 1825 amount2 = node.web3.toWei(0.000006, 'ether') 1826 address1, address2 = create_lock_release_amount(client, amount1, amount2) 1827 # create Restricting Plan 1828 plan = [{'Epoch': 1, 'Amount': von_amount(economic.delegate_limit, 10)}] 1829 result = client.restricting.createRestrictingPlan(address2, plan, address1) 1830 assert_code(result, 0) 1831 # create staking 1832 result = client.staking.create_staking(0, address1, address1) 1833 assert_code(result, 0) 1834 # Application for Commission 1835 result = client.delegate.delegate(1, address2) 1836 assert_code(result, 0) 1837 try: 1838 # get Pledge node information 1839 candidate_info = client.ppos.getCandidateInfo(node.node_id) 1840 info = candidate_info['Ret'] 1841 staking_blocknum = info['StakingBlockNum'] 1842 # withdrew delegate 1843 client.delegate.withdrew_delegate(staking_blocknum, address2) 1844 status = False 1845 except Exception as e: 1846 log.info("Use case success, exception information:{} ".format(str(e))) 1847 assert status, "ErrMsg:Transfer result {}".format(status) 1848 1849 1850 def create_restricting_increase_staking(client, economic, node): 1851 # create account 1852 address1, _ = economic.account.generate_account(node.web3, economic.create_staking_limit) 1853 address2, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2)) 1854 # create Restricting Plan1 1855 add_staking_amount = von_amount(economic.add_staking_limit, 10) 1856 plan = [{'Epoch': 1, 'Amount': add_staking_amount}] 1857 result = client.restricting.createRestrictingPlan(address2, plan, address1) 1858 assert_code(result, 0) 1859 restricting_info = client.ppos.getRestrictingInfo(address2) 1860 log.info("restricting plan informtion: {}".format(restricting_info)) 1861 # create staking 1862 result = client.staking.create_staking(0, address2, address2) 1863 assert_code(result, 0) 1864 return address2 1865 1866 1867 @pytest.mark.P1 1868 def test_LS_IV_001(client_new_node): 1869 """ 1870 锁仓账户申请质押后用锁仓余额进行增持质押 1871 :param client_new_node: 1872 :return: 1873 """ 1874 client = client_new_node 1875 economic = client.economic 1876 node = client.node 1877 address2 = create_restricting_increase_staking(client, economic, node) 1878 # Create pledge of increasing holding 1879 result = client.staking.increase_staking(1, address2) 1880 assert_code(result, 0) 1881 1882 1883 @pytest.mark.P1 1884 def test_LS_IV_002(client_new_node): 1885 """ 1886 有锁仓可用金额,但是账户gas不足的情况下申请增持 1887 :param client_new_node: 1888 :return: 1889 """ 1890 client = client_new_node 1891 economic = client.economic 1892 node = client.node 1893 status = True 1894 # create account 1895 address1, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2)) 1896 address2, _ = economic.account.generate_account(node.web3, 1897 economic.create_staking_limit + node.web3.toWei(0.000009, 'ether')) 1898 # create Restricting Plan 1899 add_staking_amount = von_amount(economic.add_staking_limit, 10) 1900 plan = [{'Epoch': 1, 'Amount': add_staking_amount}] 1901 result = client.restricting.createRestrictingPlan(address2, plan, address1) 1902 assert_code(result, 0) 1903 restricting_info = client.ppos.getRestrictingInfo(address2) 1904 log.info("restricting plan informtion: {}".format(restricting_info)) 1905 # create staking 1906 result = client.staking.create_staking(0, address2, address2) 1907 assert_code(result, 0) 1908 try: 1909 # Create pledge of increasing holding 1910 client.staking.increase_staking(1, address2) 1911 status = False 1912 except Exception as e: 1913 log.info("Use case success, exception information:{} ".format(str(e))) 1914 assert status, "ErrMsg:Transfer result {}".format(status) 1915 1916 1917 @pytest.mark.P1 1918 def test_LS_IV_003(clients_new_node, reset_environment): 1919 """ 1920 锁仓账户增持状态异常验证人(节点已挂) 1921 :param clients_new_node: 1922 :param reset_environment: 1923 :return: 1924 """ 1925 client1 = clients_new_node[0] 1926 log.info("Current linked client1: {}".format(client1.node.node_mark)) 1927 client2 = clients_new_node[1] 1928 log.info("Current linked client2: {}".format(client2.node.node_mark)) 1929 economic = client1.economic 1930 node = client1.node 1931 # Create restricting plan and free pledge 1932 address2 = create_restricting_increase_staking(client1, economic, node) 1933 # stop pledge node 1934 node.stop() 1935 # Wait for the consensus round to end 1936 client2.economic.wait_consensus_blocknum(client2.node) 1937 # Create pledge of increasing holding 1938 result = client2.staking.increase_staking(1, address2, node_id=node.node_id) 1939 assert_code(result, 0) 1940 1941 1942 def restricting_plan_verification_pledge(client, economic, node): 1943 # create account 1944 address1, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2)) 1945 # create Restricting Plan 1946 amount = economic.create_staking_limit 1947 plan = [{'Epoch': 1, 'Amount': amount}] 1948 result = client.restricting.createRestrictingPlan(address1, plan, address1) 1949 assert_code(result, 0) 1950 return address1 1951 1952 1953 @pytest.mark.P2 1954 def test_LS_CSV_001(client_new_node): 1955 """ 1956 创建计划质押-锁仓账户和释放账户是同一个账户账户进行质押(质押金额小于锁仓金额) 1957 :param client_new_node: 1958 :return: 1959 """ 1960 client = client_new_node 1961 economic = client.economic 1962 node = client.node 1963 # Create restricting plan 1964 address1 = restricting_plan_verification_pledge(client, economic, node) 1965 # create staking 1966 staking_amount = economic.create_staking_limit 1967 result = client.staking.create_staking(1, address1, address1, amount=staking_amount) 1968 assert_code(result, 0) 1969 1970 1971 @pytest.mark.P2 1972 def test_LS_CSV_002(client_new_node): 1973 """ 1974 创建计划质押-锁仓账户和释放账户是同一个账户账户进行质押(质押金额大于锁仓金额) 1975 :param client_new_node: 1976 :return: 1977 """ 1978 client = client_new_node 1979 economic = client.economic 1980 node = client.node 1981 # Create restricting plan 1982 address1 = restricting_plan_verification_pledge(client, economic, node) 1983 # create staking 1984 staking_amount = von_amount(economic.create_staking_limit, 2) 1985 result = client.staking.create_staking(0, address1, address1, amount=staking_amount) 1986 assert_code(result, 301111) 1987 1988 1989 def restricting_plan_verification_pledge2(client, economic, node): 1990 # create account 1991 address1, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2)) 1992 address2, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether')) 1993 # create Restricting Plan 1994 amount = economic.create_staking_limit 1995 plan = [{'Epoch': 1, 'Amount': amount}] 1996 result = client.restricting.createRestrictingPlan(address2, plan, address1) 1997 assert_code(result, 0) 1998 return address2 1999 2000 2001 @pytest.mark.P2 2002 def test_LS_CSV_003(client_new_node): 2003 """ 2004 创建计划质押-锁仓账户和释放账户不同时进行质押(质押金额小于等于锁仓金额) 2005 :param client_new_node: 2006 :return: 2007 """ 2008 client = client_new_node 2009 economic = client.economic 2010 node = client.node 2011 # Create restricting plan 2012 address2 = restricting_plan_verification_pledge2(client, economic, node) 2013 # create staking 2014 staking_amount = economic.create_staking_limit 2015 result = client.staking.create_staking(1, address2, address2, amount=staking_amount) 2016 assert_code(result, 0) 2017 2018 2019 @pytest.mark.P2 2020 def test_LS_CSV_004(client_new_node): 2021 """ 2022 创建计划质押-锁仓账户和释放账户不同时进行质押(质押金额大于锁仓金额) 2023 :param client_new_node: 2024 :return: 2025 """ 2026 client = client_new_node 2027 economic = client.economic 2028 node = client.node 2029 # Create restricting plan 2030 address2 = restricting_plan_verification_pledge2(client, economic, node) 2031 # create staking 2032 staking_amount = von_amount(economic.create_staking_limit, 2) 2033 result = client.staking.create_staking(1, address2, address2, amount=staking_amount) 2034 assert_code(result, 304013) 2035 2036 2037 def restricting_plan_verification_add_staking(client, economic, node): 2038 # create account 2039 address1, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 3)) 2040 # create Restricting Plan 2041 amount = von_amount(economic.create_staking_limit, 2) 2042 plan = [{'Epoch': 1, 'Amount': amount}] 2043 result = client.restricting.createRestrictingPlan(address1, plan, address1) 2044 assert_code(result, 0) 2045 # create staking 2046 result = client.staking.create_staking(1, address1, address1) 2047 assert_code(result, 0) 2048 return address1 2049 2050 2051 @pytest.mark.P2 2052 def test_LS_CSV_005(client_new_node): 2053 """ 2054 锁仓账户和释放账户是同一个账户账户进行增持质押(质押金额小于锁仓金额) 2055 :param client_new_node: 2056 :return: 2057 """ 2058 client = client_new_node 2059 economic = client.economic 2060 node = client.node 2061 # create restricting plan staking 2062 address1 = restricting_plan_verification_add_staking(client, economic, node) 2063 # Additional pledge 2064 increase_amount = von_amount(economic.delegate_limit, 5) 2065 result = client.staking.increase_staking(1, address1, amount=increase_amount) 2066 assert_code(result, 0) 2067 2068 2069 @pytest.mark.P2 2070 def test_LS_CSV_006(client_new_node): 2071 """ 2072 锁仓账户和释放账户是同一个账户账户进行增持质押(质押金额大于锁仓金额) 2073 :param client_new_node: 2074 :return: 2075 """ 2076 client = client_new_node 2077 economic = client.economic 2078 node = client.node 2079 # create restricting plan staking 2080 address1 = restricting_plan_verification_add_staking(client, economic, node) 2081 # Additional pledge 2082 increase_amount = von_amount(economic.create_staking_limit, 2) 2083 result = client.staking.increase_staking(1, address1, amount=increase_amount) 2084 assert_code(result, 304013) 2085 2086 2087 def restricting_plan_verification_add_staking2(client, economic, node): 2088 # create account 2089 address1, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2)) 2090 address2, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2)) 2091 # create Restricting Plan 2092 amount = von_amount(economic.add_staking_limit, 10) 2093 plan = [{'Epoch': 1, 'Amount': amount}] 2094 result = client.restricting.createRestrictingPlan(address2, plan, address1) 2095 assert_code(result, 0) 2096 # create staking 2097 result = client.staking.create_staking(0, address2, address2) 2098 assert_code(result, 0) 2099 return address2 2100 2101 2102 @pytest.mark.P2 2103 def test_LS_CSV_007(client_new_node): 2104 """ 2105 锁仓账户和释放账户不同时进行质押(增持质押金额小于锁仓金额) 2106 :param client_new_node: 2107 :return: 2108 """ 2109 client = client_new_node 2110 economic = client.economic 2111 node = client.node 2112 # create restricting plan staking 2113 address2 = restricting_plan_verification_add_staking2(client, economic, node) 2114 # Additional pledge 2115 increase_amount = von_amount(economic.add_staking_limit, 5) 2116 result = client.staking.increase_staking(1, address2, amount=increase_amount) 2117 assert_code(result, 0) 2118 2119 2120 @pytest.mark.P2 2121 def test_LS_CSV_008(client_new_node): 2122 """ 2123 锁仓账户和释放账户不同时进行质押(增持质押金额大于锁仓金额) 2124 :param client_new_node: 2125 :return: 2126 """ 2127 client = client_new_node 2128 economic = client.economic 2129 node = client.node 2130 # create restricting plan staking 2131 address2 = restricting_plan_verification_add_staking2(client, economic, node) 2132 # Additional pledge 2133 increase_amount = von_amount(economic.add_staking_limit, 15) 2134 result = client.staking.increase_staking(1, address2, amount=increase_amount) 2135 assert_code(result, 304013) 2136 2137 2138 def restricting_plan_verification_delegate(client, economic, node): 2139 # create account 2140 address1, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2)) 2141 address2, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether')) 2142 # create Restricting Plan 2143 amount = von_amount(economic.delegate_limit, 10) 2144 plan = [{'Epoch': 1, 'Amount': amount}] 2145 result = client.restricting.createRestrictingPlan(address2, plan, address1) 2146 assert_code(result, 0) 2147 # create staking 2148 result = client.staking.create_staking(0, address1, address1) 2149 assert_code(result, 0) 2150 return address2 2151 2152 2153 @pytest.mark.P2 2154 def test_LS_CSV_009(client_new_node): 2155 """ 2156 锁仓账户和释放账户不是同一个账号进行委托(委托金额小于锁仓金额) 2157 :param client_new_node: 2158 :return: 2159 """ 2160 client = client_new_node 2161 economic = client.economic 2162 node = client.node 2163 # create restricting plan staking 2164 address2 = restricting_plan_verification_delegate(client, economic, node) 2165 # Additional pledge 2166 delegate_amount = von_amount(economic.delegate_limit, 5) 2167 result = client.delegate.delegate(1, address2, amount=delegate_amount) 2168 assert_code(result, 0) 2169 2170 2171 @pytest.mark.P2 2172 def test_LS_CSV_010(client_new_node): 2173 """ 2174 锁仓账户和释放账户不是同一个账号进行委托(委托金额大于锁仓金额) 2175 :param client_new_node: 2176 :return: 2177 """ 2178 client = client_new_node 2179 economic = client.economic 2180 node = client.node 2181 # create restricting plan staking 2182 address2 = restricting_plan_verification_delegate(client, economic, node) 2183 # Additional pledge 2184 delegate_amount = von_amount(economic.delegate_limit, 15) 2185 result = client.delegate.delegate(1, address2, amount=delegate_amount) 2186 assert_code(result, 304013) 2187 2188 2189 @pytest.mark.P2 2190 def test_LS_CSV_011(client_new_node): 2191 """ 2192 锁仓账号在犹豫期申请质押后,在锁定期申请增持后,在申请退回质押金 2193 :param client_new_node: 2194 :return: 2195 """ 2196 client = client_new_node 2197 economic = client.economic 2198 node = client.node 2199 # create account 2200 address1, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 3)) 2201 # create Restricting Plan 2202 amount = von_amount(economic.create_staking_limit, 2) 2203 plan = [{'Epoch': 2, 'Amount': amount}] 2204 result = client.restricting.createRestrictingPlan(address1, plan, address1) 2205 assert_code(result, 0) 2206 # create staking 2207 result = client.staking.create_staking(1, address1, address1) 2208 assert_code(result, 0) 2209 # Waiting for the end of the settlement period 2210 economic.wait_settlement_blocknum(node) 2211 # Additional pledge 2212 result = client.staking.increase_staking(1, address1) 2213 assert_code(result, 0) 2214 balance = node.eth.getBalance(address1) 2215 log.info("Account address: {} balance: {}".format(address1, balance)) 2216 # Application for return of pledge 2217 result = client.staking.withdrew_staking(address1) 2218 assert_code(result, 0) 2219 balance1 = node.eth.getBalance(address1) 2220 log.info("Account address: {} balance: {}".format(address1, balance1)) 2221 # Waiting for the end of the 2 settlement period 2222 economic.wait_settlement_blocknum(node, 2) 2223 balance2 = node.eth.getBalance(address1) 2224 log.info("Account address: {} balance: {}".format(address1, balance2)) 2225 assert balance2 - balance1 > economic.create_staking_limit, "errMsg: Account address: {} balance: {}".format( 2226 address1, balance2) 2227 2228 2229 @pytest.mark.P2 2230 def test_LS_CSV_012(client_new_node): 2231 """ 2232 锁仓账户退回质押金中,申请委托节点 2233 :param client_new_node: 2234 :return: 2235 """ 2236 client = client_new_node 2237 economic = client.economic 2238 node = client.node 2239 # create restricting plan staking 2240 address1 = restricting_plan_verification_pledge(client, economic, node) 2241 # create staking 2242 result = client.staking.create_staking(1, address1, address1) 2243 assert_code(result, 0) 2244 # create account 2245 address2, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether')) 2246 # Waiting for the end of the settlement period 2247 economic.wait_settlement_blocknum(node) 2248 # Application for return of pledge 2249 result = client.staking.withdrew_staking(address1) 2250 assert_code(result, 0) 2251 # create Restricting Plan 2252 amount = von_amount(economic.delegate_limit, 10) 2253 plan = [{'Epoch': 1, 'Amount': amount}] 2254 result = client.restricting.createRestrictingPlan(address2, plan, address2) 2255 assert_code(result, 0) 2256 # Free amount Entrust node 2257 result = client.delegate.delegate(0, address2) 2258 assert_code(result, 301103) 2259 # Restricting amount Entrust node 2260 result = client.delegate.delegate(1, address2) 2261 assert_code(result, 301103) 2262 2263 2264 @pytest.mark.P2 2265 def test_LS_CSV_013(client_new_node): 2266 """ 2267 锁仓账户退回质押金中,申请增持质押 2268 :param client_new_node: 2269 :return: 2270 """ 2271 client = client_new_node 2272 economic = client.economic 2273 node = client.node 2274 # create restricting plan staking 2275 address1 = restricting_plan_verification_add_staking(client, economic, node) 2276 # Waiting for the end of the settlement period 2277 economic.wait_settlement_blocknum(node) 2278 # Application for return of pledge 2279 result = client.staking.withdrew_staking(address1) 2280 assert_code(result, 0) 2281 # create Restricting Plan 2282 amount = von_amount(economic.add_staking_limit, 5) 2283 plan = [{'Epoch': 1, 'Amount': amount}] 2284 result = client.restricting.createRestrictingPlan(address1, plan, address1) 2285 assert_code(result, 0) 2286 # Restricting amount Additional pledge 2287 result = client.staking.increase_staking(1, address1) 2288 assert_code(result, 301103) 2289 # Free amount Additional pledge 2290 result = client.staking.increase_staking(0, address1) 2291 assert_code(result, 301103) 2292 2293 2294 def steps_of_returning_pledge(client, economic, node): 2295 # create restricting plan staking 2296 address1 = restricting_plan_verification_pledge(client, economic, node) 2297 # create staking 2298 result = client.staking.create_staking(1, address1, address1) 2299 assert_code(result, 0) 2300 # create account 2301 address2, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether')) 2302 # Waiting for the end of the settlement period 2303 economic.wait_settlement_blocknum(node) 2304 # Application for return of pledge 2305 result = client.staking.withdrew_staking(address1) 2306 assert_code(result, 0) 2307 # Waiting for the end of the 2 settlement period 2308 economic.wait_settlement_blocknum(node, 2) 2309 log.info("Pledge node information: {}".format(client.ppos.getCandidateInfo(node.node_id))) 2310 return address1, address2 2311 2312 2313 @pytest.mark.P2 2314 def test_LS_CSV_014(client_new_node): 2315 """ 2316 锁仓账户退回质押金后,重新申请质押节点 2317 :param client_new_node: 2318 :return: 2319 """ 2320 client = client_new_node 2321 economic = client.economic 2322 node = client.node 2323 # After returning the deposit 2324 address1, address2 = steps_of_returning_pledge(client, economic, node) 2325 # create Restricting Plan 2326 amount = economic.create_staking_limit 2327 plan = [{'Epoch': 1, 'Amount': amount}] 2328 result = client.restricting.createRestrictingPlan(address1, plan, address1) 2329 assert_code(result, 0) 2330 restricting_info = client.ppos.getRestrictingInfo(address1) 2331 log.info("restricting plan informtion: {}".format(restricting_info)) 2332 # create staking 2333 result = client.staking.create_staking(1, address1, address1) 2334 assert_code(result, 0) 2335 2336 2337 @pytest.mark.P2 2338 def test_LS_CSV_015(client_new_node): 2339 """ 2340 锁仓账户退回质押金后,重新申请委托节点 2341 :param client_new_node: 2342 :return: 2343 """ 2344 client = client_new_node 2345 economic = client.economic 2346 node = client.node 2347 # After returning the deposit 2348 address1, address2 = steps_of_returning_pledge(client, economic, node) 2349 # create Restricting Plan 2350 amount = von_amount(economic.delegate_limit, 10) 2351 plan = [{'Epoch': 1, 'Amount': amount}] 2352 result = client.restricting.createRestrictingPlan(address2, plan, address2) 2353 assert_code(result, 0) 2354 # Free amount Entrust node 2355 result = client.delegate.delegate(0, address2) 2356 assert_code(result, 301102) 2357 # Restricting amount Entrust node 2358 result = client.delegate.delegate(1, address2) 2359 assert_code(result, 301102) 2360 2361 2362 @pytest.mark.P2 2363 def test_LS_CSV_016(client_new_node): 2364 """ 2365 锁仓账户退回质押金后,重新申请增持质押 2366 :param client_new_node: 2367 :return: 2368 """ 2369 client = client_new_node 2370 economic = client.economic 2371 node = client.node 2372 # After returning the deposit 2373 address1, address2 = steps_of_returning_pledge(client, economic, node) 2374 # create Restricting Plan 2375 amount = von_amount(economic.add_staking_limit, 5) 2376 plan = [{'Epoch': 1, 'Amount': amount}] 2377 result = client.restricting.createRestrictingPlan(address1, plan, address1) 2378 assert_code(result, 0) 2379 # Restricting amount Additional pledge 2380 result = client.staking.increase_staking(1, address1) 2381 assert_code(result, 301102) 2382 # Free amount Additional pledge 2383 result = client.staking.increase_staking(0, address1) 2384 assert_code(result, 301102)