mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-13 12:33:25 +02:00
Remove old server tests (#631)
This commit is contained in:
parent
00b0e8ec20
commit
00d346668a
4 changed files with 0 additions and 91 deletions
|
|
@ -1,25 +0,0 @@
|
|||
import logging
|
||||
|
||||
from squeak.core import CheckSqueak
|
||||
from squeak.core import CheckSqueakError
|
||||
from squeak.core import CSqueak
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SqueakValidator(object):
|
||||
"""Validates incoming squeaks"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
def validate(self, squeak: CSqueak) -> bool:
|
||||
if not squeak:
|
||||
return False
|
||||
|
||||
try:
|
||||
CheckSqueak(squeak)
|
||||
return True
|
||||
except CheckSqueakError as e:
|
||||
logger.info("Got invalid squeak with error: {}".format(e))
|
||||
return False
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
import time
|
||||
|
||||
import pytest
|
||||
from bitcoin.core import lx
|
||||
from squeak.core import HASH_LENGTH
|
||||
from squeak.core import MakeSqueakFromStr
|
||||
from squeak.core.signing import CSigningKey
|
||||
|
||||
from squeaknode.server.squeak_validator import SqueakValidator
|
||||
|
||||
# # read in SQL for populating test data
|
||||
# with open(os.path.join(os.path.dirname(__file__), "data.sql"), "rb") as f:
|
||||
# _data_sql = f.read().decode("utf8")
|
||||
|
||||
|
||||
def make_squeak(
|
||||
signing_key: CSigningKey, content: str, reply_to: bytes = b"\x00" * HASH_LENGTH
|
||||
):
|
||||
block_height = 0
|
||||
block_hash = lx(
|
||||
"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b")
|
||||
timestamp = int(time.time())
|
||||
return MakeSqueakFromStr(
|
||||
signing_key,
|
||||
content,
|
||||
block_height,
|
||||
block_hash,
|
||||
timestamp,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def signing_key():
|
||||
return CSigningKey.generate()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def validator():
|
||||
return SqueakValidator()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def example_squeak(signing_key):
|
||||
return make_squeak(
|
||||
signing_key,
|
||||
"hello!",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bad_squeak(signing_key):
|
||||
squeak = make_squeak(
|
||||
signing_key,
|
||||
"hello!",
|
||||
)
|
||||
squeak.ClearDecryptionKey()
|
||||
return squeak
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO post (title, body, created)
|
||||
VALUES
|
||||
('test title', 'test' || x'0a' || 'body', '2018-01-01 00:00:00');
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
def test_validate(validator, example_squeak):
|
||||
assert validator.validate(example_squeak)
|
||||
|
||||
|
||||
def test_validate_bad_squeak(validator, bad_squeak):
|
||||
assert not validator.validate(bad_squeak)
|
||||
Loading…
Add table
Add a link
Reference in a new issue