Skip to content

Commit

Permalink
fix and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Jan 4, 2025
1 parent 8e61090 commit ec1fddf
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 7 deletions.
6 changes: 5 additions & 1 deletion counterparty-core/counterpartycore/lib/message_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning

Code scanning / pylint

Simplify chained comparison between the operands. Warning

Simplify chained comparison between the operands.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
28 changes: 22 additions & 6 deletions counterparty-core/counterpartycore/test/fixtures/vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7560,44 +7560,60 @@
],
"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},
},
{
"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": {
Expand Down

0 comments on commit ec1fddf

Please sign in to comment.