split integration tests into three jobs
This commit is contained in:
parent
8327585b3b
commit
c9f27b83e1
26 changed files with 23 additions and 119 deletions
|
@ -37,11 +37,23 @@ test:unit:
|
||||||
- make install tools
|
- make install tools
|
||||||
- HOME=/tmp coverage run -p --source=lbry -m unittest discover -vv tests.unit
|
- HOME=/tmp coverage run -p --source=lbry -m unittest discover -vv tests.unit
|
||||||
|
|
||||||
test:integration:
|
test:integration-datanetwork:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- pip install coverage tox-travis
|
- pip install coverage tox-travis
|
||||||
- tox
|
- tox -e datanetwork
|
||||||
|
|
||||||
|
test:integration-blockchain:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- pip install coverage tox-travis
|
||||||
|
- tox -e blockchain
|
||||||
|
|
||||||
|
test:integration-other:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- pip install coverage tox-travis
|
||||||
|
- tox -e other
|
||||||
|
|
||||||
test:json-api:
|
test:json-api:
|
||||||
stage: test
|
stage: test
|
||||||
|
|
|
@ -88,9 +88,6 @@ To install on Windows:
|
||||||
> lbry-venv\Scripts\activate
|
> lbry-venv\Scripts\activate
|
||||||
|
|
||||||
Install packages:
|
Install packages:
|
||||||
> cd torba
|
|
||||||
> pip install -e .
|
|
||||||
> cd ../lbry
|
|
||||||
> pip install -e .
|
> pip install -e .
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -99,7 +96,7 @@ To install on Windows:
|
||||||
To run the unit tests from the repo directory:
|
To run the unit tests from the repo directory:
|
||||||
|
|
||||||
```
|
```
|
||||||
python -m unittest discover -s lbry tests.unit
|
python -m unittest discover tests.unit
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
include README.md
|
include README.md
|
||||||
include CHANGELOG.md
|
include CHANGELOG.md
|
||||||
include LICENSE
|
include LICENSE
|
||||||
recursive-include torba *.txt *.py
|
recursive-include lbry *.txt *.py
|
||||||
|
|
|
@ -2,7 +2,7 @@ import time
|
||||||
import asyncio
|
import asyncio
|
||||||
import random
|
import random
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from torba.client.basenetwork import ClientSession
|
from lbry.wallet.client.basenetwork import ClientSession
|
||||||
|
|
||||||
|
|
||||||
class AgentSmith(ClientSession):
|
class AgentSmith(ClientSession):
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
from torba.client.basenetwork import ClientSession
|
from lbry.wallet.client.basenetwork import ClientSession
|
||||||
from torba.rpc.jsonrpc import RPCError
|
from lbry.wallet.rpc.jsonrpc import RPCError
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
logging.getLogger('torba').setLevel(logging.CRITICAL)
|
logging.getLogger('lbry.wallet').setLevel(logging.CRITICAL)
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
|
|
|
@ -1,103 +0,0 @@
|
||||||
import asyncio
|
|
||||||
import logging
|
|
||||||
from lbry.testcase import IntegrationTestCase, WalletNode
|
|
||||||
from lbry.constants import CENT
|
|
||||||
|
|
||||||
|
|
||||||
class SyncTests(IntegrationTestCase):
|
|
||||||
|
|
||||||
VERBOSITY = logging.WARN
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
self.api_port = 5280
|
|
||||||
self.started_nodes = []
|
|
||||||
|
|
||||||
async def asyncTearDown(self):
|
|
||||||
for node in self.started_nodes:
|
|
||||||
try:
|
|
||||||
await node.stop(cleanup=True)
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
await super().asyncTearDown()
|
|
||||||
|
|
||||||
async def make_wallet_node(self, seed=None):
|
|
||||||
self.api_port += 1
|
|
||||||
wallet_node = WalletNode(
|
|
||||||
self.wallet_node.manager_class,
|
|
||||||
self.wallet_node.ledger_class,
|
|
||||||
port=self.api_port
|
|
||||||
)
|
|
||||||
await wallet_node.start(self.conductor.spv_node, seed)
|
|
||||||
self.started_nodes.append(wallet_node)
|
|
||||||
return wallet_node
|
|
||||||
|
|
||||||
async def test_nodes_with_same_account_stay_in_sync(self):
|
|
||||||
# destination node/account for receiving TXs
|
|
||||||
node0 = await self.make_wallet_node()
|
|
||||||
account0 = node0.account
|
|
||||||
# main node/account creating TXs
|
|
||||||
node1 = self.wallet_node
|
|
||||||
account1 = self.wallet_node.account
|
|
||||||
# mirror node/account, expected to reflect everything in main node as it happens
|
|
||||||
node2 = await self.make_wallet_node(account1.seed)
|
|
||||||
account2 = node2.account
|
|
||||||
|
|
||||||
self.assertNotEqual(account0.id, account1.id)
|
|
||||||
self.assertEqual(account1.id, account2.id)
|
|
||||||
await self.assertBalance(account0, '0.0')
|
|
||||||
await self.assertBalance(account1, '0.0')
|
|
||||||
await self.assertBalance(account2, '0.0')
|
|
||||||
self.assertEqual(await account0.get_address_count(chain=0), 20)
|
|
||||||
self.assertEqual(await account1.get_address_count(chain=0), 20)
|
|
||||||
self.assertEqual(await account2.get_address_count(chain=0), 20)
|
|
||||||
self.assertEqual(await account1.get_address_count(chain=1), 6)
|
|
||||||
self.assertEqual(await account2.get_address_count(chain=1), 6)
|
|
||||||
|
|
||||||
# check that main node and mirror node generate 5 address to fill gap
|
|
||||||
fifth_address = (await account1.receiving.get_addresses())[4]
|
|
||||||
await self.blockchain.send_to_address(fifth_address, 1.00)
|
|
||||||
await asyncio.wait([
|
|
||||||
account1.ledger.on_address.first,
|
|
||||||
account2.ledger.on_address.first
|
|
||||||
])
|
|
||||||
self.assertEqual(await account1.get_address_count(chain=0), 25)
|
|
||||||
self.assertEqual(await account2.get_address_count(chain=0), 25)
|
|
||||||
await self.assertBalance(account1, '1.0')
|
|
||||||
await self.assertBalance(account2, '1.0')
|
|
||||||
|
|
||||||
await self.blockchain.generate(1)
|
|
||||||
|
|
||||||
# pay 0.01 from main node to receiving node, would have increased change addresses
|
|
||||||
address0 = (await account0.receiving.get_addresses())[0]
|
|
||||||
hash0 = self.ledger.address_to_hash160(address0)
|
|
||||||
tx = await account1.ledger.transaction_class.create(
|
|
||||||
[],
|
|
||||||
[self.ledger.transaction_class.output_class.pay_pubkey_hash(CENT, hash0)],
|
|
||||||
[account1], account1
|
|
||||||
)
|
|
||||||
await self.broadcast(tx)
|
|
||||||
await asyncio.wait([
|
|
||||||
account0.ledger.wait(tx),
|
|
||||||
account1.ledger.wait(tx),
|
|
||||||
account2.ledger.wait(tx),
|
|
||||||
])
|
|
||||||
await self.blockchain.generate(1)
|
|
||||||
await asyncio.wait([
|
|
||||||
account0.ledger.wait(tx),
|
|
||||||
account1.ledger.wait(tx),
|
|
||||||
account2.ledger.wait(tx),
|
|
||||||
])
|
|
||||||
self.assertEqual(await account0.get_address_count(chain=0), 21)
|
|
||||||
self.assertGreater(await account1.get_address_count(chain=1), 6)
|
|
||||||
self.assertGreater(await account2.get_address_count(chain=1), 6)
|
|
||||||
await self.assertBalance(account0, '0.01')
|
|
||||||
await self.assertBalance(account1, '0.989876')
|
|
||||||
await self.assertBalance(account2, '0.989876')
|
|
||||||
|
|
||||||
await self.blockchain.generate(1)
|
|
||||||
|
|
||||||
# create a new mirror node and see if it syncs to same balance from scratch
|
|
||||||
node3 = await self.make_wallet_node(account1.seed)
|
|
||||||
account3 = node3.account
|
|
||||||
await self.assertBalance(account3, '0.989876')
|
|
8
tox.ini
8
tox.ini
|
@ -1,6 +1,3 @@
|
||||||
[tox]
|
|
||||||
envlist = py37-integration
|
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps =
|
deps =
|
||||||
coverage
|
coverage
|
||||||
|
@ -9,11 +6,12 @@ extras = test
|
||||||
changedir = {toxinidir}/tests
|
changedir = {toxinidir}/tests
|
||||||
setenv =
|
setenv =
|
||||||
HOME=/tmp
|
HOME=/tmp
|
||||||
TORBA_LEDGER=lbry.wallet
|
|
||||||
commands =
|
commands =
|
||||||
pip install https://github.com/rogerbinns/apsw/releases/download/3.30.1-r1/apsw-3.30.1-r1.zip \
|
pip install https://github.com/rogerbinns/apsw/releases/download/3.30.1-r1/apsw-3.30.1-r1.zip \
|
||||||
--global-option=fetch \
|
--global-option=fetch \
|
||||||
--global-option=--version --global-option=3.30.1 --global-option=--all \
|
--global-option=--version --global-option=3.30.1 --global-option=--all \
|
||||||
--global-option=build --global-option=--enable --global-option=fts5
|
--global-option=build --global-option=--enable --global-option=fts5
|
||||||
orchstr8 download
|
orchstr8 download
|
||||||
coverage run -p --source={envsitepackagesdir}/lbry -m unittest discover -vv integration {posargs}
|
blockchain: coverage run -p --source={envsitepackagesdir}/lbry -m unittest discover -vv integration.blockchain {posargs}
|
||||||
|
datanetwork: coverage run -p --source={envsitepackagesdir}/lbry -m unittest discover -vv integration.datanetwork {posargs}
|
||||||
|
other: coverage run -p --source={envsitepackagesdir}/lbry -m unittest discover -vv integration.other {posargs}
|
||||||
|
|
Loading…
Reference in a new issue