github.com/platonnetwork/platon-go@v0.7.6/cases/tests/ppos_2/test_check_topics.py (about)

     1  # -*- coding: utf-8 -*-
     2  from tests.lib.utils import *
     3  import pytest
     4  from common.key import mock_duplicate_sign
     5  from tests.ppos_2.conftest import check_receipt
     6  
     7  
     8  @pytest.fixture()
     9  def set_not_need_analyze(client_new_node):
    10      client_new_node.ppos.need_analyze = False
    11      yield client_new_node
    12      client_new_node.ppos.need_analyze = True
    13  
    14  
    15  @pytest.mark.P3
    16  def test_staking_receipt(set_not_need_analyze):
    17      client = set_not_need_analyze
    18      node = client.node
    19      economic = client.economic
    20      address, _ = client.economic.account.generate_account(node.web3, economic.create_staking_limit * 2)
    21      hash = client.staking.create_staking(0, address, address)
    22      log.info(hash)
    23      key = "topics"
    24      expected_result = []
    25      check_receipt(node, hash, key, expected_result)
    26  
    27  
    28  @pytest.mark.P3
    29  def test_delegate_receipt(set_not_need_analyze):
    30      client = set_not_need_analyze
    31      node = client.node
    32      economic = client.economic
    33      address, _ = economic.account.generate_account(node.web3, economic.create_staking_limit * 2)
    34      address, pri_key = economic.account.generate_account(node.web3, economic.delegate_limit * 10)
    35      hash = client.staking.create_staking(0, address, address)
    36      node.eth.waitForTransactionReceipt(hash)
    37      hash = client.delegate.delegate(0, address)
    38      log.info(hash)
    39      key = "topics"
    40      expected_result = []
    41      check_receipt(node, hash, key, expected_result)
    42  
    43  
    44  @pytest.mark.P3
    45  def test_withdrewDelegate_receipt(client_new_node):
    46      client = client_new_node
    47      node = client.node
    48      economic = client.economic
    49      staking_address, _ = economic.account.generate_account(node.web3, economic.create_staking_limit * 2)
    50      delegate_address, pri_key = economic.account.generate_account(node.web3, economic.delegate_limit * 10)
    51      client.ppos.need_analyze = True
    52      client.staking.create_staking(0, staking_address, staking_address)
    53      client.delegate.delegate(0, delegate_address)
    54      msg = client.ppos.getCandidateInfo(node.node_id)
    55      staking_blocknum = msg["Ret"]["StakingBlockNum"]
    56      client.ppos.need_analyze = False
    57      hash = client.delegate.withdrew_delegate(staking_blocknum, delegate_address)
    58      key = "topics"
    59      expected_result = []
    60      check_receipt(node, hash, key, expected_result)
    61      client.ppos.need_analyze = True
    62  
    63  
    64  @pytest.mark.P3
    65  def test_increase_staking_receipt(set_not_need_analyze):
    66      client = set_not_need_analyze
    67      node = client.node
    68      economic = client.economic
    69      address, _ = economic.account.generate_account(node.web3, economic.create_staking_limit * 2)
    70      log.info(client.ppos.need_analyze)
    71  
    72      hash = client.staking.create_staking(0, address, address)
    73      node.eth.waitForTransactionReceipt(hash)
    74      hash = client.staking.increase_staking(0, address)
    75      log.info(hash)
    76      key = "topics"
    77      expected_result = []
    78      check_receipt(node, hash, key, expected_result)
    79  
    80  
    81  @pytest.mark.P3
    82  def test_edit_candidate_receipt(set_not_need_analyze):
    83      client = set_not_need_analyze
    84      node = client.node
    85      economic = client.economic
    86      address, pri_key = economic.account.generate_account(node.web3, economic.create_staking_limit * 2)
    87      hash = client.staking.create_staking(0, address, address)
    88      node.eth.waitForTransactionReceipt(hash)
    89      hash = client.staking.edit_candidate(address, address)
    90      key = "topics"
    91      expected_result = []
    92      check_receipt(node, hash, key, expected_result)
    93  
    94  
    95  @pytest.mark.P3
    96  def test_withdrew_staking_receipt(set_not_need_analyze):
    97      client = set_not_need_analyze
    98      node = client.node
    99      economic = client.economic
   100      address, _ = economic.account.generate_account(node.web3, economic.create_staking_limit * 2)
   101  
   102      hash = client.staking.create_staking(0, address, address)
   103      node.eth.waitForTransactionReceipt(hash)
   104      hash = client.staking.withdrew_staking(address)
   105      key = "topics"
   106      expected_result = []
   107      check_receipt(node, hash, key, expected_result)
   108  
   109  
   110  @pytest.mark.P3
   111  def test_createRestrictingPlan_receipt(set_not_need_analyze):
   112      client = set_not_need_analyze
   113      node = client.node
   114      economic = client.economic
   115      address, _ = economic.account.generate_account(node.web3, economic.create_staking_limit * 2)
   116      lockup_amount = client.node.web3.toWei(20, "ether")
   117      plan = [{'Epoch': 1, 'Amount': lockup_amount}]
   118      # Create a lock plan
   119      hash = client.restricting.createRestrictingPlan(address, plan, address)
   120      key = "topics"
   121      expected_result = []
   122      check_receipt(node, hash, key, expected_result)
   123  
   124  
   125  @pytest.mark.P3
   126  def test_reportDuplicateSign_receipt(set_not_need_analyze):
   127      client = set_not_need_analyze
   128      node = client.node
   129      economic = client.economic
   130      address, _ = economic.account.generate_account(node.web3, economic.create_staking_limit * 2)
   131      number = client.node.eth.blockNumber
   132      report_information = mock_duplicate_sign(1, client.node.nodekey, client.node.blsprikey, number)
   133      address_, _ = economic.account.generate_account(node.web3, economic.create_staking_limit * 2)
   134      hash = client.duplicatesign.reportDuplicateSign(1, report_information, address_)
   135      key = "topics"
   136      expected_result = []
   137      check_receipt(node, hash, key, expected_result)