From 4c7d9ae4688b23b95c2a7bf69773b0a933a23c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Eckel?= Date: Tue, 14 Feb 2023 17:04:47 +0100 Subject: [PATCH 1/7] fixed election and voting backward compatibility issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Eckel --- planetmint/lib.py | 11 +++++------ tests/validation/test_transaction_structure.py | 6 ++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/planetmint/lib.py b/planetmint/lib.py index e031edd..4ce3649 100644 --- a/planetmint/lib.py +++ b/planetmint/lib.py @@ -684,7 +684,7 @@ class Planetmint(object): current_validators = self.get_validators_dict() # NOTE: change more than 1/3 of the current power is not allowed - if transaction.assets[0]["data"]["power"] >= (1 / 3) * sum(current_validators.values()): + if Transaction.get_asset_array( transaction )[0]["data"]["power"] >= (1 / 3) * sum(current_validators.values()): raise InvalidPowerChange("`power` change must be less than 1/3 of total power") def get_election_status(self, transaction): @@ -740,7 +740,7 @@ class Planetmint(object): return recipients def show_election_status(self, transaction): - data = transaction.assets[0]["data"] + data = transaction.get_assets()[0]["data"] if "public_key" in data.keys(): data["public_key"] = public_key_to_base64(data["public_key"]["value"]) response = "" @@ -821,8 +821,7 @@ class Planetmint(object): for tx in txns: if not isinstance(tx, Vote): continue - - election_id = tx.assets[0]["id"] + election_id = Transaction.read_out_asset_id(tx) if election_id not in elections: elections[election_id] = [] elections[election_id].append(tx) @@ -956,7 +955,7 @@ class Planetmint(object): if election.operation == CHAIN_MIGRATION_ELECTION: self.migrate_abci_chain() if election.operation == VALIDATOR_ELECTION: - validator_updates = [election.assets[0]["data"]] + validator_updates = [election.get_assets()[0]["data"]] curr_validator_set = self.get_validators(new_height) updated_validator_set = new_validator_set(curr_validator_set, validator_updates) @@ -964,7 +963,7 @@ class Planetmint(object): # TODO change to `new_height + 2` when upgrading to Tendermint 0.24.0. self.store_validator_set(new_height + 1, updated_validator_set) - return encode_validator(election.assets[0]["data"]) + return encode_validator(election.get_assets()[0]["data"]) Block = namedtuple("Block", ("app_hash", "height", "transactions")) diff --git a/tests/validation/test_transaction_structure.py b/tests/validation/test_transaction_structure.py index ed6eae3..cf16c89 100644 --- a/tests/validation/test_transaction_structure.py +++ b/tests/validation/test_transaction_structure.py @@ -259,3 +259,9 @@ def test_validate_version(b, create_tx, alice): create_tx._id = None create_tx.sign([alice.private_key]) validate_raises(create_tx) + + +def test_upgrade_issue_validation(b): + tx_dict = {"inputs": [{"owners_before": ["HY2gviZVW1fvsshx21kRCcGUJFBKQwf37xA959cTNFzP"], "fulfills": None, "fulfillment": "pGSAIPWt56ud3H3z0qf6hPKcMsJtOSc_goPAo3AXkH8T4mzAgUBuGTrhGQQ0oePAgxC_9pHNWzHiykddAuhMSnSDoatPExkDp2nAmq8D6pvc3ECqMUUj04GBEq2aROmAylDBKrgG"}], "outputs": [{"public_keys": ["6G8TmxcbRgYuQviBg9Us5h4B8D94fNJ4kbMMKRwmY5sy"], "condition": {"details": {"type": "ed25519-sha-256", "public_key": "6G8TmxcbRgYuQviBg9Us5h4B8D94fNJ4kbMMKRwmY5sy"}, "uri": "ni:///sha-256;jf_gG_7GnA7bTzelkz_Du2kMHzw7OS20TVNHD8XZSq4?fpt=ed25519-sha-256&cost=131072"}, "amount": "10"}, {"public_keys": ["CwHvbpvaWQu9wBuVVLRsc2rxUcGM7j1tR3RsVPWtgbXj"], "condition": {"details": {"type": "ed25519-sha-256", "public_key": "CwHvbpvaWQu9wBuVVLRsc2rxUcGM7j1tR3RsVPWtgbXj"}, "uri": "ni:///sha-256;4VrA0c8Pvb4DA7Bvrx7or0JBKExRCfWyKSFiLYxpr7A?fpt=ed25519-sha-256&cost=131072"}, "amount": "10"}, {"public_keys": ["HY2gviZVW1fvsshx21kRCcGUJFBKQwf37xA959cTNFzP"], "condition": {"details": {"type": "ed25519-sha-256", "public_key": "HY2gviZVW1fvsshx21kRCcGUJFBKQwf37xA959cTNFzP"}, "uri": "ni:///sha-256;-uhNj2-VQAytXDoz0z2n9PHUbJrzME4syF1EJCQ9cKw?fpt=ed25519-sha-256&cost=131072"}, "amount": "10"}, {"public_keys": ["2mxYGVViSHfTFJNydAKQQZaz8HAUjUSCDobPCF2q1hjk"], "condition": {"details": {"type": "ed25519-sha-256", "public_key": "2mxYGVViSHfTFJNydAKQQZaz8HAUjUSCDobPCF2q1hjk"}, "uri": "ni:///sha-256;fTF2N2feWDvfEeMoTXss5KlWkYwnP4g2jUWKF2cmFRI?fpt=ed25519-sha-256&cost=131072"}, "amount": "10"}, {"public_keys": ["Dxy87xVCbGueayzmzo1csFFp47mhsvCYqX7dJJSTZmvB"], "condition": {"details": {"type": "ed25519-sha-256", "public_key": "Dxy87xVCbGueayzmzo1csFFp47mhsvCYqX7dJJSTZmvB"}, "uri": "ni:///sha-256;Ga2y8alLY9f1tQ-Jvly68UZZ7csLLWbL7v7240_-uvo?fpt=ed25519-sha-256&cost=131072"}, "amount": "10"}], "operation": "VALIDATOR_ELECTION", "metadata": None, "asset": {"data": {"public_key": {"value": "EEE57EEEE18BCC60B951C0672B09D70F52B20AC8C8DE9A191F956BB09083BF96", "type": "ed25519-base16"}, "power": 10, "node_id": "a4ee5afed56efbfbc0d08c1d030b1d0291451c59", "seed": "99430bfa-26e7-422d-a816-37166a05818c"}}, "version": "2.0", "id": "d2a58e4bb788e6594b4e8570b881b8b9859be34881fd4cba40b49481b0af2e98"} + tx = Transaction.from_dict(tx_dict, False) + print(tx) From b1151d21f318f10632ab95b4e72c4bd4dcecb267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Eckel?= Date: Tue, 14 Feb 2023 17:09:41 +0100 Subject: [PATCH 2/7] bumped version! added changelog added planetmint-transactions >= 0.7.0 dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Eckel --- CHANGELOG.md | 3 +++ planetmint/version.py | 2 +- setup.py | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 360d99f..7345905 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,9 @@ For reference, the possible headings are: * **Known Issues** * **Notes** +## [1.4.2] - 2023-14-02 +* **fixed** fixed voting/election backward compatibility issue (using planetmint-transactions >= 0.7.0) + ## [1.4.1] - 2022-21-12 * **fixed** inconsistent cryptocondition keyring tag handling. Using cryptoconditions > 1.1.0 from now on. diff --git a/planetmint/version.py b/planetmint/version.py index f4bc962..b4fcdd8 100644 --- a/planetmint/version.py +++ b/planetmint/version.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) # Code is Apache-2.0 and docs are CC-BY-4.0 -__version__ = "1.4.1" +__version__ = "1.4.2" __short_version__ = "1.4" # Supported Tendermint versions diff --git a/setup.py b/setup.py index a9fc93b..accb392 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ docs_require = [ "pyparsing==3.0.8", "pytz==2022.1", "PyYAML>=5.4.0", - "requests>=2.25i.1", + "requests>=2.25.1", "six==1.16.0", "snowballstemmer==2.2.0", "Sphinx==4.5.0", @@ -129,7 +129,7 @@ install_requires = [ "planetmint-ipld>=0.0.3", "pyasn1>=0.4.8", "python-decouple", - "planetmint-transactions>=0.5.0", + "planetmint-transactions>=0.7.0", ] setup( From 2fc522dc77fdc6f8e042263a8dd1eec96ca65317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Eckel?= Date: Tue, 14 Feb 2023 17:31:02 +0100 Subject: [PATCH 3/7] blackified MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Eckel --- planetmint/lib.py | 2 +- .../validation/test_transaction_structure.py | 82 ++++++++++++++++++- 2 files changed, 82 insertions(+), 2 deletions(-) diff --git a/planetmint/lib.py b/planetmint/lib.py index b1e3e38..13470df 100644 --- a/planetmint/lib.py +++ b/planetmint/lib.py @@ -684,7 +684,7 @@ class Planetmint(object): current_validators = self.get_validators_dict() # NOTE: change more than 1/3 of the current power is not allowed - if Transaction.get_asset_array( transaction )[0]["data"]["power"] >= (1 / 3) * sum(current_validators.values()): + if Transaction.get_asset_array(transaction)[0]["data"]["power"] >= (1 / 3) * sum(current_validators.values()): raise InvalidPowerChange("`power` change must be less than 1/3 of total power") def get_election_status(self, transaction): diff --git a/tests/validation/test_transaction_structure.py b/tests/validation/test_transaction_structure.py index cf16c89..5fe2da0 100644 --- a/tests/validation/test_transaction_structure.py +++ b/tests/validation/test_transaction_structure.py @@ -262,6 +262,86 @@ def test_validate_version(b, create_tx, alice): def test_upgrade_issue_validation(b): - tx_dict = {"inputs": [{"owners_before": ["HY2gviZVW1fvsshx21kRCcGUJFBKQwf37xA959cTNFzP"], "fulfills": None, "fulfillment": "pGSAIPWt56ud3H3z0qf6hPKcMsJtOSc_goPAo3AXkH8T4mzAgUBuGTrhGQQ0oePAgxC_9pHNWzHiykddAuhMSnSDoatPExkDp2nAmq8D6pvc3ECqMUUj04GBEq2aROmAylDBKrgG"}], "outputs": [{"public_keys": ["6G8TmxcbRgYuQviBg9Us5h4B8D94fNJ4kbMMKRwmY5sy"], "condition": {"details": {"type": "ed25519-sha-256", "public_key": "6G8TmxcbRgYuQviBg9Us5h4B8D94fNJ4kbMMKRwmY5sy"}, "uri": "ni:///sha-256;jf_gG_7GnA7bTzelkz_Du2kMHzw7OS20TVNHD8XZSq4?fpt=ed25519-sha-256&cost=131072"}, "amount": "10"}, {"public_keys": ["CwHvbpvaWQu9wBuVVLRsc2rxUcGM7j1tR3RsVPWtgbXj"], "condition": {"details": {"type": "ed25519-sha-256", "public_key": "CwHvbpvaWQu9wBuVVLRsc2rxUcGM7j1tR3RsVPWtgbXj"}, "uri": "ni:///sha-256;4VrA0c8Pvb4DA7Bvrx7or0JBKExRCfWyKSFiLYxpr7A?fpt=ed25519-sha-256&cost=131072"}, "amount": "10"}, {"public_keys": ["HY2gviZVW1fvsshx21kRCcGUJFBKQwf37xA959cTNFzP"], "condition": {"details": {"type": "ed25519-sha-256", "public_key": "HY2gviZVW1fvsshx21kRCcGUJFBKQwf37xA959cTNFzP"}, "uri": "ni:///sha-256;-uhNj2-VQAytXDoz0z2n9PHUbJrzME4syF1EJCQ9cKw?fpt=ed25519-sha-256&cost=131072"}, "amount": "10"}, {"public_keys": ["2mxYGVViSHfTFJNydAKQQZaz8HAUjUSCDobPCF2q1hjk"], "condition": {"details": {"type": "ed25519-sha-256", "public_key": "2mxYGVViSHfTFJNydAKQQZaz8HAUjUSCDobPCF2q1hjk"}, "uri": "ni:///sha-256;fTF2N2feWDvfEeMoTXss5KlWkYwnP4g2jUWKF2cmFRI?fpt=ed25519-sha-256&cost=131072"}, "amount": "10"}, {"public_keys": ["Dxy87xVCbGueayzmzo1csFFp47mhsvCYqX7dJJSTZmvB"], "condition": {"details": {"type": "ed25519-sha-256", "public_key": "Dxy87xVCbGueayzmzo1csFFp47mhsvCYqX7dJJSTZmvB"}, "uri": "ni:///sha-256;Ga2y8alLY9f1tQ-Jvly68UZZ7csLLWbL7v7240_-uvo?fpt=ed25519-sha-256&cost=131072"}, "amount": "10"}], "operation": "VALIDATOR_ELECTION", "metadata": None, "asset": {"data": {"public_key": {"value": "EEE57EEEE18BCC60B951C0672B09D70F52B20AC8C8DE9A191F956BB09083BF96", "type": "ed25519-base16"}, "power": 10, "node_id": "a4ee5afed56efbfbc0d08c1d030b1d0291451c59", "seed": "99430bfa-26e7-422d-a816-37166a05818c"}}, "version": "2.0", "id": "d2a58e4bb788e6594b4e8570b881b8b9859be34881fd4cba40b49481b0af2e98"} + tx_dict = { + "inputs": [ + { + "owners_before": ["HY2gviZVW1fvsshx21kRCcGUJFBKQwf37xA959cTNFzP"], + "fulfills": None, + "fulfillment": "pGSAIPWt56ud3H3z0qf6hPKcMsJtOSc_goPAo3AXkH8T4mzAgUBuGTrhGQQ0oePAgxC_9pHNWzHiykddAuhMSnSDoatPExkDp2nAmq8D6pvc3ECqMUUj04GBEq2aROmAylDBKrgG", + } + ], + "outputs": [ + { + "public_keys": ["6G8TmxcbRgYuQviBg9Us5h4B8D94fNJ4kbMMKRwmY5sy"], + "condition": { + "details": { + "type": "ed25519-sha-256", + "public_key": "6G8TmxcbRgYuQviBg9Us5h4B8D94fNJ4kbMMKRwmY5sy", + }, + "uri": "ni:///sha-256;jf_gG_7GnA7bTzelkz_Du2kMHzw7OS20TVNHD8XZSq4?fpt=ed25519-sha-256&cost=131072", + }, + "amount": "10", + }, + { + "public_keys": ["CwHvbpvaWQu9wBuVVLRsc2rxUcGM7j1tR3RsVPWtgbXj"], + "condition": { + "details": { + "type": "ed25519-sha-256", + "public_key": "CwHvbpvaWQu9wBuVVLRsc2rxUcGM7j1tR3RsVPWtgbXj", + }, + "uri": "ni:///sha-256;4VrA0c8Pvb4DA7Bvrx7or0JBKExRCfWyKSFiLYxpr7A?fpt=ed25519-sha-256&cost=131072", + }, + "amount": "10", + }, + { + "public_keys": ["HY2gviZVW1fvsshx21kRCcGUJFBKQwf37xA959cTNFzP"], + "condition": { + "details": { + "type": "ed25519-sha-256", + "public_key": "HY2gviZVW1fvsshx21kRCcGUJFBKQwf37xA959cTNFzP", + }, + "uri": "ni:///sha-256;-uhNj2-VQAytXDoz0z2n9PHUbJrzME4syF1EJCQ9cKw?fpt=ed25519-sha-256&cost=131072", + }, + "amount": "10", + }, + { + "public_keys": ["2mxYGVViSHfTFJNydAKQQZaz8HAUjUSCDobPCF2q1hjk"], + "condition": { + "details": { + "type": "ed25519-sha-256", + "public_key": "2mxYGVViSHfTFJNydAKQQZaz8HAUjUSCDobPCF2q1hjk", + }, + "uri": "ni:///sha-256;fTF2N2feWDvfEeMoTXss5KlWkYwnP4g2jUWKF2cmFRI?fpt=ed25519-sha-256&cost=131072", + }, + "amount": "10", + }, + { + "public_keys": ["Dxy87xVCbGueayzmzo1csFFp47mhsvCYqX7dJJSTZmvB"], + "condition": { + "details": { + "type": "ed25519-sha-256", + "public_key": "Dxy87xVCbGueayzmzo1csFFp47mhsvCYqX7dJJSTZmvB", + }, + "uri": "ni:///sha-256;Ga2y8alLY9f1tQ-Jvly68UZZ7csLLWbL7v7240_-uvo?fpt=ed25519-sha-256&cost=131072", + }, + "amount": "10", + }, + ], + "operation": "VALIDATOR_ELECTION", + "metadata": None, + "asset": { + "data": { + "public_key": { + "value": "EEE57EEEE18BCC60B951C0672B09D70F52B20AC8C8DE9A191F956BB09083BF96", + "type": "ed25519-base16", + }, + "power": 10, + "node_id": "a4ee5afed56efbfbc0d08c1d030b1d0291451c59", + "seed": "99430bfa-26e7-422d-a816-37166a05818c", + } + }, + "version": "2.0", + "id": "d2a58e4bb788e6594b4e8570b881b8b9859be34881fd4cba40b49481b0af2e98", + } tx = Transaction.from_dict(tx_dict, False) print(tx) From b14a092fb38aee796ca29018d1edaae58b5719b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Eckel?= Date: Tue, 14 Feb 2023 22:38:51 +0100 Subject: [PATCH 4/7] fixed changed testcases and a bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Eckel --- planetmint/lib.py | 2 +- tests/validation/test_transaction_structure.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/planetmint/lib.py b/planetmint/lib.py index 13470df..113c033 100644 --- a/planetmint/lib.py +++ b/planetmint/lib.py @@ -684,7 +684,7 @@ class Planetmint(object): current_validators = self.get_validators_dict() # NOTE: change more than 1/3 of the current power is not allowed - if Transaction.get_asset_array(transaction)[0]["data"]["power"] >= (1 / 3) * sum(current_validators.values()): + if transaction.get_assets()[0]["data"]["power"] >= (1 / 3) * sum(current_validators.values()): raise InvalidPowerChange("`power` change must be less than 1/3 of total power") def get_election_status(self, transaction): diff --git a/tests/validation/test_transaction_structure.py b/tests/validation/test_transaction_structure.py index 5fe2da0..456f887 100644 --- a/tests/validation/test_transaction_structure.py +++ b/tests/validation/test_transaction_structure.py @@ -168,7 +168,9 @@ def test_create_tx_no_fulfills(b, create_tx, alice): tx = create_tx.to_dict() tx["inputs"][0]["fulfills"] = {"transaction_id": "a" * 64, "output_index": 0} tx = Transaction.from_dict(tx).sign([alice.private_key]).to_dict() - validate_raises(tx) + # Schema validation does not lookup inputs. this is only done by the node with DB/consensus context + #validate_raises(tx) + validate(tx) def test_transfer_has_inputs(user_sk, signed_transfer_tx, alice): From a23c180a0b30c7bdcc7bc61be4c1aac93c3b9824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Eckel?= Date: Tue, 14 Feb 2023 22:39:24 +0100 Subject: [PATCH 5/7] blackified MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Eckel --- tests/validation/test_transaction_structure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/validation/test_transaction_structure.py b/tests/validation/test_transaction_structure.py index 456f887..169013c 100644 --- a/tests/validation/test_transaction_structure.py +++ b/tests/validation/test_transaction_structure.py @@ -169,7 +169,7 @@ def test_create_tx_no_fulfills(b, create_tx, alice): tx["inputs"][0]["fulfills"] = {"transaction_id": "a" * 64, "output_index": 0} tx = Transaction.from_dict(tx).sign([alice.private_key]).to_dict() # Schema validation does not lookup inputs. this is only done by the node with DB/consensus context - #validate_raises(tx) + # validate_raises(tx) validate(tx) From 3afb2e6f3da3ae51760cbed4b3f8632207ab9159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Eckel?= Date: Tue, 14 Feb 2023 22:43:33 +0100 Subject: [PATCH 6/7] blackified with newest verion to satisfy CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Eckel --- acceptance/python/src/test_naughty_strings.py | 3 +-- acceptance/python/src/test_zenroom.py | 2 -- integration/python/src/test_naughty_strings.py | 2 -- integration/python/src/test_zenroom.py | 1 - planetmint/backend/localmongodb/query.py | 1 - planetmint/backend/tarantool/transaction/tools.py | 2 -- planetmint/web/routes.py | 4 ++-- setup.py | 2 +- tests/assets/test_divisible_assets.py | 10 ---------- tests/assets/test_zenroom_signing.py | 1 - tests/db/test_planetmint_api.py | 1 - tests/test_config_utils.py | 1 - tests/upsert_validator/test_upsert_validator_vote.py | 4 +--- tests/web/test_assets.py | 2 -- tests/web/test_metadata.py | 1 - tests/web/test_transactions.py | 1 - 16 files changed, 5 insertions(+), 33 deletions(-) diff --git a/acceptance/python/src/test_naughty_strings.py b/acceptance/python/src/test_naughty_strings.py index a74f3fd..9e57084 100644 --- a/acceptance/python/src/test_naughty_strings.py +++ b/acceptance/python/src/test_naughty_strings.py @@ -67,6 +67,7 @@ skipped_naughty_strings = [ naughty_strings = [naughty for naughty in naughty_strings if naughty not in skipped_naughty_strings] + # This is our base test case, but we'll reuse it to send naughty strings as both keys and values. def send_naughty_tx(assets, metadata): # ## Set up a connection to Planetmint @@ -118,7 +119,6 @@ def send_naughty_tx(assets, metadata): @pytest.mark.parametrize("naughty_string", naughty_strings, ids=naughty_strings) def test_naughty_keys(naughty_string): - assets = [{"data": multihash(marshal({naughty_string: "nice_value"}))}] metadata = multihash(marshal({naughty_string: "nice_value"})) @@ -127,7 +127,6 @@ def test_naughty_keys(naughty_string): @pytest.mark.parametrize("naughty_string", naughty_strings, ids=naughty_strings) def test_naughty_values(naughty_string): - assets = [{"data": multihash(marshal({"nice_key": naughty_string}))}] metadata = multihash(marshal({"nice_key": naughty_string})) diff --git a/acceptance/python/src/test_zenroom.py b/acceptance/python/src/test_zenroom.py index 1b9ea14..543913a 100644 --- a/acceptance/python/src/test_zenroom.py +++ b/acceptance/python/src/test_zenroom.py @@ -19,7 +19,6 @@ def test_zenroom_signing( zenroom_script_input, condition_script_zencode, ): - biolabs = generate_keypair() version = "2.0" @@ -47,7 +46,6 @@ def test_zenroom_signing( zenroom_house_assets, condition_script_zencode, ): - biolabs = generate_keypair() version = "2.0" diff --git a/integration/python/src/test_naughty_strings.py b/integration/python/src/test_naughty_strings.py index 921d718..20f89e3 100644 --- a/integration/python/src/test_naughty_strings.py +++ b/integration/python/src/test_naughty_strings.py @@ -115,7 +115,6 @@ def send_naughty_tx(assets, metadata): @pytest.mark.parametrize("naughty_string", naughty_strings, ids=naughty_strings) def test_naughty_keys(naughty_string): - assets = [{"data": {naughty_string: "nice_value"}}] metadata = {naughty_string: "nice_value"} @@ -124,7 +123,6 @@ def test_naughty_keys(naughty_string): @pytest.mark.parametrize("naughty_string", naughty_strings, ids=naughty_strings) def test_naughty_values(naughty_string): - assets = [{"data": {"nice_key": naughty_string}}] metadata = {"nice_key": naughty_string} diff --git a/integration/python/src/test_zenroom.py b/integration/python/src/test_zenroom.py index 1f33ca0..cc0f6b3 100644 --- a/integration/python/src/test_zenroom.py +++ b/integration/python/src/test_zenroom.py @@ -17,7 +17,6 @@ def test_zenroom_signing( zenroom_script_input, condition_script_zencode, ): - biolabs = generate_keypair() version = "2.0" diff --git a/planetmint/backend/localmongodb/query.py b/planetmint/backend/localmongodb/query.py index 3351164..feaf145 100644 --- a/planetmint/backend/localmongodb/query.py +++ b/planetmint/backend/localmongodb/query.py @@ -102,7 +102,6 @@ def store_block(conn, block): @register_query(LocalMongoDBConnection) def get_txids_filtered(conn, asset_ids, operation=None, last_tx=None): - match = { Transaction.CREATE: {"operation": "CREATE", "id": {"$in": asset_ids}}, Transaction.TRANSFER: {"operation": "TRANSFER", "asset.id": {"$in": asset_ids}}, diff --git a/planetmint/backend/tarantool/transaction/tools.py b/planetmint/backend/tarantool/transaction/tools.py index afc4634..cb04b56 100644 --- a/planetmint/backend/tarantool/transaction/tools.py +++ b/planetmint/backend/tarantool/transaction/tools.py @@ -47,7 +47,6 @@ class TransactionDecompose: } def get_map(self, dictionary: dict = None): - return ( _save_keys_order(dictionary=dictionary) if dictionary is not None @@ -75,7 +74,6 @@ class TransactionDecompose: _inputs = [] input_index = 0 for _input in self._transaction["inputs"]: - _inputs.append( ( self._transaction["id"], diff --git a/planetmint/web/routes.py b/planetmint/web/routes.py index 3579c2e..05ad831 100644 --- a/planetmint/web/routes.py +++ b/planetmint/web/routes.py @@ -18,9 +18,9 @@ from planetmint.web.views import ( def add_routes(app): """Add the routes to an app""" - for (prefix, routes) in API_SECTIONS: + for prefix, routes in API_SECTIONS: api = Api(app, prefix=prefix) - for ((pattern, resource, *args), kwargs) in routes: + for (pattern, resource, *args), kwargs in routes: kwargs.setdefault("strict_slashes", False) api.add_resource(resource, pattern, *args, **kwargs) diff --git a/setup.py b/setup.py index accb392..8b8f2f9 100644 --- a/setup.py +++ b/setup.py @@ -94,7 +94,7 @@ dev_require = ["ipdb", "ipython", "watchdog", "logging_tree", "pre-commit", "twi tests_require = [ "coverage", "pep8", - "black", + "black>=23.1.0", "hypothesis>=5.3.0", "pytest>=3.0.0", "pytest-cov==2.8.1", diff --git a/tests/assets/test_divisible_assets.py b/tests/assets/test_divisible_assets.py index 60254bf..94f7030 100644 --- a/tests/assets/test_divisible_assets.py +++ b/tests/assets/test_divisible_assets.py @@ -34,7 +34,6 @@ def test_single_in_single_own_single_out_single_own_create(alice, user_pk, b): # Multiple outputs # Single owners_after per output def test_single_in_single_own_multiple_out_single_own_create(alice, user_pk, b): - tx = Create.generate( [alice.public_key], [([user_pk], 50), ([user_pk], 50)], @@ -55,7 +54,6 @@ def test_single_in_single_own_multiple_out_single_own_create(alice, user_pk, b): # Single output # Multiple owners_after def test_single_in_single_own_single_out_multiple_own_create(alice, user_pk, b): - tx = Create.generate( [alice.public_key], [([user_pk, user_pk], 100)], @@ -81,7 +79,6 @@ def test_single_in_single_own_single_out_multiple_own_create(alice, user_pk, b): # Mix: one output with a single owners_after, one output with multiple # owners_after def test_single_in_single_own_multiple_out_mix_own_create(alice, user_pk, b): - tx = Create.generate( [alice.public_key], [([user_pk], 50), ([user_pk, user_pk], 50)], @@ -130,7 +127,6 @@ def test_single_in_multiple_own_single_out_single_own_create(alice, b, user_pk, # Single output # Single owners_after def test_single_in_single_own_single_out_single_own_transfer(alice, b, user_pk, user_sk): - # CREATE divisible asset tx_create = Create.generate( [alice.public_key], [([user_pk], 100)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}] @@ -155,7 +151,6 @@ def test_single_in_single_own_single_out_single_own_transfer(alice, b, user_pk, # Multiple output # Single owners_after def test_single_in_single_own_multiple_out_single_own_transfer(alice, b, user_pk, user_sk): - # CREATE divisible asset tx_create = Create.generate( [alice.public_key], [([user_pk], 100)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}] @@ -183,7 +178,6 @@ def test_single_in_single_own_multiple_out_single_own_transfer(alice, b, user_pk # Single output # Multiple owners_after def test_single_in_single_own_single_out_multiple_own_transfer(alice, b, user_pk, user_sk): - # CREATE divisible asset tx_create = Create.generate( [alice.public_key], [([user_pk], 100)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}] @@ -219,7 +213,6 @@ def test_single_in_single_own_single_out_multiple_own_transfer(alice, b, user_pk # Mix: one output with a single owners_after, one output with multiple # owners_after def test_single_in_single_own_multiple_out_mix_own_transfer(alice, b, user_pk, user_sk): - # CREATE divisible asset tx_create = Create.generate( [alice.public_key], [([user_pk], 100)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}] @@ -448,7 +441,6 @@ def test_muiltiple_in_mix_own_multiple_out_mix_own_transfer(alice, b, user_pk, u # Single output # Single owners_after def test_multiple_in_different_transactions(alice, b, user_pk, user_sk): - # CREATE divisible asset # `b` creates a divisible asset and assigns 50 shares to `b` and # 50 shares to `user_pk` @@ -549,7 +541,6 @@ def test_threshold_same_public_key(alice, b, user_pk, user_sk): def test_sum_amount(alice, b, user_pk, user_sk): - # CREATE divisible asset with 3 outputs with amount 1 tx_create = Create.generate( [alice.public_key], @@ -575,7 +566,6 @@ def test_sum_amount(alice, b, user_pk, user_sk): def test_divide(alice, b, user_pk, user_sk): - # CREATE divisible asset with 1 output with amount 3 tx_create = Create.generate( [alice.public_key], [([user_pk], 3)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}] diff --git a/tests/assets/test_zenroom_signing.py b/tests/assets/test_zenroom_signing.py index 655d4fb..85263bf 100644 --- a/tests/assets/test_zenroom_signing.py +++ b/tests/assets/test_zenroom_signing.py @@ -52,7 +52,6 @@ metadata = {"units": 300, "type": "KG"} def test_zenroom_signing(): - biolabs = generate_key_pair() version = "3.0" diff --git a/tests/db/test_planetmint_api.py b/tests/db/test_planetmint_api.py index f0bcbc0..27e43c0 100644 --- a/tests/db/test_planetmint_api.py +++ b/tests/db/test_planetmint_api.py @@ -99,7 +99,6 @@ class TestBigchainApi(object): b.validate_transaction(tx) def test_write_transaction(self, b, user_sk, user_pk, alice, create_tx): - asset1 = {"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"} tx = Create.generate([alice.public_key], [([alice.public_key], 1)], assets=[asset1]).sign([alice.private_key]) diff --git a/tests/test_config_utils.py b/tests/test_config_utils.py index f537830..382066b 100644 --- a/tests/test_config_utils.py +++ b/tests/test_config_utils.py @@ -315,7 +315,6 @@ def test_write_config(): ), ) def test_database_envs(env_name, env_value, config_key, monkeypatch): - monkeypatch.setattr("os.environ", {env_name: env_value}) planetmint.config_utils.autoconfigure() diff --git a/tests/upsert_validator/test_upsert_validator_vote.py b/tests/upsert_validator/test_upsert_validator_vote.py index b0e649e..8aeb5a9 100644 --- a/tests/upsert_validator/test_upsert_validator_vote.py +++ b/tests/upsert_validator/test_upsert_validator_vote.py @@ -155,7 +155,6 @@ def test_valid_election_votes_received(b_mock, valid_upsert_validator_election, @pytest.mark.bdb def test_valid_election_conclude(b_mock, valid_upsert_validator_election, ed25519_node_keys): - # Node 0: cast vote tx_vote0 = gen_vote(valid_upsert_validator_election, 0, ed25519_node_keys) @@ -214,7 +213,6 @@ def test_valid_election_conclude(b_mock, valid_upsert_validator_election, ed2551 @pytest.mark.abci def test_upsert_validator(b, node_key, node_keys, ed25519_node_keys): - if b.get_latest_block()["height"] == 0: generate_block(b) @@ -343,6 +341,6 @@ def test_get_validator_update(b, node_keys, node_key, ed25519_node_keys): def reset_validator_set(b, node_keys, height): validators = [] - for (node_pub, _) in node_keys.items(): + for node_pub, _ in node_keys.items(): validators.append({"public_key": {"type": "ed25519-base64", "value": node_pub}, "voting_power": 10}) b.store_validator_set(height, validators) diff --git a/tests/web/test_assets.py b/tests/web/test_assets.py index 366b487..d22d802 100644 --- a/tests/web/test_assets.py +++ b/tests/web/test_assets.py @@ -24,7 +24,6 @@ def test_get_assets_with_missing_text_search(client): @pytest.mark.bdb def test_get_assets_tendermint(client, b, alice): - # test returns empty list when no assets are found res = client.get(ASSETS_ENDPOINT + "?search=abc") assert res.json == [] @@ -45,7 +44,6 @@ def test_get_assets_tendermint(client, b, alice): @pytest.mark.bdb def test_get_assets_limit_tendermint(client, b, alice): - # create two assets assets1 = [{"data": multihash(marshal({"msg": "abc 1"}))}] assets2 = [{"data": multihash(marshal({"msg": "abc 2"}))}] diff --git a/tests/web/test_metadata.py b/tests/web/test_metadata.py index bf3f6c8..c42b01b 100644 --- a/tests/web/test_metadata.py +++ b/tests/web/test_metadata.py @@ -48,7 +48,6 @@ def test_get_metadata_tendermint(client, b, alice): @pytest.mark.bdb def test_get_metadata_limit_tendermint(client, b, alice): - # create two assets assets1 = [{"data": multihash(marshal({"msg": "abc 1"}))}] meta1 = multihash(marshal({"key": "meta 1"})) diff --git a/tests/web/test_transactions.py b/tests/web/test_transactions.py index e4e8007..2ff1921 100644 --- a/tests/web/test_transactions.py +++ b/tests/web/test_transactions.py @@ -327,7 +327,6 @@ def test_post_invalid_transaction( @pytest.mark.abci def test_post_transfer_transaction_endpoint(client, user_pk, user_sk, posted_create_tx): - transfer_tx = Transfer.generate(posted_create_tx.to_inputs(), [([user_pk], 1)], asset_ids=[posted_create_tx.id]) transfer_tx = transfer_tx.sign([user_sk]) From 871a8c1c09d311e03823c480f26b92bcd5ebae80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Eckel?= Date: Tue, 14 Feb 2023 22:48:11 +0100 Subject: [PATCH 7/7] fix dependency management issuexy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Eckel --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 8b8f2f9..5d84580 100644 --- a/setup.py +++ b/setup.py @@ -60,7 +60,7 @@ docs_require = [ "mdit-py-plugins==0.3.0", "mdurl==0.1.1", "myst-parser==0.17.2", - "packaging==21.3", + "packaging>=22.0", "pockets==0.9.1", "Pygments==2.12.0", "pyparsing==3.0.8", @@ -116,7 +116,7 @@ install_requires = [ "gunicorn==20.1.0", "jsonschema==4.16.0", "logstats==0.3.0", - "packaging>=20.9", + "packaging>=22.0", "pymongo==3.11.4", "tarantool==0.7.1", "python-rapidjson>=1.0",