mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Use factories and fixtures in pubsub tests
Done - Add factories using factory-boy - Modify fixtures and tests to use factories - Modify tests to use fixtures and factories - Clean up
This commit is contained in:
@ -2,13 +2,8 @@ import functools
|
||||
|
||||
import pytest
|
||||
|
||||
from libp2p import new_node
|
||||
from libp2p.pubsub.gossipsub import GossipSub
|
||||
from libp2p.pubsub.pubsub import Pubsub
|
||||
|
||||
from tests.utils import cleanup
|
||||
|
||||
from .configs import FLOODSUB_PROTOCOL_ID, LISTEN_MADDR
|
||||
from .configs import FLOODSUB_PROTOCOL_ID
|
||||
from .factories import GossipsubFactory
|
||||
from .floodsub_integration_test_settings import (
|
||||
perform_test_from_obj,
|
||||
floodsub_protocol_pytest_params,
|
||||
@ -18,17 +13,7 @@ from .floodsub_integration_test_settings import (
|
||||
# pylint: disable=too-many-locals
|
||||
@pytest.mark.asyncio
|
||||
async def test_gossipsub_initialize_with_floodsub_protocol():
|
||||
node = await new_node(transport_opt=[str(LISTEN_MADDR)])
|
||||
|
||||
await node.get_network().listen(LISTEN_MADDR)
|
||||
|
||||
gossipsub = GossipSub([FLOODSUB_PROTOCOL_ID], 3, 2, 4, 30)
|
||||
pubsub = Pubsub(node, gossipsub, "a")
|
||||
|
||||
# Did it work?
|
||||
assert gossipsub and pubsub
|
||||
|
||||
await cleanup()
|
||||
GossipsubFactory(protocols=[FLOODSUB_PROTOCOL_ID])
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_case_obj", floodsub_protocol_pytest_params)
|
||||
@ -37,6 +22,6 @@ async def test_gossipsub_run_with_floodsub_tests(test_case_obj):
|
||||
await perform_test_from_obj(
|
||||
test_case_obj,
|
||||
functools.partial(
|
||||
GossipSub, degree=3, degree_low=2, degree_high=4, time_to_live=30
|
||||
GossipsubFactory, degree=3, degree_low=2, degree_high=4, time_to_live=30
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user