diff --git a/planetmint/backend/exceptions.py b/planetmint/backend/exceptions.py index 2ab5ef6..cf22952 100644 --- a/planetmint/backend/exceptions.py +++ b/planetmint/backend/exceptions.py @@ -3,10 +3,10 @@ # SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) # Code is Apache-2.0 and docs are CC-BY-4.0 -from planetmint.exceptions import BigchainDBError +from planetmint.exceptions import PlanetmintError -class BackendError(BigchainDBError): +class BackendError(PlanetmintError): """Top level exception for any backend exception.""" diff --git a/planetmint/exceptions.py b/planetmint/exceptions.py index 9e12b7c..624f1e9 100644 --- a/planetmint/exceptions.py +++ b/planetmint/exceptions.py @@ -4,9 +4,9 @@ # Code is Apache-2.0 and docs are CC-BY-4.0 -class BigchainDBError(Exception): +class PlanetmintError(Exception): """Base class for Planetmint exceptions.""" -class CriticalDoubleSpend(BigchainDBError): +class CriticalDoubleSpend(PlanetmintError): """Data integrity error that requires attention""" diff --git a/planetmint/lib.py b/planetmint/lib.py index 3c37124..ceb8a0c 100644 --- a/planetmint/lib.py +++ b/planetmint/lib.py @@ -13,11 +13,7 @@ from uuid import uuid4 import rapidjson -try: - from hashlib import sha3_256 -except ImportError: - # NOTE: needed for Python < 3.6 - from sha3 import sha3_256 +from hashlib import sha3_256 import requests diff --git a/planetmint/tendermint_utils.py b/planetmint/tendermint_utils.py index 508a1be..ad7bb66 100644 --- a/planetmint/tendermint_utils.py +++ b/planetmint/tendermint_utils.py @@ -8,10 +8,7 @@ import hashlib import json from binascii import hexlify -try: - from hashlib import sha3_256 -except ImportError: - from sha3 import sha3_256 +from hashlib import sha3_256 def encode_transaction(value): diff --git a/planetmint/transactions/common/crypto.py b/planetmint/transactions/common/crypto.py index 0812018..968088d 100644 --- a/planetmint/transactions/common/crypto.py +++ b/planetmint/transactions/common/crypto.py @@ -5,12 +5,7 @@ # Separate all crypto code so that we can easily test several implementations from collections import namedtuple - -try: - from hashlib import sha3_256 -except ImportError: - from sha3 import sha3_256 - +from hashlib import sha3_256 from cryptoconditions import crypto diff --git a/planetmint/transactions/common/exceptions.py b/planetmint/transactions/common/exceptions.py index ed0c307..780fe01 100644 --- a/planetmint/transactions/common/exceptions.py +++ b/planetmint/transactions/common/exceptions.py @@ -5,32 +5,32 @@ """Custom exceptions used in the `planetmint` package. """ -from planetmint.exceptions import BigchainDBError +from planetmint.exceptions import PlanetmintError -class ConfigurationError(BigchainDBError): +class ConfigurationError(PlanetmintError): """Raised when there is a problem with server configuration""" -class DatabaseDoesNotExist(BigchainDBError): +class DatabaseDoesNotExist(PlanetmintError): """Raised when trying to delete the database but the db is not there""" -class StartupError(BigchainDBError): +class StartupError(PlanetmintError): """Raised when there is an error starting up the system""" -class CyclicBlockchainError(BigchainDBError): +class CyclicBlockchainError(PlanetmintError): """Raised when there is a cycle in the blockchain""" -class KeypairMismatchException(BigchainDBError): +class KeypairMismatchException(PlanetmintError): """Raised if the private key(s) provided for signing don't match any of the current owner(s) """ -class OperationError(BigchainDBError): +class OperationError(PlanetmintError): """Raised when an operation cannot go through""" @@ -43,7 +43,7 @@ class OperationError(BigchainDBError): # especially for the purposes of testing. -class ValidationError(BigchainDBError): +class ValidationError(PlanetmintError): """Raised if there was an error in validation""" diff --git a/planetmint/transactions/common/transaction.py b/planetmint/transactions/common/transaction.py index 33f504c..48f2aaf 100644 --- a/planetmint/transactions/common/transaction.py +++ b/planetmint/transactions/common/transaction.py @@ -21,10 +21,7 @@ from cryptoconditions import Fulfillment, ThresholdSha256, Ed25519Sha256, Zenroo from cryptoconditions.exceptions import ParsingError, ASN1DecodeError, ASN1EncodeError from cid import is_cid -try: - from hashlib import sha3_256 -except ImportError: - from sha3 import sha3_256 +from hashlib import sha3_256 from planetmint.transactions.common.crypto import PrivateKey, hash_data from planetmint.transactions.common.exceptions import ( diff --git a/tests/common/test_transaction.py b/tests/common/test_transaction.py index 5e81937..1c0f0e7 100644 --- a/tests/common/test_transaction.py +++ b/tests/common/test_transaction.py @@ -22,12 +22,8 @@ from cryptoconditions import Fulfillment from cryptoconditions import PreimageSha256 from cryptoconditions import Ed25519Sha256 from pytest import mark, raises -from ipld import marshal, multihash -try: - from hashlib import sha3_256 -except ImportError: - from sha3 import sha3_256 +from hashlib import sha3_256 pytestmark = mark.bdb diff --git a/tests/tendermint/test_lib.py b/tests/tendermint/test_lib.py index c7e7077..7c1e04a 100644 --- a/tests/tendermint/test_lib.py +++ b/tests/tendermint/test_lib.py @@ -9,11 +9,7 @@ from unittest.mock import patch from planetmint.transactions.types.assets.create import Create from planetmint.transactions.types.assets.transfer import Transfer -try: - from hashlib import sha3_256 -except ImportError: - # NOTE: needed for Python < 3.6 - from sha3 import sha3_256 +from hashlib import sha3_256 import pytest from pymongo import MongoClient diff --git a/tests/tendermint/test_utils.py b/tests/tendermint/test_utils.py index fe9dc62..c6cfd45 100644 --- a/tests/tendermint/test_utils.py +++ b/tests/tendermint/test_utils.py @@ -7,10 +7,7 @@ import base64 import json from pytest import mark -try: - from hashlib import sha3_256 -except ImportError: - from sha3 import sha3_256 +from hashlib import sha3_256 def test_encode_decode_transaction(b): diff --git a/tests/validation/test_transaction_structure.py b/tests/validation/test_transaction_structure.py index 83ccef3..aa5df28 100644 --- a/tests/validation/test_transaction_structure.py +++ b/tests/validation/test_transaction_structure.py @@ -11,10 +11,7 @@ import json import pytest -try: - import hashlib as sha3 -except ImportError: - import sha3 +import hashlib as sha3 from unittest.mock import MagicMock from planetmint.transactions.common.exceptions import AmountError, SchemaValidationError, ThresholdTooDeep diff --git a/tests/web/test_transactions.py b/tests/web/test_transactions.py index b2fd3e0..6ea6aad 100644 --- a/tests/web/test_transactions.py +++ b/tests/web/test_transactions.py @@ -11,10 +11,7 @@ import pytest from cryptoconditions import Ed25519Sha256 from ipld import multihash, marshal -try: - from hashlib import sha3_256 -except ImportError: - from sha3 import sha3_256 +from hashlib import sha3_256 from planetmint.transactions.common import crypto from planetmint.transactions.types.assets.create import Create