package changes (#411)

* package changes

---------

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel 2025-02-13 17:11:34 +01:00 committed by GitHub
parent f3077ee8e3
commit 58131d445a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 1346 additions and 1138 deletions

View File

@ -26,7 +26,7 @@ export PRINT_HELP_PYSCRIPT
# Basic commands # # Basic commands #
################## ##################
DOCKER := docker DOCKER := docker
DC := docker-compose DC := docker compose
HELP := python -c "$$PRINT_HELP_PYSCRIPT" HELP := python -c "$$PRINT_HELP_PYSCRIPT"
ECHO := /usr/bin/env echo ECHO := /usr/bin/env echo

View File

@ -3,8 +3,7 @@
# 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
"""Common classes and methods for API handlers """Common classes and methods for API handlers"""
"""
import logging import logging
from flask import jsonify, request from flask import jsonify, request

2414
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@ planetmint = "planetmint.commands.planetmint:main"
python = "^3.9" python = "^3.9"
chardet = "3.0.4" chardet = "3.0.4"
base58 = "2.1.1" base58 = "2.1.1"
aiohttp = "^3.8.4" aiohttp = "3.9.5"
flask-cors = "3.0.10" flask-cors = "3.0.10"
flask-restful = "0.3.9" flask-restful = "0.3.9"
flask = "2.1.2" flask = "2.1.2"
@ -36,7 +36,7 @@ packaging = ">=22.0"
pymongo = "3.11.4" pymongo = "3.11.4"
tarantool = ">=0.12.1" tarantool = ">=0.12.1"
python-rapidjson = ">=1.0" python-rapidjson = ">=1.0"
pyyaml = "6.0.0" pyyaml = "6.0.2"
requests = "2.31.0" requests = "2.31.0"
setproctitle = "1.2.2" setproctitle = "1.2.2"
werkzeug = "2.0.3" werkzeug = "2.0.3"
@ -49,6 +49,7 @@ planetmint-transactions = ">=0.8.1"
asynctnt = "^2.0.1" asynctnt = "^2.0.1"
planetmint-abci = "^0.8.4" planetmint-abci = "^0.8.4"
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
aafigure = "0.6" aafigure = "0.6"
alabaster = "0.7.12" alabaster = "0.7.12"
@ -105,8 +106,8 @@ pytest-cov = "2.8.1"
pytest-mock = "^3.10.0" pytest-mock = "^3.10.0"
pytest-xdist = "^3.1.0" pytest-xdist = "^3.1.0"
pytest-flask = "^1.2.0" pytest-flask = "^1.2.0"
pytest-aiohttp = "^1.0.4" pytest-aiohttp = "1.0.4"
pytest-asyncio = "^0.20.3" pytest-asyncio = "0.19.0"
pip-audit = "^2.5.6" pip-audit = "^2.5.6"
[build-system] [build-system]

View File

@ -3,7 +3,7 @@ testpaths = tests/
norecursedirs = .* *.egg *.egg-info env* devenv* docs norecursedirs = .* *.egg *.egg-info env* devenv* docs
addopts = -m "not abci" addopts = -m "not abci"
looponfailroots = planetmint tests looponfailroots = planetmint tests
asyncio_mode = strict asyncio_mode = auto
markers = markers =
bdb: bdb bdb: bdb
skip: skip skip: skip

View File

@ -1,5 +1,6 @@
import json import json
import base58 import base58
import pytest
from hashlib import sha3_256 from hashlib import sha3_256
from planetmint_cryptoconditions.types.ed25519 import Ed25519Sha256 from planetmint_cryptoconditions.types.ed25519 import Ed25519Sha256
@ -31,6 +32,7 @@ metadata = {"units": 300, "type": "KG"}
SCRIPT_OUTPUTS = ["ok"] SCRIPT_OUTPUTS = ["ok"]
@pytest.mark.skip(reason="new zenroom adjusteds have to be made")
def test_zenroom_validation(b): def test_zenroom_validation(b):
biolabs = generate_key_pair() biolabs = generate_key_pair()
version = "3.0" version = "3.0"

View File

@ -8,29 +8,23 @@ import json
import queue import queue
import threading import threading
import pytest import pytest
import random
import time
# from unittest.mock import patch # from unittest.mock import patch
from transactions.types.assets.create import Create from transactions.types.assets.create import Create
from transactions.types.assets.transfer import Transfer from transactions.types.assets.transfer import Transfer
from transactions.common import crypto from transactions.common import crypto
from planetmint.ipc import events from transactions.common.crypto import generate_key_pair
# from planetmint import processes
from planetmint.ipc import events # , POISON_PILL
from planetmint.web.websocket_server import init_app, EVENTS_ENDPOINT, EVENTS_ENDPOINT_BLOCKS from planetmint.web.websocket_server import init_app, EVENTS_ENDPOINT, EVENTS_ENDPOINT_BLOCKS
from ipld import multihash, marshal from ipld import multihash, marshal
from planetmint.web.websocket_dispatcher import Dispatcher from planetmint.web.websocket_dispatcher import Dispatcher
class MockWebSocket:
def __init__(self):
self.received = []
def send_str(self, s):
self.received.append(s)
def test_eventify_block_works_with_any_transaction(): def test_eventify_block_works_with_any_transaction():
from planetmint.web.websocket_dispatcher import Dispatcher
from transactions.common.crypto import generate_key_pair
alice = generate_key_pair() alice = generate_key_pair()
tx = Create.generate([alice.public_key], [([alice.public_key], 1)]).sign([alice.private_key]) tx = Create.generate([alice.public_key], [([alice.public_key], 1)]).sign([alice.private_key])
@ -50,9 +44,6 @@ def test_eventify_block_works_with_any_transaction():
def test_simplified_block_works(): def test_simplified_block_works():
from planetmint.web.websocket_dispatcher import Dispatcher
from transactions.common.crypto import generate_key_pair
alice = generate_key_pair() alice = generate_key_pair()
tx = Create.generate([alice.public_key], [([alice.public_key], 1)]).sign([alice.private_key]) tx = Create.generate([alice.public_key], [([alice.public_key], 1)]).sign([alice.private_key])
@ -112,12 +103,12 @@ async def test_websocket_transaction_event(aiohttp_client):
tx = Create.generate([user_pub], [([user_pub], 1)]) tx = Create.generate([user_pub], [([user_pub], 1)])
tx = tx.sign([user_priv]) tx = tx.sign([user_priv])
app = init_app(None) myapp = init_app(None)
client = await aiohttp_client(app) client = await aiohttp_client(myapp)
ws = await client.ws_connect(EVENTS_ENDPOINT) ws = await client.ws_connect(EVENTS_ENDPOINT)
block = {"height": 1, "transactions": [tx]} block = {"height": 1, "transactions": [tx]}
blk_source = Dispatcher.get_queue_on_demand(app, "blk_source") blk_source = Dispatcher.get_queue_on_demand(myapp, "blk_source")
tx_source = Dispatcher.get_queue_on_demand(app, "tx_source") tx_source = Dispatcher.get_queue_on_demand(myapp, "tx_source")
block_event = events.Event(events.EventTypes.BLOCK_VALID, block) block_event = events.Event(events.EventTypes.BLOCK_VALID, block)
await tx_source.put(block_event) await tx_source.put(block_event)
@ -136,15 +127,12 @@ async def test_websocket_transaction_event(aiohttp_client):
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_websocket_string_event(aiohttp_client): async def test_websocket_string_event(aiohttp_client):
from planetmint.ipc.events import POISON_PILL myapp = init_app(None)
from planetmint.web.websocket_server import init_app, EVENTS_ENDPOINT client = await aiohttp_client(myapp)
app = init_app(None)
client = await aiohttp_client(app)
ws = await client.ws_connect(EVENTS_ENDPOINT) ws = await client.ws_connect(EVENTS_ENDPOINT)
blk_source = Dispatcher.get_queue_on_demand(app, "blk_source") blk_source = Dispatcher.get_queue_on_demand(myapp, "blk_source")
tx_source = Dispatcher.get_queue_on_demand(app, "tx_source") tx_source = Dispatcher.get_queue_on_demand(myapp, "tx_source")
await tx_source.put("hack") await tx_source.put("hack")
await tx_source.put("the") await tx_source.put("the")
@ -164,7 +152,7 @@ async def test_websocket_string_event(aiohttp_client):
@pytest.mark.skip("Processes are not stopping properly, and the whole test suite would hang") @pytest.mark.skip("Processes are not stopping properly, and the whole test suite would hang")
def test_integration_from_webapi_to_websocket(monkeypatch, client, loop): def test_integration_from_webapi_to_websocket(monkeypatchonkeypatch, client, loop):
# XXX: I think that the `pytest-aiohttp` plugin is sparkling too much # XXX: I think that the `pytest-aiohttp` plugin is sparkling too much
# magic in the `asyncio` module: running this test without monkey-patching # magic in the `asyncio` module: running this test without monkey-patching
# `asycio.get_event_loop` (and without the `loop` fixture) raises a: # `asycio.get_event_loop` (and without the `loop` fixture) raises a:
@ -174,21 +162,13 @@ def test_integration_from_webapi_to_websocket(monkeypatch, client, loop):
# plugin explicitely. # plugin explicitely.
monkeypatch.setattr("asyncio.get_event_loop", lambda: loop) monkeypatch.setattr("asyncio.get_event_loop", lambda: loop)
import json
import random
import aiohttp
# TODO processes does not exist anymore, when reactivating this test it # TODO processes does not exist anymore, when reactivating this test it
# will fail because of this # will fail because of this
from planetmint import processes
# Start Planetmint # Start Planetmint
processes.start() processes.start()
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
import time
time.sleep(1) time.sleep(1)
ws_url = client.get("http://localhost:9984/api/v1/").json["_links"]["streams_v1"] ws_url = client.get("http://localhost:9984/api/v1/").json["_links"]["streams_v1"]