Skip to content

Commit

Permalink
migrate blocks.py test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Jan 25, 2025
1 parent 29ea42d commit 694b18a
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions counterparty-core/counterpartycore/pytest/mocks/bitcoind.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def dummy_tx(
utxo_destination=None,
use_first_tx=False,
fee=2000,
data=None,
):
# we take an existing tx to avoid foreign key constraint errors
cursor = ledger_db.cursor()
Expand Down Expand Up @@ -105,6 +106,7 @@ def dummy_tx(
"destination": destination,
"btc_amount": btc_amount,
"fee": fee,
"data": data,
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from counterpartycore.lib.messages import send
from counterpartycore.lib.messages.versions import send1
from counterpartycore.lib.parser import blocks


def test_parse_tx_simple(ledger_db, defaults, blockchain_mock, test_helpers):
_source, _destination, data = send.compose(
ledger_db, defaults["addresses"][0], defaults["addresses"][1], "XCP", 100
)
tx = blockchain_mock.dummy_tx(ledger_db, defaults["addresses"][0], data=data)
blocks.parse_tx(ledger_db, tx)

test_helpers.check_records(
ledger_db,
[
{
"table": "sends",
"values": {
"asset": "XCP",
"block_index": tx["block_index"],
"destination": defaults["addresses"][1],
"quantity": 100,
"source": defaults["addresses"][0],
"status": "valid",
"tx_hash": tx["tx_hash"],
"tx_index": tx["tx_index"],
},
}
],
)


def test_parse_tx_multisig(ledger_db, defaults, blockchain_mock, test_helpers):
_source, _destination, data = send1.compose(
ledger_db, defaults["addresses"][0], defaults["p2ms_addresses"][0], "XCP", 100
)
tx = blockchain_mock.dummy_tx(
ledger_db, defaults["addresses"][0], defaults["p2ms_addresses"][0], data=data
)
blocks.parse_tx(ledger_db, tx)

test_helpers.check_records(
ledger_db,
[
{
"table": "sends",
"values": {
"asset": "XCP",
"block_index": tx["block_index"],
"destination": defaults["p2ms_addresses"][0],
"quantity": 100,
"source": defaults["addresses"][0],
"status": "valid",
"tx_hash": tx["tx_hash"],
"tx_index": tx["tx_index"],
},
}
],
)

0 comments on commit 694b18a

Please sign in to comment.