示例#1
0
def test_valid_txn_with_fees(helpers, mint_tokens, fees_set,
                             nodeSetWithIntegratedTokenPlugin, looper,
                             address_main, addresses, tdir, tconf):
    seq_no = get_seq_no(mint_tokens)
    remaining = 1000
    last_node = nodeSetWithIntegratedTokenPlugin[-1]
    last_node.stop()
    looper.removeProdable(last_node)
    token_req_handler = last_node.get_req_handler(TOKEN_LEDGER_ID)
    token_req_handler.utxo_cache._store.close()

    nodeSetWithIntegratedTokenPlugin = nodeSetWithIntegratedTokenPlugin[:-1]

    for address in addresses:
        inputs = [
            {
                ADDRESS: address_main,
                SEQNO: seq_no
            },
        ]
        outputs = [
            {
                ADDRESS: address,
                AMOUNT: 1
            },
            {
                ADDRESS: address_main,
                AMOUNT: remaining - 2
            },  # XFER fee is 1
        ]
        request = helpers.request.transfer(inputs, outputs)
        response = helpers.sdk.send_and_check_request_objects([request])
        result = helpers.sdk.get_first_result(response)
        seq_no = get_seq_no(result)
        remaining -= 2

    for _ in range(5):
        pay_fees(helpers, fees_set, address_main)

    config_helper = PNodeConfigHelper(last_node.name, tconf, chroot=tdir)
    restarted_node = TestNode(last_node.name,
                              config_helper=config_helper,
                              config=tconf,
                              ha=last_node.nodestack.ha,
                              cliha=last_node.clientstack.ha)

    integrate_token_plugin_in_node(restarted_node)
    integrate_fees_plugin_in_node(restarted_node)

    tl = restarted_node.getLedger(TOKEN_LEDGER_ID)
    for node in nodeSetWithIntegratedTokenPlugin:
        token_ledger = node.getLedger(TOKEN_LEDGER_ID)
        assert token_ledger.size > tl.size

    looper.add(restarted_node)
    nodeSetWithIntegratedTokenPlugin.append(restarted_node)

    ensure_all_nodes_have_same_data(looper, nodeSetWithIntegratedTokenPlugin)
def last_txn(request, helpers, nodeSetWithIntegratedTokenPlugin, addresses, fees_set, make_tokens):
    if request.param == 'FEES':
        return pay_fees(helpers, fees_set, addresses[1])[FEES]
    if request.param == 'XFER':
        inputs = helpers.general.get_utxo_addresses(addresses[1:])
        inputs = [utxo for utxos in inputs for utxo in utxos]
        outputs = [{ADDRESS: addresses[0], AMOUNT: 992}]
        return helpers.general.do_transfer(inputs, outputs)
    if request.param == 'MINT':
        return make_tokens
def fees_paid(helpers, fees_set, address_main, mint_tokens):
    return pay_fees(helpers, fees_set, address_main)