Skip to content

Commit

Permalink
Fix Typo (Name -> ID) (CounterpartyXCP#1009)
Browse files Browse the repository at this point in the history
* Fix uncaught exception for short asset names

* Add unit test to cover short asset names

* Move status assignment
  • Loading branch information
droplister authored and deweller committed Oct 31, 2017
1 parent 3f50299 commit fb7ebad
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions counterpartylib/lib/messages/issuance.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ def parse (db, tx, message, message_type_id):
callable_, call_date, call_price, description = False, 0, 0.0, ''
try:
asset = util.generate_asset_name(asset_id, tx['block_index'])
except exceptions.AssetNameError:
status = 'valid'
except exceptions.AssetIDError:
asset = None
status = 'invalid: bad asset name'
status = 'valid'
except exceptions.UnpackError as e:
asset, quantity, divisible, callable_, call_date, call_price, description = None, None, None, None, None, None, None
status = 'invalid: could not unpack'
Expand Down
27 changes: 27 additions & 0 deletions counterpartylib/test/fixtures/vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1921,6 +1921,33 @@
'quantity': 0,
}}
]
}, {
'comment': 'too short asset length',
# 00000014|00000000000002bf|0000000005f5e100|01
# | | | |
# | | | └─── divisible (1 byte)
# | | └───── quantity (8 bytes) - 100000000
# | └────────────────── asset name (8 bytes) - BBB (invalid)
# └────────────────── Type ID (4 bytes) - type 20/issuance
'in': ({'data': bytes.fromhex('0000001400000000000002bf0000000005f5e10001'), 'block_time': 155409000, 'source': 'mn6q3dS2EnDUx3bmyWc6D4szJNVGtaR7zc', 'block_hash': DP['default_block_hash'], 'block_index': DP['default_block_index'], 'btc_amount': 0, 'fee': 10000, 'supported': 1, 'tx_index': 502, 'destination': '', 'tx_hash': '71da4fac29d6442ef3ff13f291860f512a888161ae9e574f313562851912aace'}, issuance.ID,),
'records': [
{'table': 'issuances', 'values': {
'asset': None,
'asset_longname': None,
'block_index': DP['default_block_index'],
'description': None,
'fee_paid': 0,
'issuer': 'mn6q3dS2EnDUx3bmyWc6D4szJNVGtaR7zc',
'locked': 0,
'quantity': None,
'source': 'mn6q3dS2EnDUx3bmyWc6D4szJNVGtaR7zc',
'status': 'invalid: bad asset name',
'transfer': 0,
'divisible': None,
'tx_hash': '71da4fac29d6442ef3ff13f291860f512a888161ae9e574f313562851912aace',
'tx_index': 502,
}}
]
}, {
'comment': 'first time issuance of subasset',
'in': ({'data': bytes.fromhex('0000001501530821671b10010000000005f5e100010a57c6f36de23a1f5f4c46'), 'block_time': 155409000, 'source': 'mn6q3dS2EnDUx3bmyWc6D4szJNVGtaR7zc', 'block_hash': DP['default_block_hash'], 'block_index': DP['default_block_index'], 'btc_amount': 0, 'fee': 10000, 'supported': 1, 'tx_index': 502, 'destination': '', 'tx_hash': '71da4fac29d6442ef3ff13f291860f512a888161ae9e574f313562851912aace'}, issuance.SUBASSET_ID,),
Expand Down

0 comments on commit fb7ebad

Please sign in to comment.