Update tests and code

This commit is contained in:
hackrush 2019-05-20 01:51:54 +05:30 committed by Lex Berezhny
parent 7a78d49e13
commit d367ff6ac1
3 changed files with 11 additions and 7 deletions

View file

@ -1903,7 +1903,7 @@ class Daemon(metaclass=JSONRPCServerType):
channel_pubkey_hash = account.ledger.public_key_to_address(
txo.claim.channel.public_key_bytes
)
account.add_channel_private_key(channel_pubkey_hash, txo.ref.id, txo.private_key)
account.add_channel_private_key(txo.claim_name, channel_pubkey_hash, txo.id, txo.private_key)
self.default_wallet.save()
await self.storage.save_claims([self._old_get_temp_claim_info(
tx, txo, claim_address, claim, name, dewies_to_lbc(amount)
@ -2044,7 +2044,7 @@ class Daemon(metaclass=JSONRPCServerType):
channel_pubkey_hash = account.ledger.public_key_to_address(
new_txo.claim.channel.public_key_bytes
)
account.add_channel_private_key(channel_pubkey_hash, new_txo.ref.id, new_txo.private_key)
account.add_channel_private_key(new_txo.claim_name, channel_pubkey_hash, new_txo.id, new_txo.private_key)
self.default_wallet.save()
await self.storage.save_claims([self._old_get_temp_claim_info(
tx, new_txo, claim_address, new_txo.claim, new_txo.claim_name, dewies_to_lbc(amount)

View file

@ -38,11 +38,13 @@ class Account(BaseAccount):
super().apply(d)
self.channel_keys.update(d.get('certificates', {}))
def add_channel_private_key(self, channel_pubkey_hash, ref_id, private_key):
assert channel_pubkey_hash not in self.channel_keys, 'Trying to add a duplicate channel private key.'
def add_channel_private_key(self, channel_name, channel_pubkey_hash, ref_id, private_key):
assert ref_id not in self.channel_keys, 'Trying to add a duplicate channel private key.'
self.channel_keys[ref_id] = private_key
if channel_pubkey_hash not in self.channel_keys:
self.channel_keys[channel_pubkey_hash] = private_key
else:
log.info("Public-Private key mapping for the channel %s already exists. Skipping...", channel_name)
def get_channel_private_key(self, channel_pubkey_hash):
return self.channel_keys.get(channel_pubkey_hash)

View file

@ -255,7 +255,7 @@ class ChannelCommands(CommandTestCase):
fixed_values['public_key'] = channel['public_key']
self.assertEqual(channel, {'public_key': fixed_values['public_key'], 'featured': ['beef']})
# update channel setting all fields
# update channel "@featurechannel" setting all fields
tx = await self.out(self.channel_update(claim_id, **values))
channel = tx['outputs'][0]['value']
fixed_values['featured'].insert(0, 'beef') # existing featured claim
@ -301,6 +301,8 @@ class ChannelCommands(CommandTestCase):
# send the private key too
txoid = f"{tx['outputs'][0]['txid']}:{tx['outputs'][0]['nout']}"
account2.channel_keys[txoid] = self.account.channel_keys[txoid]
channel_pubkey_address_hash = self.account.ledger.public_key_to_address(unhexlify(channel['public_key']))
account2.channel_keys[channel_pubkey_address_hash] = self.account.channel_keys[channel_pubkey_address_hash]
# now should have private key
txo = (await account2.get_channels())[0]