Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
drew2a committed Sep 27, 2021
1 parent 087019e commit 90fa5bc
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
from ipv8.peer import Peer
from ipv8.requestcache import RequestCache
from ipv8.types import Address

from tribler_core.modules.bandwidth_accounting import EMPTY_SIGNATURE
from tribler_core.components.bandwidth_accounting.community.cache import BandwidthTransactionSignCache
from tribler_core.components.bandwidth_accounting.db.database import BandwidthDatabase
from tribler_core.components.bandwidth_accounting.community.payload import (
BandwidthTransactionPayload,
BandwidthTransactionQueryPayload,
)
from tribler_core.components.bandwidth_accounting.db.transaction import BandwidthTransactionData
from tribler_core.components.bandwidth_accounting.db.database import BandwidthDatabase
from tribler_core.components.bandwidth_accounting.db.transaction import BandwidthTransactionData, EMPTY_SIGNATURE
from tribler_core.modules.tribler_community import TriblerCommunity
from tribler_core.utilities.unicode import hexlify

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

from pony.orm import PrimaryKey, Required, db_session

from tribler_core.modules.bandwidth_accounting import EMPTY_SIGNATURE
from tribler_core.components.bandwidth_accounting.community.payload import BandwidthTransactionPayload

EMPTY_SIGNATURE = b'0' * 64

@dataclass
class BandwidthTransactionData:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from unittest.mock import patch

from tribler_core.components.bandwidth_accounting.bandwidth_accounting_component import BandwidthAccountingComponent
from tribler_core.components.base import Session
from tribler_core.components.ipv8 import Ipv8Component
from tribler_core.components.masterkey import MasterKeyComponent
from tribler_core.components.restapi import RESTComponent
from tribler_core.restapi.rest_manager import RESTManager


async def test_bandwidth_accounting_component(tribler_config):
components = [RESTComponent(), MasterKeyComponent(), Ipv8Component(), BandwidthAccountingComponent()]
session = Session(tribler_config, components)
with session:
comp = BandwidthAccountingComponent.instance()
with patch.object(RESTManager, 'get_endpoint'):
await session.start()

assert comp.community
assert comp._rest_manager
assert comp._ipv8

await session.shutdown()
2 changes: 1 addition & 1 deletion src/tribler-core/tribler_core/components/payout.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from tribler_common.simpledefs import NTFY
from tribler_core.components.bandwidth_accounting.bandwidth_accounting_component import BandwidthAccountingComponent
from tribler_core.components.base import Component
from tribler_core.components.bandwidth_accounting.bandwidth_accounting import BandwidthAccountingComponent
from tribler_core.components.ipv8 import Ipv8Component
from tribler_core.components.reporter import ReporterComponent
from tribler_core.modules.payout.payout_manager import PayoutManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from tribler_core.components.bandwidth_accounting.bandwidth_accounting_component import BandwidthAccountingComponent
from tribler_core.components.base import Session, SessionError
from tribler_core.components.bandwidth_accounting.bandwidth_accounting import BandwidthAccountingComponent
from tribler_core.components.gigachannel import GigaChannelComponent
from tribler_core.components.gigachannel_manager import GigachannelManagerComponent
from tribler_core.components.ipv8 import Ipv8Component
Expand Down Expand Up @@ -62,19 +62,6 @@ async def test_masterkey_component(tribler_config):
await session.shutdown()


async def test_bandwidth_accounting_component(tribler_config):
components = [RESTComponent(), MasterKeyComponent(), Ipv8Component(), BandwidthAccountingComponent()]
session = Session(tribler_config, components)
with session:
comp = BandwidthAccountingComponent.instance()
with patch.object(RESTManager, 'get_endpoint'):
await session.start()

assert comp.community
assert comp._rest_manager
assert comp._ipv8

await session.shutdown()


async def test_giga_channel_component(tribler_config):
Expand Down
2 changes: 1 addition & 1 deletion src/tribler-core/tribler_core/components/tunnels.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from ipv8.messaging.anonymization.community import TunnelSettings
from ipv8.peerdiscovery.discovery import RandomWalk
from ipv8_service import IPv8
from tribler_core.components.bandwidth_accounting.bandwidth_accounting_component import BandwidthAccountingComponent
from tribler_core.components.base import Component
from tribler_core.components.bandwidth_accounting.bandwidth_accounting import BandwidthAccountingComponent
from tribler_core.components.ipv8 import Ipv8Component
from tribler_core.components.libtorrent import LibtorrentComponent
from tribler_core.components.reporter import ReporterComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

import pytest

from tribler_core.modules.bandwidth_accounting import EMPTY_SIGNATURE
from tribler_core.components.bandwidth_accounting.restapi.bandwidth_endpoint import BandwidthEndpoint
from tribler_core.components.bandwidth_accounting.community.community import BandwidthAccountingCommunity
from tribler_core.components.bandwidth_accounting.db.database import BandwidthDatabase
from tribler_core.components.bandwidth_accounting.settings import BandwidthAccountingSettings
from tribler_core.components.bandwidth_accounting.db.transaction import BandwidthTransactionData
from tribler_core.components.bandwidth_accounting.db.transaction import BandwidthTransactionData, EMPTY_SIGNATURE
from tribler_core.restapi.base_api_test import do_request
from tribler_core.utilities.unicode import hexlify

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
from ipv8.test.base import TestBase
from ipv8.test.mocking.ipv8 import MockIPv8

from tribler_core.modules.bandwidth_accounting import EMPTY_SIGNATURE
from tribler_core.components.bandwidth_accounting.community.cache import BandwidthTransactionSignCache
from tribler_core.components.bandwidth_accounting.community.community import BandwidthAccountingCommunity
from tribler_core.components.bandwidth_accounting.db.database import BandwidthDatabase
from tribler_core.components.bandwidth_accounting.settings import BandwidthAccountingSettings
from tribler_core.components.bandwidth_accounting.db.transaction import BandwidthTransactionData
from tribler_core.components.bandwidth_accounting.db.transaction import BandwidthTransactionData, EMPTY_SIGNATURE
from tribler_core.utilities.utilities import MEMORY_DB


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

import pytest

from tribler_core.modules.bandwidth_accounting import EMPTY_SIGNATURE
from tribler_core.components.bandwidth_accounting.db.database import BandwidthDatabase
from tribler_core.components.bandwidth_accounting.db.transaction import BandwidthTransactionData
from tribler_core.components.bandwidth_accounting.db.transaction import BandwidthTransactionData, EMPTY_SIGNATURE
from tribler_core.utilities.utilities import MEMORY_DB


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from ipv8.keyvault.crypto import default_eccrypto

from tribler_core.modules.bandwidth_accounting import EMPTY_SIGNATURE
from tribler_core.components.bandwidth_accounting.db.transaction import BandwidthTransactionData
from tribler_core.components.bandwidth_accounting.db.transaction import BandwidthTransactionData, EMPTY_SIGNATURE


def test_sign_transaction():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
import pytest

from tribler_core.exceptions import TrustGraphException
from tribler_core.modules.bandwidth_accounting import EMPTY_SIGNATURE
from tribler_core.components.bandwidth_accounting.db.database import BandwidthDatabase
from tribler_core.components.bandwidth_accounting.db.transaction import BandwidthTransactionData
from tribler_core.components.bandwidth_accounting.db.transaction import BandwidthTransactionData, EMPTY_SIGNATURE
from tribler_core.modules.trust_calculation.trust_graph import TrustGraph
from tribler_core.restapi.base_api_test import do_request
from tribler_core.restapi.rest_manager import error_middleware
Expand Down

0 comments on commit 90fa5bc

Please sign in to comment.