forked from LBRYCommunity/lbry-sdk
wallet integration tests fixed
This commit is contained in:
parent
d6d69a46d4
commit
4a8776be10
3 changed files with 32 additions and 29 deletions
|
@ -1897,16 +1897,12 @@ class Daemon(AuthJSONRPCServer):
|
||||||
raise Exception('Must specify nout')
|
raise Exception('Must specify nout')
|
||||||
|
|
||||||
tx = yield self.wallet.abandon_claim(claim_id, txid, nout)
|
tx = yield self.wallet.abandon_claim(claim_id, txid, nout)
|
||||||
result = {
|
|
||||||
"success": True,
|
|
||||||
"txid": tx.id,
|
|
||||||
"nout": 0,
|
|
||||||
"tx": hexlify(tx.raw),
|
|
||||||
"fee": str(Decimal(tx.fee) / COIN),
|
|
||||||
"claim_id": claim_id
|
|
||||||
}
|
|
||||||
self.analytics_manager.send_claim_action('abandon')
|
self.analytics_manager.send_claim_action('abandon')
|
||||||
defer.returnValue(result)
|
defer.returnValue({
|
||||||
|
"success": True,
|
||||||
|
"tx": tx,
|
||||||
|
"claim_id": claim_id
|
||||||
|
})
|
||||||
|
|
||||||
@requires(WALLET_COMPONENT, conditions=[WALLET_IS_UNLOCKED])
|
@requires(WALLET_COMPONENT, conditions=[WALLET_IS_UNLOCKED])
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
|
|
@ -256,8 +256,9 @@ class AuthJSONRPCServer(AuthorizedBase):
|
||||||
if self.listening_port:
|
if self.listening_port:
|
||||||
self.listening_port.stopListening()
|
self.listening_port.stopListening()
|
||||||
self.looping_call_manager.shutdown()
|
self.looping_call_manager.shutdown()
|
||||||
for session in list(self.server.sessions.values()):
|
if self.server is not None:
|
||||||
session.expire()
|
for session in list(self.server.sessions.values()):
|
||||||
|
session.expire()
|
||||||
if self.analytics_manager:
|
if self.analytics_manager:
|
||||||
self.analytics_manager.shutdown()
|
self.analytics_manager.shutdown()
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
import json
|
||||||
import tempfile
|
import tempfile
|
||||||
import logging
|
import logging
|
||||||
import asyncio
|
import asyncio
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
|
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
from orchstr8.testcase import IntegrationTestCase, d2f
|
from orchstr8.testcase import IntegrationTestCase, d2f
|
||||||
|
|
||||||
|
@ -16,10 +16,10 @@ from lbrynet.daemon.Daemon import Daemon
|
||||||
from lbrynet.wallet.manager import LbryWalletManager
|
from lbrynet.wallet.manager import LbryWalletManager
|
||||||
from lbrynet.daemon.Components import WalletComponent, DHTComponent, HashAnnouncerComponent, ExchangeRateManagerComponent
|
from lbrynet.daemon.Components import WalletComponent, DHTComponent, HashAnnouncerComponent, ExchangeRateManagerComponent
|
||||||
from lbrynet.daemon.Components import UPnPComponent
|
from lbrynet.daemon.Components import UPnPComponent
|
||||||
from lbrynet.daemon.Components import REFLECTOR_COMPONENT, HASH_ANNOUNCER_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT
|
from lbrynet.daemon.Components import REFLECTOR_COMPONENT
|
||||||
from lbrynet.daemon.Components import UPNP_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT, DHT_COMPONENT
|
from lbrynet.daemon.Components import PEER_PROTOCOL_SERVER_COMPONENT
|
||||||
from lbrynet.daemon.Components import STREAM_IDENTIFIER_COMPONENT, HEADERS_COMPONENT, RATE_LIMITER_COMPONENT
|
|
||||||
from lbrynet.daemon.ComponentManager import ComponentManager
|
from lbrynet.daemon.ComponentManager import ComponentManager
|
||||||
|
from lbrynet.daemon.auth.server import jsonrpc_dumps_pretty
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -156,6 +156,12 @@ class CommandTestCase(IntegrationTestCase):
|
||||||
def d_generate(self, blocks):
|
def d_generate(self, blocks):
|
||||||
return defer.Deferred.fromFuture(asyncio.ensure_future(self.generate(blocks)))
|
return defer.Deferred.fromFuture(asyncio.ensure_future(self.generate(blocks)))
|
||||||
|
|
||||||
|
def out(self, d):
|
||||||
|
""" Converts Daemon API call results (dictionary)
|
||||||
|
to JSON and then back to a dictionary. """
|
||||||
|
d.addCallback(lambda o: json.loads(jsonrpc_dumps_pretty(o, ledger=self.ledger))['result'])
|
||||||
|
return d
|
||||||
|
|
||||||
|
|
||||||
class EpicAdventuresOfChris45(CommandTestCase):
|
class EpicAdventuresOfChris45(CommandTestCase):
|
||||||
|
|
||||||
|
@ -177,12 +183,12 @@ class EpicAdventuresOfChris45(CommandTestCase):
|
||||||
# While making the spamdwich he wonders... has anyone on LBRY
|
# While making the spamdwich he wonders... has anyone on LBRY
|
||||||
# registered the @spam channel yet? "I should do that!" he
|
# registered the @spam channel yet? "I should do that!" he
|
||||||
# exclaims and goes back to his computer to do just that!
|
# exclaims and goes back to his computer to do just that!
|
||||||
channel = yield self.daemon.jsonrpc_channel_new('@spam', 1)
|
channel = yield self.out(self.daemon.jsonrpc_channel_new('@spam', 1))
|
||||||
self.assertTrue(channel['success'])
|
self.assertTrue(channel['success'])
|
||||||
yield self.d_confirm_tx(channel['txid'])
|
yield self.d_confirm_tx(channel['tx']['txid'])
|
||||||
|
|
||||||
# Do we have it locally?
|
# Do we have it locally?
|
||||||
channels = yield self.daemon.jsonrpc_channel_list()
|
channels = yield self.out(self.daemon.jsonrpc_channel_list())
|
||||||
self.assertEqual(len(channels), 1)
|
self.assertEqual(len(channels), 1)
|
||||||
self.assertEqual(channels[0]['name'], '@spam')
|
self.assertEqual(channels[0]['name'], '@spam')
|
||||||
self.assertTrue(channels[0]['have_certificate'])
|
self.assertTrue(channels[0]['have_certificate'])
|
||||||
|
@ -228,7 +234,7 @@ class EpicAdventuresOfChris45(CommandTestCase):
|
||||||
# at 6 confirmations and the total is correct.
|
# at 6 confirmations and the total is correct.
|
||||||
|
|
||||||
# And is the channel resolvable and empty?
|
# And is the channel resolvable and empty?
|
||||||
response = yield self.daemon.jsonrpc_resolve(uri='lbry://@spam')
|
response = yield self.out(self.daemon.jsonrpc_resolve(uri='lbry://@spam'))
|
||||||
self.assertIn('lbry://@spam', response)
|
self.assertIn('lbry://@spam', response)
|
||||||
self.assertIn('certificate', response['lbry://@spam'])
|
self.assertIn('certificate', response['lbry://@spam'])
|
||||||
|
|
||||||
|
@ -245,11 +251,11 @@ class EpicAdventuresOfChris45(CommandTestCase):
|
||||||
file.write(b'yada yada yada!')
|
file.write(b'yada yada yada!')
|
||||||
file.write(b'the end')
|
file.write(b'the end')
|
||||||
file.flush()
|
file.flush()
|
||||||
claim1 = yield self.daemon.jsonrpc_publish(
|
claim1 = yield self.out(self.daemon.jsonrpc_publish(
|
||||||
'hovercraft', 1, file_path=file.name, channel_name='@spam', channel_id=channel['claim_id']
|
'hovercraft', 1, file_path=file.name, channel_name='@spam', channel_id=channel['claim_id']
|
||||||
)
|
))
|
||||||
self.assertTrue(claim1['success'])
|
self.assertTrue(claim1['success'])
|
||||||
yield self.d_confirm_tx(claim1['txid'])
|
yield self.d_confirm_tx(claim1['tx']['txid'])
|
||||||
|
|
||||||
# He quickly checks the unconfirmed balance to make sure everything looks
|
# He quickly checks the unconfirmed balance to make sure everything looks
|
||||||
# correct.
|
# correct.
|
||||||
|
@ -258,7 +264,7 @@ class EpicAdventuresOfChris45(CommandTestCase):
|
||||||
|
|
||||||
# Also checks that his new story can be found on the blockchain before
|
# Also checks that his new story can be found on the blockchain before
|
||||||
# giving the link to all his friends.
|
# giving the link to all his friends.
|
||||||
response = yield self.daemon.jsonrpc_resolve(uri='lbry://@spam/hovercraft')
|
response = yield self.out(self.daemon.jsonrpc_resolve(uri='lbry://@spam/hovercraft'))
|
||||||
self.assertIn('lbry://@spam/hovercraft', response)
|
self.assertIn('lbry://@spam/hovercraft', response)
|
||||||
self.assertIn('claim', response['lbry://@spam/hovercraft'])
|
self.assertIn('claim', response['lbry://@spam/hovercraft'])
|
||||||
|
|
||||||
|
@ -276,19 +282,19 @@ class EpicAdventuresOfChris45(CommandTestCase):
|
||||||
file.write(b'[typo fixing sounds being made]')
|
file.write(b'[typo fixing sounds being made]')
|
||||||
file.write(b'yada yada yada!')
|
file.write(b'yada yada yada!')
|
||||||
file.flush()
|
file.flush()
|
||||||
claim2 = yield self.daemon.jsonrpc_publish(
|
claim2 = yield self.out(self.daemon.jsonrpc_publish(
|
||||||
'hovercraft', 1, file_path=file.name, channel_name='@spam', channel_id=channel['claim_id']
|
'hovercraft', 1, file_path=file.name, channel_name='@spam', channel_id=channel['claim_id']
|
||||||
)
|
))
|
||||||
self.assertTrue(claim2['success'])
|
self.assertTrue(claim2['success'])
|
||||||
self.assertEqual(claim2['claim_id'], claim1['claim_id'])
|
self.assertEqual(claim2['claim_id'], claim1['claim_id'])
|
||||||
yield self.d_confirm_tx(claim2['txid'])
|
yield self.d_confirm_tx(claim2['tx']['txid'])
|
||||||
|
|
||||||
# After some soul searching Chris decides that his story needs more
|
# After some soul searching Chris decides that his story needs more
|
||||||
# heart and a better ending. He takes down the story and begins the rewrite.
|
# heart and a better ending. He takes down the story and begins the rewrite.
|
||||||
abandon = yield self.daemon.jsonrpc_claim_abandon(claim1['claim_id'])
|
abandon = yield self.out(self.daemon.jsonrpc_claim_abandon(claim1['claim_id']))
|
||||||
self.assertTrue(abandon['success'])
|
self.assertTrue(abandon['success'])
|
||||||
yield self.d_confirm_tx(abandon['txid'])
|
yield self.d_confirm_tx(abandon['tx']['txid'])
|
||||||
|
|
||||||
# And now check that the claim doesn't resolve anymore.
|
# And now check that the claim doesn't resolve anymore.
|
||||||
response = yield self.daemon.jsonrpc_resolve(uri='lbry://@spam/hovercraft')
|
response = yield self.out(self.daemon.jsonrpc_resolve(uri='lbry://@spam/hovercraft'))
|
||||||
self.assertNotIn('claim', response['lbry://@spam/hovercraft'])
|
self.assertNotIn('claim', response['lbry://@spam/hovercraft'])
|
||||||
|
|
Loading…
Reference in a new issue