mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-24 22:45:44 +00:00
adjusted hashlib imports and renamed to bigchaindb error
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
69fe9b253d
commit
cddfe862ef
@ -3,10 +3,10 @@
|
|||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
# Code is Apache-2.0 and docs are 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."""
|
"""Top level exception for any backend exception."""
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,9 +4,9 @@
|
|||||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||||
|
|
||||||
|
|
||||||
class BigchainDBError(Exception):
|
class PlanetmintError(Exception):
|
||||||
"""Base class for Planetmint exceptions."""
|
"""Base class for Planetmint exceptions."""
|
||||||
|
|
||||||
|
|
||||||
class CriticalDoubleSpend(BigchainDBError):
|
class CriticalDoubleSpend(PlanetmintError):
|
||||||
"""Data integrity error that requires attention"""
|
"""Data integrity error that requires attention"""
|
||||||
|
|||||||
@ -13,11 +13,7 @@ from uuid import uuid4
|
|||||||
|
|
||||||
import rapidjson
|
import rapidjson
|
||||||
|
|
||||||
try:
|
|
||||||
from hashlib import sha3_256
|
from hashlib import sha3_256
|
||||||
except ImportError:
|
|
||||||
# NOTE: needed for Python < 3.6
|
|
||||||
from sha3 import sha3_256
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|||||||
@ -8,10 +8,7 @@ import hashlib
|
|||||||
import json
|
import json
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
|
|
||||||
try:
|
|
||||||
from hashlib import sha3_256
|
from hashlib import sha3_256
|
||||||
except ImportError:
|
|
||||||
from sha3 import sha3_256
|
|
||||||
|
|
||||||
|
|
||||||
def encode_transaction(value):
|
def encode_transaction(value):
|
||||||
|
|||||||
@ -5,12 +5,7 @@
|
|||||||
|
|
||||||
# Separate all crypto code so that we can easily test several implementations
|
# Separate all crypto code so that we can easily test several implementations
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
try:
|
|
||||||
from hashlib import sha3_256
|
from hashlib import sha3_256
|
||||||
except ImportError:
|
|
||||||
from sha3 import sha3_256
|
|
||||||
|
|
||||||
from cryptoconditions import crypto
|
from cryptoconditions import crypto
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,32 +5,32 @@
|
|||||||
|
|
||||||
"""Custom exceptions used in the `planetmint` package.
|
"""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"""
|
"""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"""
|
"""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"""
|
"""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"""
|
"""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
|
"""Raised if the private key(s) provided for signing don't match any of the
|
||||||
current owner(s)
|
current owner(s)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class OperationError(BigchainDBError):
|
class OperationError(PlanetmintError):
|
||||||
"""Raised when an operation cannot go through"""
|
"""Raised when an operation cannot go through"""
|
||||||
|
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class OperationError(BigchainDBError):
|
|||||||
# especially for the purposes of testing.
|
# especially for the purposes of testing.
|
||||||
|
|
||||||
|
|
||||||
class ValidationError(BigchainDBError):
|
class ValidationError(PlanetmintError):
|
||||||
"""Raised if there was an error in validation"""
|
"""Raised if there was an error in validation"""
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -21,10 +21,7 @@ from cryptoconditions import Fulfillment, ThresholdSha256, Ed25519Sha256, Zenroo
|
|||||||
from cryptoconditions.exceptions import ParsingError, ASN1DecodeError, ASN1EncodeError
|
from cryptoconditions.exceptions import ParsingError, ASN1DecodeError, ASN1EncodeError
|
||||||
from cid import is_cid
|
from cid import is_cid
|
||||||
|
|
||||||
try:
|
|
||||||
from hashlib import sha3_256
|
from hashlib import sha3_256
|
||||||
except ImportError:
|
|
||||||
from sha3 import sha3_256
|
|
||||||
|
|
||||||
from planetmint.transactions.common.crypto import PrivateKey, hash_data
|
from planetmint.transactions.common.crypto import PrivateKey, hash_data
|
||||||
from planetmint.transactions.common.exceptions import (
|
from planetmint.transactions.common.exceptions import (
|
||||||
|
|||||||
@ -22,12 +22,8 @@ from cryptoconditions import Fulfillment
|
|||||||
from cryptoconditions import PreimageSha256
|
from cryptoconditions import PreimageSha256
|
||||||
from cryptoconditions import Ed25519Sha256
|
from cryptoconditions import Ed25519Sha256
|
||||||
from pytest import mark, raises
|
from pytest import mark, raises
|
||||||
from ipld import marshal, multihash
|
|
||||||
|
|
||||||
try:
|
|
||||||
from hashlib import sha3_256
|
from hashlib import sha3_256
|
||||||
except ImportError:
|
|
||||||
from sha3 import sha3_256
|
|
||||||
|
|
||||||
pytestmark = mark.bdb
|
pytestmark = mark.bdb
|
||||||
|
|
||||||
|
|||||||
@ -9,11 +9,7 @@ from unittest.mock import patch
|
|||||||
from planetmint.transactions.types.assets.create import Create
|
from planetmint.transactions.types.assets.create import Create
|
||||||
from planetmint.transactions.types.assets.transfer import Transfer
|
from planetmint.transactions.types.assets.transfer import Transfer
|
||||||
|
|
||||||
try:
|
|
||||||
from hashlib import sha3_256
|
from hashlib import sha3_256
|
||||||
except ImportError:
|
|
||||||
# NOTE: needed for Python < 3.6
|
|
||||||
from sha3 import sha3_256
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pymongo import MongoClient
|
from pymongo import MongoClient
|
||||||
|
|||||||
@ -7,10 +7,7 @@ import base64
|
|||||||
import json
|
import json
|
||||||
from pytest import mark
|
from pytest import mark
|
||||||
|
|
||||||
try:
|
|
||||||
from hashlib import sha3_256
|
from hashlib import sha3_256
|
||||||
except ImportError:
|
|
||||||
from sha3 import sha3_256
|
|
||||||
|
|
||||||
|
|
||||||
def test_encode_decode_transaction(b):
|
def test_encode_decode_transaction(b):
|
||||||
|
|||||||
@ -11,10 +11,7 @@ import json
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
try:
|
|
||||||
import hashlib as sha3
|
import hashlib as sha3
|
||||||
except ImportError:
|
|
||||||
import sha3
|
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
from planetmint.transactions.common.exceptions import AmountError, SchemaValidationError, ThresholdTooDeep
|
from planetmint.transactions.common.exceptions import AmountError, SchemaValidationError, ThresholdTooDeep
|
||||||
|
|||||||
@ -11,10 +11,7 @@ import pytest
|
|||||||
from cryptoconditions import Ed25519Sha256
|
from cryptoconditions import Ed25519Sha256
|
||||||
from ipld import multihash, marshal
|
from ipld import multihash, marshal
|
||||||
|
|
||||||
try:
|
|
||||||
from hashlib import sha3_256
|
from hashlib import sha3_256
|
||||||
except ImportError:
|
|
||||||
from sha3 import sha3_256
|
|
||||||
|
|
||||||
from planetmint.transactions.common import crypto
|
from planetmint.transactions.common import crypto
|
||||||
from planetmint.transactions.types.assets.create import Create
|
from planetmint.transactions.types.assets.create import Create
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user