@pytest.mark.integration
def test_send_transaction_cached_blockhash(stubbed_sender_cached_blockhash, stubbed_receiver_cached_blockhash, test_http_client_cached_blockhash):
    'Test sending a transaction to localnet.'
    transfer_tx = Transaction().add(sp.transfer(sp.TransferParams(from_pubkey=stubbed_sender_cached_blockhash.public_key, to_pubkey=stubbed_receiver_cached_blockhash, lamports=1000)))
    assert (len(test_http_client_cached_blockhash.blockhash_cache.unused_blockhashes) == 0)
    assert (len(test_http_client_cached_blockhash.blockhash_cache.used_blockhashes) == 0)
    resp = test_http_client_cached_blockhash.send_transaction(transfer_tx, stubbed_sender_cached_blockhash)
    assert (len(test_http_client_cached_blockhash.blockhash_cache.unused_blockhashes) in (0, 1))
    assert (len(test_http_client_cached_blockhash.blockhash_cache.used_blockhashes) == 1)
    assert_valid_response(resp)
    test_http_client_cached_blockhash.confirm_transaction(resp['result'])
    resp = test_http_client_cached_blockhash.get_balance(stubbed_sender_cached_blockhash.public_key)
    assert_valid_response(resp)
    assert (resp['result']['value'] == 9999994000)
    transfer_tx = Transaction().add(sp.transfer(sp.TransferParams(from_pubkey=stubbed_sender_cached_blockhash.public_key, to_pubkey=stubbed_receiver_cached_blockhash, lamports=2000)))
    resp = test_http_client_cached_blockhash.get_balance(stubbed_receiver_cached_blockhash)
    assert_valid_response(resp)
    assert (resp['result']['value'] == 954)
    resp = test_http_client_cached_blockhash.send_transaction(transfer_tx, stubbed_sender_cached_blockhash)
    assert (len(test_http_client_cached_blockhash.blockhash_cache.unused_blockhashes) in (0, 1))
    assert (len(test_http_client_cached_blockhash.blockhash_cache.used_blockhashes) in (1, 2))
    assert_valid_response(resp)
    test_http_client_cached_blockhash.confirm_transaction(resp['result'])
    resp = test_http_client_cached_blockhash.get_balance(stubbed_sender_cached_blockhash.public_key)
    assert_valid_response(resp)
    assert (resp['result']['value'] == 9999987000)
    assert (len(test_http_client_cached_blockhash.blockhash_cache.unused_blockhashes) == 1)
    assert (len(test_http_client_cached_blockhash.blockhash_cache.used_blockhashes) == 1)
Test sending a transaction to localnet.
@pytest.mark.integration
def test_send_transaction_cached_blockhash(stubbed_sender_cached_blockhash, stubbed_receiver_cached_blockhash, test_http_client_cached_blockhash):
    
    transfer_tx = Transaction().add(sp.transfer(sp.TransferParams(from_pubkey=stubbed_sender_cached_blockhash.public_key, to_pubkey=stubbed_receiver_cached_blockhash, lamports=1000)))
    assert (len(test_http_client_cached_blockhash.blockhash_cache.unused_blockhashes) == 0)
    assert (len(test_http_client_cached_blockhash.blockhash_cache.used_blockhashes) == 0)
    resp = test_http_client_cached_blockhash.send_transaction(transfer_tx, stubbed_sender_cached_blockhash)
    assert (len(test_http_client_cached_blockhash.blockhash_cache.unused_blockhashes) in (0, 1))
    assert (len(test_http_client_cached_blockhash.blockhash_cache.used_blockhashes) == 1)
    assert_valid_response(resp)
    test_http_client_cached_blockhash.confirm_transaction(resp['result'])
    resp = test_http_client_cached_blockhash.get_balance(stubbed_sender_cached_blockhash.public_key)
    assert_valid_response(resp)
    assert (resp['result']['value'] == 9999994000)
    transfer_tx = Transaction().add(sp.transfer(sp.TransferParams(from_pubkey=stubbed_sender_cached_blockhash.public_key, to_pubkey=stubbed_receiver_cached_blockhash, lamports=2000)))
    resp = test_http_client_cached_blockhash.get_balance(stubbed_receiver_cached_blockhash)
    assert_valid_response(resp)
    assert (resp['result']['value'] == 954)
    resp = test_http_client_cached_blockhash.send_transaction(transfer_tx, stubbed_sender_cached_blockhash)
    assert (len(test_http_client_cached_blockhash.blockhash_cache.unused_blockhashes) in (0, 1))
    assert (len(test_http_client_cached_blockhash.blockhash_cache.used_blockhashes) in (1, 2))
    assert_valid_response(resp)
    test_http_client_cached_blockhash.confirm_transaction(resp['result'])
    resp = test_http_client_cached_blockhash.get_balance(stubbed_sender_cached_blockhash.public_key)
    assert_valid_response(resp)
    assert (resp['result']['value'] == 9999987000)
    assert (len(test_http_client_cached_blockhash.blockhash_cache.unused_blockhashes) == 1)
    assert (len(test_http_client_cached_blockhash.blockhash_cache.used_blockhashes) == 1)