mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 22:24:23 +01:00
Adds tests for check_tx_in_chain
This commit is contained in:
@@ -4,7 +4,7 @@ from pisa import c_logger
|
||||
from pisa.carrier import Carrier
|
||||
from test.simulator.utils import sha256d
|
||||
from test.simulator.transaction import TX
|
||||
from test.unit.conftest import generate_blocks, get_random_value_hex
|
||||
from test.unit.conftest import generate_blocks, generate_block, get_random_value_hex
|
||||
from pisa.rpc_errors import RPC_VERIFY_ALREADY_IN_CHAIN, RPC_DESERIALIZATION_ERROR
|
||||
|
||||
c_logger.disabled = True
|
||||
@@ -72,3 +72,24 @@ def test_get_non_existing_transaction():
|
||||
tx_info = Carrier.get_transaction(get_random_value_hex(32))
|
||||
|
||||
assert tx_info is None
|
||||
|
||||
|
||||
def test_check_tx_in_chain(carrier):
|
||||
# Let's starts by looking for a random transaction
|
||||
random_tx = TX.create_dummy_transaction()
|
||||
random_txid = sha256d(random_tx)
|
||||
tx_in_chain, confirmations = carrier.check_tx_in_chain(random_txid)
|
||||
assert tx_in_chain is False and confirmations is None
|
||||
|
||||
# We can now broadcast the transaction and check again
|
||||
carrier.send_transaction(random_tx, random_txid)
|
||||
tx_in_chain, confirmations = carrier.check_tx_in_chain(random_txid)
|
||||
|
||||
# The tx should be on mempool now, so same
|
||||
assert tx_in_chain is False and confirmations is None
|
||||
|
||||
# Finally we can mine a block and check again
|
||||
generate_block()
|
||||
tx_in_chain, confirmations = carrier.check_tx_in_chain(random_txid)
|
||||
|
||||
assert tx_in_chain is True and confirmations == 1
|
||||
|
||||
Reference in New Issue
Block a user