From ec1fddf38a5723c7e98a53a1d645a38a598da2a4 Mon Sep 17 00:00:00 2001 From: Ouziel Slama Date: Sat, 4 Jan 2025 21:34:36 +0000 Subject: [PATCH] fix and add tests --- .../counterpartycore/lib/message_type.py | 6 +++- .../fixtures/scenarios/multisig_1_of_2.log | 2 ++ .../fixtures/scenarios/multisig_1_of_2.sql | 1 + .../fixtures/scenarios/multisig_1_of_3.log | 2 ++ .../fixtures/scenarios/multisig_1_of_3.sql | 1 + .../fixtures/scenarios/multisig_2_of_2.log | 2 ++ .../fixtures/scenarios/multisig_2_of_2.sql | 1 + .../fixtures/scenarios/multisig_2_of_3.log | 2 ++ .../fixtures/scenarios/multisig_2_of_3.sql | 1 + .../fixtures/scenarios/multisig_3_of_3.log | 2 ++ .../fixtures/scenarios/multisig_3_of_3.sql | 1 + .../scenarios/parseblock_unittest_fixture.log | 2 ++ .../scenarios/parseblock_unittest_fixture.sql | 1 + .../test/fixtures/scenarios/simplesig.log | 2 ++ .../test/fixtures/scenarios/simplesig.sql | 1 + .../fixtures/scenarios/unittest_fixture.log | 2 ++ .../fixtures/scenarios/unittest_fixture.sql | 1 + .../counterpartycore/test/fixtures/vectors.py | 28 +++++++++++++++---- 18 files changed, 51 insertions(+), 7 deletions(-) diff --git a/counterparty-core/counterpartycore/lib/message_type.py b/counterparty-core/counterpartycore/lib/message_type.py index bfb81ab6a..f73b37425 100644 --- a/counterparty-core/counterpartycore/lib/message_type.py +++ b/counterparty-core/counterpartycore/lib/message_type.py @@ -75,7 +75,11 @@ def get_transaction_type(data: bytes, destination: str, utxos_info: list, block_ if not data: if destination == config.UNSPENDABLE and block_index <= config.BURN_END: return "burn" - if block_index >= util.get_change_block_index("utxo_support") and utxos_info[0] != "": + if ( + block_index >= util.get_change_block_index("utxo_support") + and len(utxos_info) > 0 + and utxos_info[0] != "" + ): return "utxomove" if ( destination != config.UNSPENDABLE diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_2.log b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_2.log index 963cbf056..d4108a506 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_2.log +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_2.log @@ -1,4 +1,6 @@ Initializing database... +Updating `transaction_type` column in `transactions` table... +Updated 0 transactions in 0.00 seconds Adding `send_type` column to `sends` table Added `send_type` column to `sends` table in 0.00 seconds Adding `source_address` and `destination_address` column to `sends` table diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_2.sql b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_2.sql index 6b8a691a5..b41e26816 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_2.sql +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_2.sql @@ -301,6 +301,7 @@ CREATE TABLE config ( name TEXT PRIMARY KEY, value TEXT ); +INSERT INTO config VALUES('FIX_TRANSACTION_TYPE_1','1'); INSERT INTO config VALUES('FIX_ASSET_EVENTS_FIELD_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_2','1'); diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_3.log b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_3.log index a48807ca9..a0b9289d6 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_3.log +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_3.log @@ -1,4 +1,6 @@ Initializing database... +Updating `transaction_type` column in `transactions` table... +Updated 0 transactions in 0.00 seconds Adding `send_type` column to `sends` table Added `send_type` column to `sends` table in 0.00 seconds Adding `source_address` and `destination_address` column to `sends` table diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_3.sql b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_3.sql index fc78446e4..8411ebaec 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_3.sql +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_1_of_3.sql @@ -301,6 +301,7 @@ CREATE TABLE config ( name TEXT PRIMARY KEY, value TEXT ); +INSERT INTO config VALUES('FIX_TRANSACTION_TYPE_1','1'); INSERT INTO config VALUES('FIX_ASSET_EVENTS_FIELD_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_2','1'); diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_2.log b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_2.log index 6eca07a36..8bbd64506 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_2.log +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_2.log @@ -1,4 +1,6 @@ Initializing database... +Updating `transaction_type` column in `transactions` table... +Updated 0 transactions in 0.00 seconds Adding `send_type` column to `sends` table Added `send_type` column to `sends` table in 0.00 seconds Adding `source_address` and `destination_address` column to `sends` table diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_2.sql b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_2.sql index 2a13b3b91..600d337ca 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_2.sql +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_2.sql @@ -301,6 +301,7 @@ CREATE TABLE config ( name TEXT PRIMARY KEY, value TEXT ); +INSERT INTO config VALUES('FIX_TRANSACTION_TYPE_1','1'); INSERT INTO config VALUES('FIX_ASSET_EVENTS_FIELD_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_2','1'); diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_3.log b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_3.log index 8fbcf852f..6b212eda4 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_3.log +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_3.log @@ -1,4 +1,6 @@ Initializing database... +Updating `transaction_type` column in `transactions` table... +Updated 0 transactions in 0.00 seconds Adding `send_type` column to `sends` table Added `send_type` column to `sends` table in 0.00 seconds Adding `source_address` and `destination_address` column to `sends` table diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_3.sql b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_3.sql index 06b17404e..1f9d3a886 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_3.sql +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_2_of_3.sql @@ -301,6 +301,7 @@ CREATE TABLE config ( name TEXT PRIMARY KEY, value TEXT ); +INSERT INTO config VALUES('FIX_TRANSACTION_TYPE_1','1'); INSERT INTO config VALUES('FIX_ASSET_EVENTS_FIELD_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_2','1'); diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_3_of_3.log b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_3_of_3.log index ea7729a0a..14f7296fb 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_3_of_3.log +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_3_of_3.log @@ -1,4 +1,6 @@ Initializing database... +Updating `transaction_type` column in `transactions` table... +Updated 0 transactions in 0.00 seconds Adding `send_type` column to `sends` table Added `send_type` column to `sends` table in 0.00 seconds Adding `source_address` and `destination_address` column to `sends` table diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_3_of_3.sql b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_3_of_3.sql index 979f0cfd0..731464583 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_3_of_3.sql +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/multisig_3_of_3.sql @@ -301,6 +301,7 @@ CREATE TABLE config ( name TEXT PRIMARY KEY, value TEXT ); +INSERT INTO config VALUES('FIX_TRANSACTION_TYPE_1','1'); INSERT INTO config VALUES('FIX_ASSET_EVENTS_FIELD_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_2','1'); diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/parseblock_unittest_fixture.log b/counterparty-core/counterpartycore/test/fixtures/scenarios/parseblock_unittest_fixture.log index 02e2f4dcd..1f4780737 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/parseblock_unittest_fixture.log +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/parseblock_unittest_fixture.log @@ -1,4 +1,6 @@ Initializing database... +Updating `transaction_type` column in `transactions` table... +Updated 0 transactions in 0.00 seconds Adding `send_type` column to `sends` table Added `send_type` column to `sends` table in 0.00 seconds Adding `source_address` and `destination_address` column to `sends` table diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/parseblock_unittest_fixture.sql b/counterparty-core/counterpartycore/test/fixtures/scenarios/parseblock_unittest_fixture.sql index 0ef95d79e..1a6564f40 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/parseblock_unittest_fixture.sql +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/parseblock_unittest_fixture.sql @@ -999,6 +999,7 @@ CREATE TABLE config ( name TEXT PRIMARY KEY, value TEXT ); +INSERT INTO config VALUES('FIX_TRANSACTION_TYPE_1','1'); INSERT INTO config VALUES('FIX_ASSET_EVENTS_FIELD_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_2','1'); diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/simplesig.log b/counterparty-core/counterpartycore/test/fixtures/scenarios/simplesig.log index 1a5775194..94858a388 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/simplesig.log +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/simplesig.log @@ -1,4 +1,6 @@ Initializing database... +Updating `transaction_type` column in `transactions` table... +Updated 0 transactions in 0.00 seconds Adding `send_type` column to `sends` table Added `send_type` column to `sends` table in 0.00 seconds Adding `source_address` and `destination_address` column to `sends` table diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/simplesig.sql b/counterparty-core/counterpartycore/test/fixtures/scenarios/simplesig.sql index 5d39967ac..f27fb5d3a 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/simplesig.sql +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/simplesig.sql @@ -301,6 +301,7 @@ CREATE TABLE config ( name TEXT PRIMARY KEY, value TEXT ); +INSERT INTO config VALUES('FIX_TRANSACTION_TYPE_1','1'); INSERT INTO config VALUES('FIX_ASSET_EVENTS_FIELD_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_2','1'); diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/unittest_fixture.log b/counterparty-core/counterpartycore/test/fixtures/scenarios/unittest_fixture.log index 9aa4119f4..4cce4424d 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/unittest_fixture.log +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/unittest_fixture.log @@ -1,4 +1,6 @@ Initializing database... +Updating `transaction_type` column in `transactions` table... +Updated 0 transactions in 0.00 seconds Adding `send_type` column to `sends` table Added `send_type` column to `sends` table in 0.00 seconds Adding `source_address` and `destination_address` column to `sends` table diff --git a/counterparty-core/counterpartycore/test/fixtures/scenarios/unittest_fixture.sql b/counterparty-core/counterpartycore/test/fixtures/scenarios/unittest_fixture.sql index e049d6d53..8a9eb5e07 100644 --- a/counterparty-core/counterpartycore/test/fixtures/scenarios/unittest_fixture.sql +++ b/counterparty-core/counterpartycore/test/fixtures/scenarios/unittest_fixture.sql @@ -998,6 +998,7 @@ CREATE TABLE config ( name TEXT PRIMARY KEY, value TEXT ); +INSERT INTO config VALUES('FIX_TRANSACTION_TYPE_1','1'); INSERT INTO config VALUES('FIX_ASSET_EVENTS_FIELD_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_1','1'); INSERT INTO config VALUES('FIX_ISSUANCES_ASSET_LONGNAME_2','1'); diff --git a/counterparty-core/counterpartycore/test/fixtures/vectors.py b/counterparty-core/counterpartycore/test/fixtures/vectors.py index 1cdac4b6a..9b296a69f 100644 --- a/counterparty-core/counterpartycore/test/fixtures/vectors.py +++ b/counterparty-core/counterpartycore/test/fixtures/vectors.py @@ -7560,27 +7560,37 @@ ], "get_transaction_type": [ { - "in": (b"CNTRPRTY00", "", 3000000), + "in": (b"CNTRPRTY00", "", [], 3000000), "out": "unknown", "mock_protocol_changes": {"short_tx_type_id": True}, }, { - "in": (b"[A95428957753448833|1", "", 3000000), + "in": (b"[A95428957753448833|1", "", [], 3000000), "out": "fairmint", "mock_protocol_changes": {"short_tx_type_id": True}, }, { - "in": (None, "", 3000000), + "in": (None, "", ["txid:0"], 3000000), "out": "utxomove", "mock_protocol_changes": {"short_tx_type_id": True, "utxo_support": True}, }, { - "in": (b"eXCPMEME|25000000000|", "", 3000000), + "in": (None, "", [""], 3000000), + "out": "unknown", + "mock_protocol_changes": {"short_tx_type_id": True}, + }, + { + "in": (None, "", [""], 2900000), + "out": "dispense", + "mock_protocol_changes": {"short_tx_type_id": True}, + }, + { + "in": (b"eXCPMEME|25000000000|", "", [], 3000000), "out": "attach", "mock_protocol_changes": {"short_tx_type_id": True}, }, { - "in": (b"fbc1qcxlwq8x9fnhyhgywlnja35l7znt58tud9duqay", "", 3000000), + "in": (b"fbc1qcxlwq8x9fnhyhgywlnja35l7znt58tud9duqay", "", [], 3000000), "out": "detach", "mock_protocol_changes": {"short_tx_type_id": True}, }, @@ -7588,16 +7598,22 @@ "in": ( b"\x02\x00>\xc7\xd9>|n\x19\x00\x00\x00\x00\x00\x00\x00P\x00%?\x9e\x96I\xb3\xf9u\x15$\xb2\x90\xf93Pra\x0c\xcc\x01", "", + [], 3000000, ), "out": "enhanced_send", "mock_protocol_changes": {"short_tx_type_id": True}, }, { - "in": (None, config.UNSPENDABLE_TESTNET, 3000000), + "in": (None, config.UNSPENDABLE_TESTNET, [""], 3000000), "out": "burn", "mock_protocol_changes": {"short_tx_type_id": True, "utxo_support": True}, }, + { + "in": (None, config.UNSPENDABLE_TESTNET, [""], 5000000), + "out": "unknown", + "mock_protocol_changes": {"short_tx_type_id": True, "utxo_support": True}, + }, ], }, "address": {