updating wallet tests
This commit is contained in:
parent
2668ceac0e
commit
a4e9f3100f
2 changed files with 18 additions and 39 deletions
|
@ -11,7 +11,7 @@ from lbryschema.decode import smart_decode
|
||||||
from lbrynet import conf
|
from lbrynet import conf
|
||||||
from lbrynet.cryptstream.CryptBlob import CryptBlobInfo
|
from lbrynet.cryptstream.CryptBlob import CryptBlobInfo
|
||||||
from lbrynet.dht.constants import dataExpireTimeout
|
from lbrynet.dht.constants import dataExpireTimeout
|
||||||
from lbrynet.wallet.database import SQLiteWalletStorage
|
from lbrynet.wallet.database import WalletDatabase
|
||||||
from torba.constants import COIN
|
from torba.constants import COIN
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -95,7 +95,7 @@ class SqliteConnection(adbapi.ConnectionPool):
|
||||||
cls.reactor = reactor
|
cls.reactor = reactor
|
||||||
|
|
||||||
|
|
||||||
class SQLiteStorage(SQLiteWalletStorage):
|
class SQLiteStorage(WalletDatabase):
|
||||||
|
|
||||||
CREATE_TABLES_QUERY = """
|
CREATE_TABLES_QUERY = """
|
||||||
pragma foreign_keys=on;
|
pragma foreign_keys=on;
|
||||||
|
@ -166,7 +166,7 @@ class SQLiteStorage(SQLiteWalletStorage):
|
||||||
timestamp integer,
|
timestamp integer,
|
||||||
primary key (sd_hash, reflector_address)
|
primary key (sd_hash, reflector_address)
|
||||||
);
|
);
|
||||||
""" + SQLiteWalletStorage.CREATE_TABLES_QUERY
|
""" + WalletDatabase.CREATE_TABLES_QUERY
|
||||||
|
|
||||||
def __init__(self, db_dir, reactor=None):
|
def __init__(self, db_dir, reactor=None):
|
||||||
if not reactor:
|
if not reactor:
|
||||||
|
|
|
@ -2,30 +2,8 @@ import asyncio
|
||||||
from binascii import hexlify, unhexlify
|
from binascii import hexlify, unhexlify
|
||||||
from orchstr8.testcase import IntegrationTestCase
|
from orchstr8.testcase import IntegrationTestCase
|
||||||
from lbryschema.claim import ClaimDict
|
from lbryschema.claim import ClaimDict
|
||||||
|
from torba.constants import COIN
|
||||||
|
from lbrynet.wallet.manager import LbryWalletManager
|
||||||
class BasicTransactionTests(IntegrationTestCase):
|
|
||||||
|
|
||||||
VERBOSE = True
|
|
||||||
|
|
||||||
async def test_sending_and_recieving(self):
|
|
||||||
|
|
||||||
self.assertEqual(await self.get_balance(), 0.0)
|
|
||||||
|
|
||||||
address = self.account.get_least_used_receiving_address()
|
|
||||||
sendtxid = await self.blockchain.send_to_address(address.decode(), 5.5)
|
|
||||||
await self.blockchain.generate(1)
|
|
||||||
await self.on_transaction(sendtxid)
|
|
||||||
|
|
||||||
self.assertAlmostEqual(await self.get_balance(), 5.5, places=2)
|
|
||||||
|
|
||||||
lbrycrd_address = await self.blockchain.get_raw_change_address()
|
|
||||||
tx = self.manager.send_amount_to_address(5, lbrycrd_address)
|
|
||||||
await self.broadcast(tx)
|
|
||||||
await self.on_transaction(tx.id.decode())
|
|
||||||
await self.blockchain.generate(1)
|
|
||||||
|
|
||||||
self.assertAlmostEqual(await self.get_balance(), 0.5, places=2)
|
|
||||||
|
|
||||||
|
|
||||||
example_claim_dict = {
|
example_claim_dict = {
|
||||||
|
@ -58,28 +36,29 @@ example_claim_dict = {
|
||||||
class ClaimTransactionTests(IntegrationTestCase):
|
class ClaimTransactionTests(IntegrationTestCase):
|
||||||
|
|
||||||
VERBOSE = True
|
VERBOSE = True
|
||||||
|
WALLET_MANAGER = LbryWalletManager
|
||||||
|
|
||||||
async def test_creating_updating_and_abandoning_claim(self):
|
async def test_creating_updating_and_abandoning_claim(self):
|
||||||
|
|
||||||
address = self.account.get_least_used_receiving_address()
|
await self.account.ensure_address_gap().asFuture(asyncio.get_event_loop())
|
||||||
sendtxid = await self.lbrycrd.send_to_address(address.decode(), 9.0)
|
|
||||||
await self.lbrycrd.generate(1)
|
|
||||||
await self.on_transaction(sendtxid)
|
|
||||||
|
|
||||||
self.assertAlmostEqual(self.manager.get_balance(), 9, places=2)
|
address = await self.account.receiving.get_or_create_usable_address().asFuture(asyncio.get_event_loop())
|
||||||
|
sendtxid = await self.blockchain.send_to_address(address.decode(), 10)
|
||||||
|
await self.on_transaction(sendtxid) #mempool
|
||||||
|
await self.blockchain.generate(1)
|
||||||
|
await self.on_transaction(sendtxid) #confirmed
|
||||||
|
|
||||||
|
self.assertEqual(round(await self.get_balance(self.account)/COIN, 1), 10.0)
|
||||||
|
|
||||||
claim = ClaimDict.load_dict(example_claim_dict)
|
claim = ClaimDict.load_dict(example_claim_dict)
|
||||||
tx = self.manager.claim_name(b'foo', 5, hexlify(claim.serialized))
|
tx = self.manager.claim_name(b'foo', 1*COIN, hexlify(claim.serialized))
|
||||||
await self.broadcast(tx)
|
await self.broadcast(tx)
|
||||||
await self.on_transaction(tx.id.decode())
|
await self.on_transaction(tx.hex_id.decode()) #mempool
|
||||||
await self.lbrycrd.generate(1)
|
await self.blockchain.generate(1)
|
||||||
|
await self.on_transaction(tx.hex_id.decode()) #confirmed
|
||||||
await asyncio.sleep(2)
|
|
||||||
|
|
||||||
self.assertAlmostEqual(self.manager.get_balance(), 9, places=2)
|
self.assertAlmostEqual(self.manager.get_balance(), 9, places=2)
|
||||||
|
|
||||||
await asyncio.sleep(2)
|
|
||||||
|
|
||||||
response = await self.resolve('lbry://foo')
|
response = await self.resolve('lbry://foo')
|
||||||
print(response)
|
print(response)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue