add and test support for support_create anonymous --comment

This commit is contained in:
Victor Shyba 2021-05-31 21:39:46 -03:00 committed by Lex Berezhny
parent 67cce0ef7e
commit a638aa9d53
2 changed files with 11 additions and 4 deletions

View file

@ -928,13 +928,14 @@ class Transaction:
funding_accounts: List['Account'], change_account: 'Account', signing_channel: Output = None,
comment: str = None):
ledger, _ = cls.ensure_all_have_same_ledger_and_wallet(funding_accounts, change_account)
if signing_channel is not None:
if signing_channel is not None or comment is not None:
support = Support()
support.emoji = '👍'
if comment is not None:
support.comment = comment
support_output = Output.pay_support_data_pubkey_hash(
amount, claim_name, claim_id, support, ledger.address_to_hash160(holding_address)
)
if signing_channel is not None:
support_output.sign(signing_channel, b'placeholder txid:nout')
else:
support_output = Output.pay_support_pubkey_hash(

View file

@ -582,6 +582,12 @@ class TransactionOutputCommands(ClaimTestCase):
r, = await self.txo_list(type='support')
self.assertEqual(r['txid'], support['txid'])
self.assertEqual(r['value']['comment'], "nice!")
await self.support_abandon(txid=support['txid'], nout=0, blocking=True)
support = await self.support_create(stream, comment="anonymously great!")
self.assertEqual(support['outputs'][0]['value']['comment'], "anonymously great!")
r, = await self.txo_list(type='support', is_not_spent=True)
self.assertEqual(r['txid'], support['txid'])
self.assertEqual(r['value']['comment'], "anonymously great!")
async def test_txo_list_resolve_supports(self):
channel = self.get_claim_id(await self.channel_create('@identity'))