Spec out first steps, nothing works yet
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
18fae5a233
commit
1c67ca74e4
5
NOTES.md
Normal file
5
NOTES.md
Normal file
@ -0,0 +1,5 @@
|
||||
# HOWTO port
|
||||
|
||||
- its a sans-io module, no IO included
|
||||
- its got a callback API recv -> onmessage which Id like to replace
|
||||
- plan is then maybe to use a async with API for this handling
|
@ -2,7 +2,7 @@
|
||||
|
||||
[![Build Status](https://drone.autonomic.zone/api/badges/hyperpy/simple-message-channels/status.svg)](https://drone.autonomic.zone/hyperpy/simple-message-channels)
|
||||
|
||||
## Wire protocol for Hypercore
|
||||
## Sans I/O wire protocol for Hypercore
|
||||
|
||||
```sh
|
||||
$ pip install simple-message-channels
|
||||
|
@ -21,7 +21,7 @@ maintainer_email = hi@decentral1.se
|
||||
url = https://git.autonomic.zone/hyperpy/simple-message-channels
|
||||
project_urls =
|
||||
Source Code = https://git.autonomic.zone/hyperpy/simple-message-channels
|
||||
description = Low level wire protocol for Hypercore
|
||||
description = Sans I/O wire protocol for Hypercore
|
||||
long_description = file: README.md
|
||||
license = GPLv3
|
||||
license_file = LICENSE
|
||||
|
@ -1,5 +1,7 @@
|
||||
"""simple-message-channels module."""
|
||||
|
||||
from simple_message_channels.smc import SimpleMessageChannel # noqa
|
||||
|
||||
try:
|
||||
import pkg_resources
|
||||
except ImportError:
|
||||
@ -7,6 +9,6 @@ except ImportError:
|
||||
|
||||
|
||||
try:
|
||||
__version__ = pkg_resources.get_distribution('simple-message-channels').version
|
||||
__version__ = pkg_resources.get_distribution('simple_message_channels').version
|
||||
except Exception:
|
||||
__version__ = 'unknown'
|
||||
|
12
simple_message_channels/smc.py
Normal file
12
simple_message_channels/smc.py
Normal file
@ -0,0 +1,12 @@
|
||||
"""Sans I/O wire protocol for Hypercore"""
|
||||
|
||||
__all__ = ["SimpleMessageChannel"]
|
||||
|
||||
|
||||
class SimpleMessageChannel:
|
||||
"""A simple message channel."""
|
||||
|
||||
async def send(self, channel: int, type: int, message: bytes) -> bytes:
|
||||
pass
|
||||
|
||||
# TODO(decentral1se): spec out the context manager API of recv
|
8
test/conftest.py
Normal file
8
test/conftest.py
Normal file
@ -0,0 +1,8 @@
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def smc():
|
||||
from simple_message_channels import SimpleMessageChannel
|
||||
|
||||
return SimpleMessageChannel()
|
10
test/test_smc.py
Normal file
10
test/test_smc.py
Normal file
@ -0,0 +1,10 @@
|
||||
async def test_send_recv(smc):
|
||||
channel, type, message = 0, 0, b"abc"
|
||||
|
||||
payload = await smc.send(channel, type, message)
|
||||
assert isinstance(payload, bytes)
|
||||
|
||||
async with smc.recv(payload) as response:
|
||||
assert response.channel == channel
|
||||
assert response.type == type
|
||||
assert response.message == message
|
Loading…
Reference in New Issue
Block a user