tests(server): test storing (#64)
This commit is contained in:
parent
483ff455e7
commit
4cd8488ed7
@ -4,3 +4,4 @@ sphinx>=1.6.5
|
||||
sphinxcontrib-napoleon>=0.6.1
|
||||
sphinxcontrib-zopeext>=0.2.1
|
||||
pytest>=4.1.0
|
||||
pytest-asyncio>=0.10.0
|
||||
|
14
kademlia/tests/conftest.py
Normal file
14
kademlia/tests/conftest.py
Normal file
@ -0,0 +1,14 @@
|
||||
import pytest
|
||||
|
||||
from kademlia.network import Server
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
def bootstrap_node(event_loop):
|
||||
server = Server()
|
||||
event_loop.run_until_complete(server.listen(8468))
|
||||
|
||||
try:
|
||||
yield ('127.0.0.1', 8468)
|
||||
finally:
|
||||
server.stop()
|
@ -1,10 +1,25 @@
|
||||
import unittest
|
||||
import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from kademlia.network import Server
|
||||
from kademlia.protocol import KademliaProtocol
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_storing(bootstrap_node):
|
||||
server = Server()
|
||||
await server.listen(bootstrap_node[1] + 1)
|
||||
await server.bootstrap([bootstrap_node])
|
||||
await server.set('key', 'value')
|
||||
result = await server.get('key')
|
||||
|
||||
assert result == 'value'
|
||||
|
||||
server.stop()
|
||||
|
||||
|
||||
class SwappableProtocolTests(unittest.TestCase):
|
||||
|
||||
def test_default_protocol(self):
|
||||
|
Loading…
Reference in New Issue
Block a user