Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

Commit

Permalink
Renamed test_basic_e2e to test_client_e2e; added skeleton of cli e2e …
Browse files Browse the repository at this point in the history
…tests; restructured teosd setup fixtures to be reusable
  • Loading branch information
bigspider committed Oct 26, 2020
1 parent fbcfc57 commit e366ea4
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 71 deletions.
4 changes: 2 additions & 2 deletions teos/cli/rpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class RPCClient:
Errors from the grpc calls are not handled.
Args:
rpc_host (:obj:`str`): the IP or host where the RPC server will be hosted.
rpc_port (:obj:`int`): the port where the RPC server will be hosted.
rpc_host (:obj:`str`): the IP or host where the RPC server is hosted.
rpc_port (:obj:`int`): the port where the RPC server is hosted.
Attributes:
stub: The rpc client stub.
Expand Down
13 changes: 11 additions & 2 deletions test/teos/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,30 @@ def prng_seed():
random.seed(0)


@pytest.fixture(scope="session")
@pytest.fixture(scope="module")
def run_bitcoind(dirname=".test_bitcoin"):
global btc_addr, utxos
# Run bitcoind in a separate folder
makedirs(dirname, exist_ok=True)

bitcoind = os.getenv("BITCOIND", "bitcoind")

copy(os.path.join(os.path.dirname(__file__), "bitcoin.conf"), dirname)
subprocess.Popen([bitcoind, f"--datadir={dirname}"])

bitcoind_popen = subprocess.Popen([bitcoind, f"--datadir={dirname}"])

# Generate some initial blocks
setup_node()
yield

bitcoin_cli.stop()
bitcoind_popen.wait()
sleep(1)

# cleanup global variables in case we do another run later
btc_addr = None
utxos = list()

rmtree(dirname)


Expand Down
4 changes: 2 additions & 2 deletions test/teos/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@


# This fixture needs to be manually run on the first E2E.
@pytest.fixture(scope="session")
def teosd():
@pytest.fixture(scope="module")
def teosd(run_bitcoind):
teosd_process, teos_id = run_teosd()

yield teosd_process, teos_id
Expand Down
11 changes: 11 additions & 0 deletions test/teos/e2e/test_cli_e2e.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest

from contrib.client import teos_client

from teos.cli.teos_cli import CLI
from teos.cli.rpc_client import RPCClient


def test_start_teosd(teosd):
# All commands should fail if the user is not registered
teosd_process, teos_id = teosd
Loading

0 comments on commit e366ea4

Please sign in to comment.