mirror of
https://github.com/planetmint/planetmint.git
synced 2025-10-14 00:59:17 +00:00
blackified
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
parent
7f3977b954
commit
6d166747d1
@ -51,7 +51,7 @@ def test_load_validation_plugin_raises_with_invalid_subclass(monkeypatch):
|
||||
|
||||
monkeypatch.setattr(
|
||||
config_utils, "iter_entry_points", lambda *args: [type("entry_point", (object,), {"load": lambda: object})]
|
||||
)my_config
|
||||
)
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
# Since the function is decorated with `lru_cache`, we need to
|
||||
@ -317,7 +317,7 @@ 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()
|
||||
Config
|
||||
|
||||
expected_config = Config().get()
|
||||
expected_config["database"][config_key] = env_value
|
||||
|
||||
|
@ -2,4 +2,3 @@
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -169,9 +169,7 @@ class App(BaseApplication):
|
||||
self.abort_if_abci_chain_is_not_synced()
|
||||
|
||||
logger.debug("deliver_tx: %s", raw_transaction)
|
||||
transaction = self.validator.is_valid_transaction(
|
||||
decode_transaction(raw_transaction), self.block_transactions
|
||||
)
|
||||
transaction = self.validator.is_valid_transaction(decode_transaction(raw_transaction), self.block_transactions)
|
||||
|
||||
if not transaction:
|
||||
logger.debug("deliver_tx: INVALID")
|
||||
@ -247,4 +245,3 @@ class App(BaseApplication):
|
||||
self.events_queue.put(event)
|
||||
|
||||
return ResponseCommit(data=data)
|
||||
|
||||
|
@ -43,7 +43,6 @@ class Validator:
|
||||
self.models = Models()
|
||||
self.validation = Validator._get_validationmethod()
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _get_validationmethod():
|
||||
validationPlugin = Config().get().get("validation_plugin")
|
||||
|
@ -15,8 +15,6 @@ import sys
|
||||
import planetmint
|
||||
|
||||
|
||||
|
||||
|
||||
from transactions.common.transaction_mode_types import BROADCAST_TX_COMMIT
|
||||
from transactions.common.exceptions import DatabaseDoesNotExist, ValidationError
|
||||
from transactions.types.elections.vote import Vote
|
||||
|
@ -82,8 +82,6 @@ class Models:
|
||||
elif spent is False:
|
||||
return self.fastquery.filter_spent_outputs(outputs)
|
||||
|
||||
|
||||
|
||||
def store_block(self, block):
|
||||
"""Create a new block."""
|
||||
|
||||
@ -230,7 +228,6 @@ class Models:
|
||||
# flatten and return all found assets
|
||||
return list(chain.from_iterable([Asset.list_to_dict(tx.assets) for tx in asset_txs]))
|
||||
|
||||
|
||||
def get_metadata(self, txn_ids) -> list[MetaData]:
|
||||
"""Return a list of metadata that match the transaction ids (txn_ids)
|
||||
|
||||
@ -284,4 +281,3 @@ class Models:
|
||||
@property
|
||||
def fastquery(self):
|
||||
return FastQuery(self.connection)
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
|
||||
class
|
@ -10,6 +10,7 @@ from transactions.types.assets.transfer import Transfer
|
||||
from transactions.types.assets.compose import Compose
|
||||
from transactions.types.assets.decompose import Decompose
|
||||
|
||||
|
||||
def test_asset_transfer(b, signed_create_tx, user_pk, user_sk, _bdb):
|
||||
tx_transfer = Transfer.generate(signed_create_tx.to_inputs(), [([user_pk], 1)], [signed_create_tx.id])
|
||||
tx_transfer_signed = tx_transfer.sign([user_sk])
|
||||
|
@ -255,19 +255,25 @@ def test_models():
|
||||
|
||||
return Models()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_validator():
|
||||
from planetmint.application import Validator
|
||||
|
||||
return Validator()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_abci_rpc():
|
||||
from planetmint.abci.rpc import ABCI_RPC
|
||||
|
||||
return ABCI_RPC()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def b():
|
||||
from planetmint.application import Validator
|
||||
|
||||
return Validator()
|
||||
|
||||
|
||||
@ -310,7 +316,9 @@ def signed_create_tx(alice, create_tx):
|
||||
|
||||
@pytest.fixture
|
||||
def posted_create_tx(b, signed_create_tx, test_abci_rpc):
|
||||
res = test_abci_rpc.post_transaction(MODE_LIST, test_abci_rpc.tendermint_rpc_endpoint, signed_create_tx, BROADCAST_TX_COMMIT)
|
||||
res = test_abci_rpc.post_transaction(
|
||||
MODE_LIST, test_abci_rpc.tendermint_rpc_endpoint, signed_create_tx, BROADCAST_TX_COMMIT
|
||||
)
|
||||
assert res.status_code == 200
|
||||
return signed_create_tx
|
||||
|
||||
|
@ -365,6 +365,7 @@ class TestMultipleInputs(object):
|
||||
|
||||
def test_get_outputs_filtered_only_unspent(b):
|
||||
from transactions.common.transaction import TransactionLink
|
||||
|
||||
go = "planetmint.model.fastquery.FastQuery.get_outputs_by_public_key"
|
||||
with patch(go) as get_outputs:
|
||||
get_outputs.return_value = [TransactionLink("a", 1), TransactionLink("b", 2)]
|
||||
@ -378,6 +379,7 @@ def test_get_outputs_filtered_only_unspent(b):
|
||||
|
||||
def test_get_outputs_filtered_only_spent(b):
|
||||
from transactions.common.transaction import TransactionLink
|
||||
|
||||
go = "planetmint.model.fastquery.FastQuery.get_outputs_by_public_key"
|
||||
with patch(go) as get_outputs:
|
||||
get_outputs.return_value = [TransactionLink("a", 1), TransactionLink("b", 2)]
|
||||
@ -391,7 +393,10 @@ def test_get_outputs_filtered_only_spent(b):
|
||||
|
||||
# @patch("planetmint.model.fastquery.FastQuery.filter_unspent_outputs")
|
||||
# @patch("planetmint.model.fastquery.FastQuery.filter_spent_outputs")
|
||||
def test_get_outputs_filtered(b, mocker,):
|
||||
def test_get_outputs_filtered(
|
||||
b,
|
||||
mocker,
|
||||
):
|
||||
from transactions.common.transaction import TransactionLink
|
||||
|
||||
mock_filter_spent_outputs = mocker.patch("planetmint.model.fastquery.FastQuery.filter_spent_outputs")
|
||||
|
@ -138,7 +138,11 @@ def test_process_block_approves_after_pending_validator_update(b):
|
||||
assert not b.models.get_election(txs[1].id)["is_concluded"]
|
||||
assert b.models.get_election(txs[2].id)["is_concluded"]
|
||||
|
||||
assert b.models.get_latest_abci_chain() == {"height": 2, "chain_id": "chain-X-migrated-at-height-1", "is_synced": False}
|
||||
assert b.models.get_latest_abci_chain() == {
|
||||
"height": 2,
|
||||
"chain_id": "chain-X-migrated-at-height-1",
|
||||
"is_synced": False,
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
@ -168,7 +172,9 @@ def test_process_block_does_not_approve_after_validator_update(b):
|
||||
|
||||
b.process_block(2, total_votes + [second_election])
|
||||
|
||||
b.models.store_block(Block(height=2, transactions=[v.id for v in total_votes + [second_election]], app_hash="")._asdict())
|
||||
b.models.store_block(
|
||||
Block(height=2, transactions=[v.id for v in total_votes + [second_election]], app_hash="")._asdict()
|
||||
)
|
||||
|
||||
b.models.store_abci_chain(1, "chain-X")
|
||||
b.process_block(3, second_votes)
|
||||
|
@ -23,8 +23,7 @@ from uuid import uuid4
|
||||
|
||||
from planetmint.abci.rpc import ABCI_RPC
|
||||
from planetmint.abci.rpc import MODE_COMMIT, MODE_LIST
|
||||
from tests.utils import delete_unspent_outputs, get_utxoset_merkle_root, store_unspent_outputs, \
|
||||
update_utxoset
|
||||
from tests.utils import delete_unspent_outputs, get_utxoset_merkle_root, store_unspent_outputs, update_utxoset
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
@ -112,7 +111,9 @@ def test_write_and_post_transaction(mock_post, b, test_abci_rpc):
|
||||
)
|
||||
|
||||
tx = b.validate_transaction(tx)
|
||||
test_abci_rpc.write_transaction(MODE_LIST, test_abci_rpc.tendermint_rpc_endpoint, MODE_COMMIT, tx, BROADCAST_TX_ASYNC)
|
||||
test_abci_rpc.write_transaction(
|
||||
MODE_LIST, test_abci_rpc.tendermint_rpc_endpoint, MODE_COMMIT, tx, BROADCAST_TX_ASYNC
|
||||
)
|
||||
|
||||
assert mock_post.called
|
||||
args, kwargs = mock_post.call_args
|
||||
|
Loading…
x
Reference in New Issue
Block a user