refactor: move generate to blockchain call

This commit is contained in:
Victor Shyba 2019-04-28 23:18:42 -03:00 committed by Lex Berezhny
parent c2ca0a9467
commit 46c03c0cb2
3 changed files with 8 additions and 7 deletions

View file

@ -151,11 +151,15 @@ class CommandTestCase(IntegrationTestCase):
await self.blockchain.generate(blocks)
await self.ledger.on_header.where(self.blockchain.is_expected_block)
def blockchain_claim_name(self, name: str, value: str, amount: str):
return self.blockchain._cli_cmnd('claimname', name, value, amount)
async def blockchain_claim_name(self, name: str, value: str, amount: str):
txid = await self.blockchain._cli_cmnd('claimname', name, value, amount)
await self.generate(1)
return txid
def blockchain_update_name(self, txid: str, value: str, amount: str):
return self.blockchain._cli_cmnd('updateclaim', txid, value, amount)
async def blockchain_update_name(self, txid: str, value: str, amount: str):
txid = await self.blockchain._cli_cmnd('updateclaim', txid, value, amount)
await self.generate(1)
return txid
async def out(self, awaitable):
""" Serializes lbrynet API results to JSON then loads and returns it as dictionary. """

View file

@ -34,12 +34,10 @@ class FileCommands(CommandTestCase):
claim = claim['lbry://foo']['claim']['protobuf'].decode()
await self.daemon.jsonrpc_file_delete(claim_name='foo')
txid = await self.blockchain_claim_name('bar', claim, '0.01')
await self.generate(1)
await self.daemon.jsonrpc_get('lbry://bar')
claim = Claim.from_bytes(unhexlify(claim))
claim.stream.description = "fix typos, fix the world"
await self.blockchain_update_name(txid, hexlify(claim.to_bytes()).decode(), '0.01')
await self.generate(1)
await self.daemon.jsonrpc_resolve('lbry://bar')
file_list = self.daemon.jsonrpc_file_list()
self.assertEqual(file_list[0].stream_claim_info.claim.stream.description, claim.stream.description)

View file

@ -72,7 +72,6 @@ class ResolveCommand(CommandTestCase):
# resolve handles invalid data
txid = await self.blockchain_claim_name(
"gibberish", hexlify(b"{'invalid':'json'}").decode(), "0.1")
await self.generate(1)
response = await self.resolve("lbry://gibberish")
self.assertSetEqual({'lbry://gibberish'}, set(response))
claim = response['lbry://gibberish']['claim']