mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-18 22:54:23 +01:00
Removes redundant tests
This commit is contained in:
@@ -1,7 +1,4 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from uuid import uuid4
|
|
||||||
from hashlib import sha256
|
|
||||||
from binascii import unhexlify
|
|
||||||
|
|
||||||
from pisa import c_logger
|
from pisa import c_logger
|
||||||
from pisa.block_processor import BlockProcessor
|
from pisa.block_processor import BlockProcessor
|
||||||
@@ -9,19 +6,6 @@ from test.unit.conftest import get_random_value_hex
|
|||||||
|
|
||||||
c_logger.disabled = True
|
c_logger.disabled = True
|
||||||
|
|
||||||
APPOINTMENT_COUNT = 100
|
|
||||||
TEST_SET_SIZE = 200
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
|
||||||
def txids():
|
|
||||||
return [get_random_value_hex(32) for _ in range(APPOINTMENT_COUNT)]
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
|
||||||
def locator_uuid_map(txids):
|
|
||||||
return {sha256(unhexlify(txid)).hexdigest(): uuid4().hex for txid in txids}
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def best_block_hash():
|
def best_block_hash():
|
||||||
@@ -52,29 +36,3 @@ def test_get_random_block():
|
|||||||
def test_get_block_count():
|
def test_get_block_count():
|
||||||
block_count = BlockProcessor.get_block_count()
|
block_count = BlockProcessor.get_block_count()
|
||||||
assert isinstance(block_count, int) and block_count >= 0
|
assert isinstance(block_count, int) and block_count >= 0
|
||||||
|
|
||||||
|
|
||||||
def test_potential_matches(txids, locator_uuid_map):
|
|
||||||
potential_matches = BlockProcessor.get_potential_matches(txids, locator_uuid_map)
|
|
||||||
|
|
||||||
# All the txids must match
|
|
||||||
assert locator_uuid_map.keys() == potential_matches.keys()
|
|
||||||
|
|
||||||
|
|
||||||
def test_potential_matches_random(locator_uuid_map):
|
|
||||||
txids = [get_random_value_hex(32) for _ in range(len(locator_uuid_map))]
|
|
||||||
|
|
||||||
potential_matches = BlockProcessor.get_potential_matches(txids, locator_uuid_map)
|
|
||||||
|
|
||||||
# None of the ids should match
|
|
||||||
assert len(potential_matches) == 0
|
|
||||||
|
|
||||||
|
|
||||||
def test_potential_matches_random_data(locator_uuid_map):
|
|
||||||
# The likelihood of finding a potential match with random data should be negligible
|
|
||||||
txids = [get_random_value_hex(32) for _ in range(TEST_SET_SIZE)]
|
|
||||||
|
|
||||||
potential_matches = BlockProcessor.get_potential_matches(txids, locator_uuid_map)
|
|
||||||
|
|
||||||
# None of the txids should match
|
|
||||||
assert len(potential_matches) == 0
|
|
||||||
|
|||||||
@@ -17,23 +17,3 @@ def test_equal():
|
|||||||
e_blob2 = EncryptedBlob(data)
|
e_blob2 = EncryptedBlob(data)
|
||||||
|
|
||||||
assert e_blob1 == e_blob2 and id(e_blob1) != id(e_blob2)
|
assert e_blob1 == e_blob2 and id(e_blob1) != id(e_blob2)
|
||||||
|
|
||||||
|
|
||||||
def test_decrypt():
|
|
||||||
# TODO: The decryption tests are assuming the cipher is AES-GCM-128, since EncryptedBlob assumes the same. Fix this.
|
|
||||||
key = get_random_value_hex(32)
|
|
||||||
encrypted_data = get_random_value_hex(64)
|
|
||||||
encrypted_blob = EncryptedBlob(encrypted_data)
|
|
||||||
|
|
||||||
# Trying to decrypt random data (in AES_GCM-128) should result in an InvalidTag exception. Our decrypt function
|
|
||||||
# returns None
|
|
||||||
hex_tx = encrypted_blob.decrypt(key)
|
|
||||||
assert hex_tx is None
|
|
||||||
|
|
||||||
# Valid data should run with no InvalidTag and verify
|
|
||||||
data = "6097cdf52309b1b2124efeed36bd34f46dc1c25ad23ac86f28380f746254f777"
|
|
||||||
key = "b2e984a570f6f49bc38ace178e09147b0aa296cbb7c92eb01412f7e2d07b5659"
|
|
||||||
encrypted_data = "092e93d4a34aac4367075506f2c050ddfa1a201ee6669b65058572904dcea642aeb01ea4b57293618e8c46809dfadadc"
|
|
||||||
encrypted_blob = EncryptedBlob(encrypted_data)
|
|
||||||
|
|
||||||
assert encrypted_blob.decrypt(key) == data
|
|
||||||
|
|||||||
Reference in New Issue
Block a user