From 3d29a7d52ecb85a289d84720279e59f47a3e68d4 Mon Sep 17 00:00:00 2001 From: Ouziel Slama Date: Thu, 16 Jan 2025 13:22:56 +0000 Subject: [PATCH] fixes --- .../test/fixtures/contract_vectors/apiv1.py | 29 ++++++----- .../test/fixtures/contract_vectors/ledger.py | 50 ++++++++++--------- .../test/regtest/testscenarios.py | 3 +- .../test/regtest/utxosupport_propertytest.py | 2 +- 4 files changed, 43 insertions(+), 41 deletions(-) diff --git a/counterparty-core/counterpartycore/test/fixtures/contract_vectors/apiv1.py b/counterparty-core/counterpartycore/test/fixtures/contract_vectors/apiv1.py index c6ee33b6f..0af07fabe 100644 --- a/counterparty-core/counterpartycore/test/fixtures/contract_vectors/apiv1.py +++ b/counterparty-core/counterpartycore/test/fixtures/contract_vectors/apiv1.py @@ -1,5 +1,4 @@ from counterpartycore.lib import exceptions -from counterpartycore.lib.api.apiv1 import APIError from ..params import ADDR, DP, MULTISIGADDR, P2SH_ADDR @@ -510,11 +509,11 @@ }, { "in": ("balances", None, "barfoo", None, None, None, None, None, 1000, 0, True), - "error": (APIError, "Invalid filter operator (OR, AND)"), + "error": (exceptions.APIError, "Invalid filter operator (OR, AND)"), }, { "in": (None, None, "AND", None, None, None, None, None, 1000, 0, True), - "error": (APIError, "Unknown table"), + "error": (exceptions.APIError, "Unknown table"), }, { "in": ( @@ -530,27 +529,27 @@ 0, True, ), - "error": (APIError, "Invalid order direction (ASC, DESC)"), + "error": (exceptions.APIError, "Invalid order direction (ASC, DESC)"), }, { "in": ("balances", None, "AND", None, None, None, None, None, 1000.0, 0, True), - "error": (APIError, "Invalid limit"), + "error": (exceptions.APIError, "Invalid limit"), }, { "in": ("balances", None, "AND", None, None, None, None, None, 1001, 0, True), - "error": (APIError, "Limit should be lower or equal to 1000"), + "error": (exceptions.APIError, "Limit should be lower or equal to 1000"), }, { "in": ("balances", None, "AND", None, None, None, None, None, 1000, 0.0, True), - "error": (APIError, "Invalid offset"), + "error": (exceptions.APIError, "Invalid offset"), }, { "in": ("balances", None, "AND", "*", None, None, None, None, 1000, 0, True), - "error": (APIError, "Invalid order_by, must be a field name"), + "error": (exceptions.APIError, "Invalid order_by, must be a field name"), }, { "in": ("balances", [0], "AND", None, None, None, None, None, 1000, 0, True), - "error": (APIError, "Unknown filter type"), + "error": (exceptions.APIError, "Unknown filter type"), }, { "in": ( @@ -566,7 +565,7 @@ 0, True, ), - "error": (APIError, "A specified filter is missing the 'value' field"), + "error": (exceptions.APIError, "A specified filter is missing the 'value' field"), }, { "in": ( @@ -582,7 +581,7 @@ 0, True, ), - "error": (APIError, "Invalid value for the field 'bar'"), + "error": (exceptions.APIError, "Invalid value for the field 'bar'"), }, { "in": ( @@ -598,7 +597,7 @@ 0, True, ), - "error": (APIError, "Invalid value for the field 'bar'"), + "error": (exceptions.APIError, "Invalid value for the field 'bar'"), }, { "in": ( @@ -614,7 +613,7 @@ 0, True, ), - "error": (APIError, "Invalid operator for the field 'bar'"), + "error": (exceptions.APIError, "Invalid operator for the field 'bar'"), }, { "in": ( @@ -630,7 +629,7 @@ 0, True, ), - "error": (APIError, "case_sensitive must be a boolean"), + "error": (exceptions.APIError, "case_sensitive must be a boolean"), }, { "comment": "standard send with no memo", @@ -857,7 +856,7 @@ 0, True, ), - "error": (APIError, "Invalid memo_hex value"), + "error": (exceptions.APIError, "Invalid memo_hex value"), }, { "comment": "search by memo hex", diff --git a/counterparty-core/counterpartycore/test/fixtures/contract_vectors/ledger.py b/counterparty-core/counterpartycore/test/fixtures/contract_vectors/ledger.py index 6913fe27a..1bd54242d 100644 --- a/counterparty-core/counterpartycore/test/fixtures/contract_vectors/ledger.py +++ b/counterparty-core/counterpartycore/test/fixtures/contract_vectors/ledger.py @@ -1,7 +1,6 @@ from fractions import Fraction from counterpartycore.lib import exceptions -from counterpartycore.lib.ledger.ledger import CreditError, DebitError from ..params import ( ADDR, @@ -10,6 +9,22 @@ LEDGER_VECTOR = { "ledger.ledger": { + "last_message": [ + { + "in": (), + "out": { + "message_index": 1743, + "block_index": 310703, + "command": "parse", + "category": "blocks", + "bindings": '{"block_index":310703,"ledger_hash":"3e8ba9968f58a14dd4950aa1a1f02d58edfd246a2ac733a5fac4aa2c04505e3e","messages_hash":"794d8c3df2ea1ce1b68833e0c33f7a846445f6da53dadceaaff41aac66dd5c83","transaction_count":0,"txlist_hash":"c76b69cb9056ed5b35e10737d93aa2fde389690899503f46f3ca18d419ce4dd2"}', + "timestamp": 0, + "event": "BLOCK_PARSED", + "tx_hash": None, + "event_hash": "7c68ff23281790be67a757e3ba0eb0a0bcd57ca2cae307531a1ae9de28f9c939", + }, + } + ], "generate_asset_id": [ {"in": ("BTC", DP["default_block_index"]), "out": 0}, {"in": ("XCP", DP["default_block_index"]), "out": 1}, @@ -50,22 +65,6 @@ {"in": (2**64, 308000), "error": (exceptions.AssetIDError, "too high")}, ], "price": [{"in": (1, 10), "out": Fraction(1, 10)}], - "last_message": [ - { - "in": (), - "out": { - "message_index": 1743, - "block_index": 310703, - "command": "parse", - "category": "blocks", - "bindings": '{"block_index":310703,"ledger_hash":"3e8ba9968f58a14dd4950aa1a1f02d58edfd246a2ac733a5fac4aa2c04505e3e","messages_hash":"794d8c3df2ea1ce1b68833e0c33f7a846445f6da53dadceaaff41aac66dd5c83","transaction_count":0,"txlist_hash":"c76b69cb9056ed5b35e10737d93aa2fde389690899503f46f3ca18d419ce4dd2"}', - "timestamp": 0, - "event": "BLOCK_PARSED", - "tx_hash": None, - "event_hash": "7c68ff23281790be67a757e3ba0eb0a0bcd57ca2cae307531a1ae9de28f9c939", - }, - } - ], "get_asset_id": [ {"in": ("XCP", DP["default_block_index"]), "out": 1}, {"in": ("BTC", DP["default_block_index"]), "out": 0}, @@ -85,31 +84,34 @@ {"in": (ADDR[0], "XCP", 1, 0), "out": None}, { "in": (ADDR[0], "BTC", DP["quantity"], 0), - "error": (DebitError, "Cannot debit bitcoins."), + "error": (exceptions.DebitError, "Cannot debit bitcoins."), }, { "in": (ADDR[0], "BTC", -1 * DP["quantity"], 0), - "error": (DebitError, "Negative quantity."), + "error": (exceptions.DebitError, "Negative quantity."), }, { "in": (ADDR[0], "BTC", 1.1 * DP["quantity"], 0), - "error": (DebitError, "Quantity must be an integer."), + "error": (exceptions.DebitError, "Quantity must be an integer."), + }, + { + "in": (ADDR[0], "XCP", 2**40, 0), + "error": (exceptions.DebitError, "Insufficient funds."), }, - {"in": (ADDR[0], "XCP", 2**40, 0), "error": (DebitError, "Insufficient funds.")}, ], "credit": [ {"in": (ADDR[0], "XCP", 1, 0), "out": None}, { "in": (ADDR[0], "BTC", DP["quantity"], 0), - "error": (CreditError, "Cannot debit bitcoins."), + "error": (exceptions.CreditError, "Cannot debit bitcoins."), }, { "in": (ADDR[0], "BTC", -1 * DP["quantity"], 0), - "error": (CreditError, "Negative quantity."), + "error": (exceptions.CreditError, "Negative quantity."), }, { "in": (ADDR[0], "BTC", 1.1 * DP["quantity"], 0), - "error": (CreditError, "Quantity must be an integer."), + "error": (exceptions.CreditError, "Quantity must be an integer."), }, ], "is_divisible": [ diff --git a/counterparty-core/counterpartycore/test/regtest/testscenarios.py b/counterparty-core/counterpartycore/test/regtest/testscenarios.py index 25d7f98bf..b20f7a1da 100644 --- a/counterparty-core/counterpartycore/test/regtest/testscenarios.py +++ b/counterparty-core/counterpartycore/test/regtest/testscenarios.py @@ -7,8 +7,9 @@ import time import sh +from counterpartycore.lib.exceptions import ComposeError from regtestcli import atomic_swap -from regtestnode import ComposeError, RegtestNodeThread, print_server_output +from regtestnode import RegtestNodeThread, print_server_output from scenarios import ( scenario_1_fairminter, scenario_2_fairminter, diff --git a/counterparty-core/counterpartycore/test/regtest/utxosupport_propertytest.py b/counterparty-core/counterpartycore/test/regtest/utxosupport_propertytest.py index d149d4e4a..dc91c18e2 100644 --- a/counterparty-core/counterpartycore/test/regtest/utxosupport_propertytest.py +++ b/counterparty-core/counterpartycore/test/regtest/utxosupport_propertytest.py @@ -4,10 +4,10 @@ import hypothesis from counterpartycore.lib import config +from counterpartycore.lib.exceptions import ComposeError from counterpartycore.lib.utils import assetnames from hypothesis import settings from properytestnode import PropertyTestNode -from regtestnode import ComposeError MESSAGE_IDS = [ 0,