def test_revert_nym_with_fees_before_catchup(looper, helpers, nodeSetWithIntegratedTokenPlugin, fees_set, fees, xfer_mint_tokens, xfer_addresses): nodes = nodeSetWithIntegratedTokenPlugin current_amount = get_amount_from_token_txn(xfer_mint_tokens) seq_no = get_seq_no(xfer_mint_tokens) lagging_node = nodes[-1] current_amount, seq_no, _ = send_and_check_nym_with_fees( helpers, fees_set, seq_no, looper, xfer_addresses, current_amount) with delay_rules_without_processing(lagging_node.nodeIbStasher, cDelay(), pDelay()): current_amount, seq_no, _ = send_and_check_nym_with_fees( helpers, fees_set, seq_no, looper, xfer_addresses, current_amount) looper.runFor(waits.expectedPrePrepareTime(len(nodes))) lagging_node.start_catchup() for n in nodes: looper.run( eventually(lambda: assertExp(n.mode == Mode.participating))) for n in nodes: looper.run( eventually(check_state, n, True, retryWait=0.2, timeout=15)) ensure_all_nodes_have_same_data(looper, nodes) current_amount, seq_no, _ = send_and_check_nym_with_fees( helpers, fees_set, seq_no, looper, xfer_addresses, current_amount) ensure_all_nodes_have_same_data(looper, nodes)
def test_revert_during_view_change_all_nodes_set_fees( tconf, nodeSetWithIntegratedTokenPlugin, fees_set, helpers, looper): """ Check that SET_FEES transaction will be written after view change when PREPARE quorum for it is reached """ nodes = nodeSetWithIntegratedTokenPlugin node_set = [n.nodeIbStasher for n in nodeSetWithIntegratedTokenPlugin] _old_pp_seq_no = get_ppseqno_from_all_nodes( nodeSetWithIntegratedTokenPlugin) helpers.general.set_fees_without_waiting({ATTRIB_FEES_ALIAS: 3}) assert _old_pp_seq_no == get_ppseqno_from_all_nodes( nodeSetWithIntegratedTokenPlugin) with delay_rules(node_set, cDelay()): # should be changed for auth rule helpers.general.set_fees_without_waiting({ATTRIB_FEES_ALIAS: 4}) looper.run( eventually( functools.partial(check_batch_ordered, _old_pp_seq_no, nodeSetWithIntegratedTokenPlugin))) ensure_view_change(looper, nodes) ensureElectionsDone(looper=looper, nodes=nodes) ensure_all_nodes_have_same_data(looper, nodes) for n in nodes: looper.run(eventually(lambda: assertExp(n.mode == Mode.participating))) for n in nodes: looper.run(eventually(check_state, n, True, retryWait=0.2, timeout=15)) fees = helpers.general.do_get_fees() assert fees[FEES][ATTRIB_FEES_ALIAS] == 4
def test_chain_set_fees_and_nym_batch_size_2(looper, helpers, nodeSetWithIntegratedTokenPlugin, sdk_pool_handle, sdk_wallet_trustee, mint_tokens, addresses, poolConfigWTFF): """ Set FEES for NYM with cost 2 Send any transaction to config ledger. Send NYM with fees 2 from A Set FEES for NYM with cost 3 Send any transaction to config ledger. Send NYM with fees 3 from A Check that first NYM is not written and second NYM is. """ A, B = addresses current_amount = get_amount_from_token_txn(mint_tokens) seq_no = get_seq_no(mint_tokens) # Set fees and some config txn fees_nym_2 = {NYM_FEES_ALIAS: 2} fees_2_resp = helpers.general.set_fees_without_waiting(fees_nym_2) sdk_pool_config_sent(looper, sdk_pool_handle, sdk_wallet_trustee, poolConfigWTFF) sdk_get_and_check_replies(looper, fees_2_resp) # NYM with fees 2 from A _, _, b_2_nym = send_and_check_nym_with_fees(helpers, {'fees': fees_nym_2}, seq_no, looper, [A], current_amount, check_reply=False) # Set fees for NYM to 3 fees_nym_3 = {NYM_FEES_ALIAS: 3} fees_3_resp = helpers.general.set_fees_without_waiting(fees_nym_3) sdk_pool_config_sent(looper, sdk_pool_handle, sdk_wallet_trustee, poolConfigWTFF) sdk_get_and_check_replies(looper, fees_3_resp) # Send NYM with fees 3 current_amount, seq_no, b_3_nym = send_and_check_nym_with_fees( helpers, {'fees': fees_nym_3}, seq_no, looper, [A], current_amount, check_reply=False) with pytest.raises(RequestRejectedException): sdk_get_and_check_replies(looper, b_2_nym) sdk_get_and_check_replies(looper, b_3_nym) a_get = helpers.general.do_get_utxo(A) assert a_get[OUTPUTS][1][AMOUNT] == current_amount assert a_get[OUTPUTS][1][SEQNO] == seq_no ensure_all_nodes_have_same_data(looper, nodeSetWithIntegratedTokenPlugin)
def test_revert_works_for_fees_after_view_change(looper, helpers, nodeSetWithIntegratedTokenPlugin, sdk_pool_handle, fees_set, mint_tokens, addresses, fees): node_set = nodeSetWithIntegratedTokenPlugin current_amount = get_amount_from_token_txn(mint_tokens) seq_no = get_seq_no(mint_tokens) reverted_node = nodeSetWithIntegratedTokenPlugin[-1] current_amount, seq_no, _ = send_and_check_nym_with_fees(helpers, fees_set, seq_no, looper, addresses, current_amount) current_amount, seq_no, _ = send_and_check_transfer(helpers, addresses, fees, looper, current_amount, seq_no) with delay_rules_without_processing(reverted_node.nodeIbStasher, delay_3pc(view_no=0, msgs=Commit)): len_batches_before = len(reverted_node.master_replica._ordering_service.batches) current_amount, seq_no, _ = send_and_check_transfer(helpers, addresses, fees, looper, current_amount, seq_no) current_amount, seq_no, _ = send_and_check_nym_with_fees(helpers, fees_set, seq_no, looper, addresses, current_amount) looper.runFor(waits.expectedPrePrepareTime(len(nodeSetWithIntegratedTokenPlugin))) len_batches_after = len(reverted_node.master_replica._ordering_service.batches) """ Checks, that we have a 2 new batches """ assert len_batches_after - len_batches_before == 2 for n in node_set: n.view_changer.on_master_degradation() ensure_view_change(looper, nodeSetWithIntegratedTokenPlugin) looper.run(eventually(lambda: assertExp(reverted_node.mode == Mode.participating))) ensure_all_nodes_have_same_data(looper, node_set) send_and_check_nym_with_fees(helpers, fees_set, seq_no, looper, addresses, current_amount) ensure_all_nodes_have_same_data(looper, node_set)
def test_validation_nym_with_fees_more_than_required(fees, helpers, nodeSetWithIntegratedTokenPlugin, address_main, sdk_pool_handle, sdk_wallet_trustee, mint_tokens, looper): """ Steps: 1. Checks that nym with fees will be rejected, because fees are not set 2. Send auth_rule txn with fees in metadata and set fees for pool 3. Resend nym with fees more than required and check, that it will be rejected """ current_amount = get_amount_from_token_txn(mint_tokens) seq_no = 1 with pytest.raises(RequestRejectedException, match="Fees are not required for this txn type"): current_amount, seq_no, _ = send_and_check_nym_with_fees(helpers, {FEES: fees}, seq_no, looper, [address_main], current_amount) helpers.general.do_set_fees(fees, fill_auth_map=False) original_action = add_new_identity_owner original_constraint = auth_map.get(add_new_identity_owner.get_action_id()) original_constraint.set_metadata({'fees': NYM_FEES_ALIAS}) sdk_send_and_check_auth_rule_request(looper, sdk_pool_handle, sdk_wallet_trustee, auth_action=ADD_PREFIX, auth_type=NYM, field=original_action.field, new_value=original_action.value, old_value=None, constraint=original_constraint.as_dict) with pytest.raises(RequestRejectedException, match="ExtraFundsError"): current_amount, seq_no, _ = send_and_check_nym_with_fees(helpers, {FEES: {NYM_FEES_ALIAS: fees[NYM_FEES_ALIAS] + 1}}, seq_no, looper, [address_main], current_amount) ensure_all_nodes_have_same_data(looper, nodeSetWithIntegratedTokenPlugin)
def test_revert_set_fees_and_view_change_all_nodes( nodeSetWithIntegratedTokenPlugin, xfer_mint_tokens, helpers, looper, xfer_addresses): """ Send SET_FEES and init view change. Check that it is reverted and transaction passes with old fees """ def _get_len_preprepares(n): replica = n.master_replica return len(replica._ordering_service.sent_preprepares if replica. isPrimary else replica._ordering_service.prePrepares) def _check_len_pprs(old_pprs_len): _len_pprs = set([ _get_len_preprepares(n) for n in nodeSetWithIntegratedTokenPlugin ]) _len_ppr = _len_pprs.pop() assert old_pprs_len + 1 == _len_ppr helpers.general.do_set_fees({NYM_FEES_ALIAS: 3}) nodes = nodeSetWithIntegratedTokenPlugin node_stashers = [n.nodeIbStasher for n in nodeSetWithIntegratedTokenPlugin] seq_no = get_seq_no(xfer_mint_tokens) _old_len_pprs = set( [_get_len_preprepares(n) for n in nodeSetWithIntegratedTokenPlugin]) assert len(_old_len_pprs) _old_len_ppr = _old_len_pprs.pop() with delay_rules_without_processing(node_stashers, cDelay()): helpers.general.set_fees_without_waiting({NYM_FEES_ALIAS: 5}) looper.run(eventually(functools.partial(_check_len_pprs, _old_len_ppr))) send_and_check_nym_with_fees(helpers, {FEES: { NYM_FEES_ALIAS: 5 }}, seq_no, looper, xfer_addresses, 1000, check_reply=False) for n in nodeSetWithIntegratedTokenPlugin: n.start_catchup() for n in nodes: looper.run( eventually(lambda: assertExp(n.mode == Mode.participating))) ensure_all_nodes_have_same_data(looper, nodes) send_and_check_nym_with_fees(helpers, {FEES: { NYM_FEES_ALIAS: 3 }}, seq_no, looper, xfer_addresses, 1000, check_reply=False) ensure_all_nodes_have_same_data(looper, nodes)
def scenario_txns_during_view_change(looper, helpers, nodes, io_addresses, send_txns, send_txns_invalid=None): lagging_node = nodes[-1] rest_nodes = nodes[:-1] def send_txns_invalid_default(): # TODO non-public API is used addr = helpers.wallet.address_map[io_addresses()[0][0]] seq_no = list(addr.outputs[0])[0] assert addr.outputs[0][seq_no] > 0 # de-sync client-server utxos states addr.outputs[0][seq_no] += 1 with pytest.raises(RequestRejectedException, match='Insufficient funds'): send_txns() # sync back client-server utxos states addr.outputs[0][seq_no] -= 1 # Send transactions send_txns() ensure_all_nodes_have_same_data(looper, nodes) # Lag one node (delay Prepare and Commit messages for lagging_node) with delay_rules(lagging_node.nodeIbStasher, pDelay(), cDelay()): # Send more transactions send_txns() ensure_all_nodes_have_same_data(looper, rest_nodes) # Send invalid transactions (send_txns_invalid or send_txns_invalid_default)() ensure_all_nodes_have_same_data(looper, rest_nodes) # Initiate view change # Wait until view change is finished and check that needed transactions are written. ensure_view_change(looper, nodes) looper.run(eventually(check_not_in_view_change, nodes)) ensureElectionsDone(looper, nodes) # Reset delays # Make sure that all nodes have equal state # (expecting that lagging_node caught up missed ones) ensure_all_nodes_have_same_data(looper, nodes) # make sure the poll is functional send_txns() ensure_all_nodes_have_same_data(looper, nodes)
def test_fees_not_set_and_nym_with_fees(helpers, nodeSetWithIntegratedTokenPlugin, sdk_wallet_steward, address_main, sdk_pool_handle, sdk_wallet_trustee, mint_tokens, looper): """ Steps: 1. Checks that nym with zero fees is valid """ current_amount = get_amount_from_token_txn(mint_tokens) seq_no = 1 fees = {NYM_FEES_ALIAS: 0} current_amount, seq_no, _ = send_and_check_nym_with_fees(helpers, {FEES: fees}, seq_no, looper, [address_main], current_amount) sdk_add_new_nym(looper, sdk_pool_handle, sdk_wallet_steward) ensure_all_nodes_have_same_data(looper, nodeSetWithIntegratedTokenPlugin)
def scenario_txns_during_catchup( looper, tconf, tdir, allPluginsPath, do_post_node_creation, nodes, send_txns ): lagging_node = nodes[-1] rest_nodes = nodes[:-1] # Stop NodeX lagging_node.cleanupOnStopping = False disconnect_node_and_ensure_disconnected(looper, nodes, lagging_node.name, stopNode=True) looper.removeProdable(name=lagging_node.name) # Send transactions send_txns() ensure_all_nodes_have_same_data(looper, rest_nodes) # Start NodeX lagging_node = start_stopped_node( lagging_node, looper, tconf, tdir, allPluginsPath, start=False, ) do_post_node_creation(lagging_node) HelperNode.fill_auth_map_for_node(lagging_node, XFER_PUBLIC) HelperNode.fill_auth_map_for_node(lagging_node, NYM) nodes[-1] = lagging_node # Delay CathupRep for DOMAIN ledger for NodeX with delay_rules( lagging_node.nodeIbStasher, cr_delay(ledger_filter=DOMAIN_LEDGER_ID) ): # allow started node to receive looper events looper.add(lagging_node) # ensure it connected to others looper.run(checkNodesConnected(nodes)) # Send transactions send_txns() ensure_all_nodes_have_same_data(looper, rest_nodes) # Reset delays # Make sure that all nodes have equal state ensure_all_nodes_have_same_data(looper, nodes) # Send transactions send_txns() ensure_all_nodes_have_same_data(looper, rest_nodes)
def scenario_txns_during_view_change(looper, nodes, curr_utxo, send_txns, send_txns_invalid=None): lagging_node = nodes[-1] rest_nodes = nodes[:-1] def send_txns_invalid_default(): curr_utxo['amount'] += 1 with pytest.raises(RequestRejectedException, match='Insufficient funds'): send_txns() curr_utxo['amount'] -= 1 # Send transactions send_txns() ensure_all_nodes_have_same_data(looper, nodes) # Lag one node (delay Prepare and Commit messages for lagging_node) with delay_rules(lagging_node.nodeIbStasher, pDelay(), cDelay()): # Send more transactions send_txns() ensure_all_nodes_have_same_data(looper, rest_nodes) # Send invalid transactions (send_txns_invalid or send_txns_invalid_default)() ensure_all_nodes_have_same_data(looper, rest_nodes) # Initiate view change # Wait until view change is finished and check that needed transactions are written. ensure_view_change(looper, nodes) ensureElectionsDone(looper, nodes) # Reset delays # Make sure that all nodes have equal state # (expecting that lagging_node caught up missed ones) ensure_all_nodes_have_same_data(looper, nodes) # make sure the poll is functional send_txns() ensure_all_nodes_have_same_data(looper, nodes)
def test_revert_during_view_change_all_nodes_xfer_with_fees( nodeSetWithIntegratedTokenPlugin, xfer_mint_tokens, fees_set, helpers, looper, xfer_addresses): """ Check that XFER and SET_FEES transaction will be written after view change when PREPARE quorum for it is reached """ nodes = nodeSetWithIntegratedTokenPlugin node_set = [n.nodeIbStasher for n in nodeSetWithIntegratedTokenPlugin] addr = xfer_addresses[0] utxo = helpers.general.get_utxo_addresses([addr])[0] outputs = [{ADDRESS: xfer_addresses[1], AMOUNT: 998}] _old_pp_seq_no = get_ppseqno_from_all_nodes( nodeSetWithIntegratedTokenPlugin) with delay_rules(node_set, cDelay()): # should be changed for auth rule helpers.general.set_fees_without_waiting({XFER_PUBLIC_FEES_ALIAS: 2}) looper.run( eventually( functools.partial(check_batch_ordered, _old_pp_seq_no, nodeSetWithIntegratedTokenPlugin))) helpers.general.transfer_without_waiting(utxo, outputs) looper.run( eventually( functools.partial(check_batch_ordered, _old_pp_seq_no + 1, nodeSetWithIntegratedTokenPlugin))) ensure_view_change(looper, nodes) ensureElectionsDone(looper=looper, nodes=nodes) ensure_all_nodes_have_same_data(looper, nodes) for n in nodes: looper.run(eventually(lambda: assertExp(n.mode == Mode.participating))) for n in nodes: looper.run(eventually(check_state, n, True, retryWait=0.2, timeout=15)) utxos = helpers.general.get_utxo_addresses(xfer_addresses[1:])[0] assert utxos[0][PAYMENT_ADDRESS] == xfer_addresses[1] assert utxos[0][AMOUNT] == 998
def test_revert_for_all_after_view_change(looper, helpers, nodeSetWithIntegratedTokenPlugin, sdk_pool_handle, fees_set, mint_tokens, addresses, fees): node_set = nodeSetWithIntegratedTokenPlugin current_amount = get_amount_from_token_txn(mint_tokens) seq_no = get_seq_no(mint_tokens) reverted_node = nodeSetWithIntegratedTokenPlugin[-1] current_amount, seq_no, _ = send_and_check_nym_with_fees( helpers, fees_set, seq_no, looper, addresses, current_amount) current_amount, seq_no, _ = send_and_check_transfer( helpers, addresses, fees, looper, current_amount, seq_no) ensure_all_nodes_have_same_data(looper, node_set) with delay_rules([n.nodeIbStasher for n in node_set], cDelay(), pDelay()): len_batches_before = len(reverted_node.master_replica.batches) current_amount, seq_no, resp1 = send_and_check_transfer( helpers, addresses, fees, looper, current_amount, seq_no, check_reply=False) current_amount, seq_no, resp2 = send_and_check_nym_with_fees( helpers, fees_set, seq_no, looper, addresses, current_amount, check_reply=False) looper.runFor( waits.expectedPrePrepareTime( len(nodeSetWithIntegratedTokenPlugin))) len_batches_after = len(reverted_node.master_replica.batches) """ Checks, that we have a 2 new batches """ assert len_batches_after - len_batches_before == 2 for n in node_set: n.view_changer.on_master_degradation() ensure_view_change_complete(looper, nodeSetWithIntegratedTokenPlugin) looper.run( eventually( lambda: assertExp(reverted_node.mode == Mode.participating))) ensure_all_nodes_have_same_data(looper, node_set) sdk_get_and_check_replies(looper, resp1) sdk_get_and_check_replies(looper, resp2) send_and_check_nym_with_fees(helpers, fees_set, seq_no, looper, addresses, current_amount) ensure_all_nodes_have_same_data(looper, node_set)
def test_validation_nym_with_zero_fees(helpers, nodeSetWithIntegratedTokenPlugin, sdk_wallet_steward, address_main, sdk_pool_handle, sdk_wallet_trustee, mint_tokens, looper): """ Steps: 1. Checks that nym with zero fees is valid 2. Send auth_rule txn with zero fees in metadata 3. Resend nym with fees and check, that it will be valid, because fees is 0, but fees are set in request """ current_amount = get_amount_from_token_txn(mint_tokens) seq_no = 1 fees = {NYM_FEES_ALIAS: 0} helpers.general.do_set_fees(fees, fill_auth_map=False) current_amount, seq_no, _ = send_and_check_nym_with_fees( helpers, {FEES: fees}, seq_no, looper, [address_main], current_amount) sdk_add_new_nym(looper, sdk_pool_handle, sdk_wallet_steward) original_action = add_new_identity_owner original_constraint = auth_map.get(add_new_identity_owner.get_action_id()) original_constraint.set_metadata({'fees': NYM_FEES_ALIAS}) sdk_send_and_check_auth_rule_request( looper, sdk_pool_handle, sdk_wallet_trustee, auth_action=ADD_PREFIX, auth_type=NYM, field=original_action.field, new_value=original_action.value, old_value=None, constraint=original_constraint.as_dict) current_amount, seq_no, _ = send_and_check_nym_with_fees( helpers, {FEES: fees}, seq_no, looper, [address_main], current_amount) sdk_add_new_nym(looper, sdk_pool_handle, sdk_wallet_steward) ensure_all_nodes_have_same_data(looper, nodeSetWithIntegratedTokenPlugin)
def test_chain_set_fees_and_xfer_batch_size_2(looper, helpers, nodeSetWithIntegratedTokenPlugin, sdk_pool_handle, sdk_wallet_trustee, mint_tokens, addresses, poolConfigWTFF): """ Set FEES for XFER for 2 Send any transaction to config ledger. Send XFER with fees 2 from A to B Set FEES for XFER for 3 Send any transaction to config ledger. Send XFER with fees 3 from A to B Check that first XFER is not written and second XFER is. """ A, B = addresses current_amount = get_amount_from_token_txn(mint_tokens) seq_no = get_seq_no(mint_tokens) transfer_summ = 20 # Set fees and some config txn helpers.node.set_fees_directly({XFER_PUBLIC_FEES_ALIAS: 42}) fees_xfer_2 = {XFER_PUBLIC_FEES_ALIAS: 2} fees_2_rsp = helpers.general.set_fees_without_waiting(fees_xfer_2) sdk_pool_config_sent(looper, sdk_pool_handle, sdk_wallet_trustee, poolConfigWTFF) sdk_get_and_check_replies(looper, fees_2_rsp) # XFER with fees 2 from A to B _, _, a_b_transfer_2 = send_and_check_transfer(helpers, [A, B], fees_xfer_2, looper, current_amount, seq_no, transfer_summ=transfer_summ, check_reply=False) # Set fees for XFER to 3 fees_xfer_3 = {XFER_PUBLIC_FEES_ALIAS: 3} fees_3_rsp = helpers.general.set_fees_without_waiting(fees_xfer_3) sdk_pool_config_sent(looper, sdk_pool_handle, sdk_wallet_trustee, poolConfigWTFF) sdk_get_and_check_replies(looper, fees_3_rsp) # Send XFER with fees from A to B a_amount, seq_no, a_b_transfer_3 = send_and_check_transfer( helpers, [A, B], fees_xfer_3, looper, current_amount, seq_no, transfer_summ=transfer_summ, check_reply=False) for n in nodeSetWithIntegratedTokenPlugin: fee_rq = n.ledger_to_req_handler[CONFIG_LEDGER_ID] assert fee_rq.fees == fees_xfer_3 with pytest.raises(RequestRejectedException): sdk_get_and_check_replies(looper, a_b_transfer_2) sdk_get_and_check_replies(looper, a_b_transfer_3) a_get = helpers.general.do_get_utxo(A) assert a_get[OUTPUTS][1][AMOUNT] == a_amount assert a_get[OUTPUTS][1][SEQNO] == seq_no b_get = helpers.general.do_get_utxo(B) assert b_get[OUTPUTS][0][AMOUNT] == transfer_summ assert b_get[OUTPUTS][0][SEQNO] == seq_no ensure_all_nodes_have_same_data(looper, nodeSetWithIntegratedTokenPlugin)
def test_first_catchup_for_a_new_node(looper, helpers, nodeSetWithIntegratedTokenPlugin, sdk_pool_handle, sdk_wallet_trustee, fees_set, mint_tokens, addresses, fees, tconf, tdir, allPluginsPath, do_post_node_creation, testNodeClass): node_set = nodeSetWithIntegratedTokenPlugin current_amount = get_amount_from_token_txn(mint_tokens) seq_no = 1 reverted_node = node_set[-1] idx = node_set.index(reverted_node) current_amount, seq_no, _ = send_and_check_nym_with_fees( helpers, fees_set, seq_no, looper, addresses, current_amount) reverted_node.cleanupOnStopping = False disconnect_node_and_ensure_disconnected(looper, node_set, reverted_node.name) looper.removeProdable(name=reverted_node.name) from_a_to_b = [addresses[0], addresses[1]] from_b_to_c = [addresses[1], addresses[2]] from_c_to_d = [addresses[2], addresses[3]] from_d_to_a = [addresses[3], addresses[0]] # current_amount, seq_no, _ = add_nym_with_fees(helpers, fees_set, seq_no, looper, addresses, current_amount) current_amount, seq_no, _ = send_and_check_transfer( helpers, from_a_to_b, fees, looper, current_amount, seq_no, transfer_summ=current_amount) current_amount, seq_no, _ = send_and_check_transfer( helpers, from_b_to_c, fees, looper, current_amount, seq_no, transfer_summ=current_amount) current_amount, seq_no, _ = send_and_check_transfer( helpers, from_c_to_d, fees, looper, current_amount, seq_no, transfer_summ=current_amount) add_new_node(helpers, looper, node_set, sdk_wallet_trustee, current_amount, seq_no, fees_set, sdk_pool_handle, tdir, tconf, allPluginsPath, addresses[3], do_post_node_creation, node_class=testNodeClass) current_amount, seq_no, _ = send_and_check_transfer( helpers, from_d_to_a, fees, looper, current_amount, seq_no, transfer_summ=current_amount) ensure_all_nodes_have_same_data(looper, node_set)
def test_chain_fees_and_xfer_batch_size_2(looper, helpers, nodeSetWithIntegratedTokenPlugin, fees_set, mint_tokens, addresses, fees): """ Set FEES for NYM transaction Send XFER from A to B Send NYM with fees from A using the UTXO as in 2 Send XFER from B to C Send NYM with fees from C Check that XFERs are written Check that first NYM is not written and the second one is written. """ a_amount = get_amount_from_token_txn(mint_tokens) seq_no = get_seq_no(mint_tokens) initial_seq_no = seq_no A, B, C = addresses transfer_summ = 20 # From A to B transfer a_amount, seq_no, a_b_transfer = send_and_check_transfer( helpers, [A, B], fees, looper, a_amount, seq_no, transfer_summ=transfer_summ, check_reply=False) # NYM with fees from A and utxo as for previous case _, _, a_nym = send_and_check_nym_with_fees(helpers, fees_set, initial_seq_no, looper, [A], a_amount + transfer_summ, check_reply=False) # From B to C transfer b_amount, seq_no, b_c_transfer = send_and_check_transfer( helpers, [B, C], fees, looper, transfer_summ, seq_no, transfer_summ=transfer_summ, check_reply=False) sdk_get_and_check_replies(looper, a_b_transfer) sdk_get_and_check_replies(looper, b_c_transfer) b_c_get = helpers.general.do_get_utxo(B) assert len(b_c_get[OUTPUTS]) == 0 # NYM with fees from C c_nym_amount, seq_no, c_nym = send_and_check_nym_with_fees( helpers, fees_set, seq_no, looper, [C], transfer_summ, check_reply=False) with pytest.raises(RequestRejectedException, match="are not found in list"): sdk_get_and_check_replies(looper, a_nym) a_b_get = helpers.general.do_get_utxo(A) assert a_b_get[OUTPUTS][1][AMOUNT] == a_amount sdk_get_and_check_replies(looper, c_nym) c_nym_get = helpers.general.do_get_utxo(C) assert c_nym_get[OUTPUTS][0][ AMOUNT] == c_nym_amount == transfer_summ - fees.get(NYM_FEES_ALIAS, 0) ensure_all_nodes_have_same_data(looper, nodeSetWithIntegratedTokenPlugin)