Commit 0f0bc38c authored by Moul's avatar Moul

[fix] InputSource: fix from_inline() regex:

- Remove trailing \n, and limit UnitBase to 9
- Lock feature with a test
parent 3d50342f
......@@ -55,8 +55,8 @@ class InputSource:
block_id_regex=BLOCK_ID_REGEX,
transaction_hash_regex=TRANSACTION_HASH_REGEX))
re_inline_v3 = re.compile(
"([0-9]+):([0-9]+):(?:(?:(D):({pubkey_regex}):({block_id_regex}))|(?:(T):({transaction_hash_regex}):\
([0-9]+)))\n"
"([0-9]+):([0-9]):(?:(?:(D):({pubkey_regex}):({block_id_regex}))|(?:(T):({transaction_hash_regex}):\
([0-9]+)))"
.format(pubkey_regex=PUBKEY_REGEX,
block_id_regex=BLOCK_ID_REGEX,
transaction_hash_regex=TRANSACTION_HASH_REGEX))
......
......@@ -6,7 +6,7 @@ Created on 12 déc. 2014
import unittest
import pypeg2
from duniterpy.grammars import output
from duniterpy.documents.transaction import Transaction, reduce_base, SimpleTransaction
from duniterpy.documents.transaction import Transaction, reduce_base, SimpleTransaction, InputSource
compact_change = """TX:10:1:1:1:1:1:0
13410-000041DF0CCA173F09B5FBA48F619D4BC934F12ADF1D0B798639EB2149C4A8CC
......@@ -480,3 +480,9 @@ class TestTransaction(unittest.TestCase):
tx = Transaction.from_compact("zeta_brousouf", tx_compact)
self.assertFalse(SimpleTransaction.is_simple(tx))
def test_inputsource_from_inline(self):
input_source_str = "30:0:T:6991C993631BED4733972ED7538E41CCC33660F554E3C51963E2A0AC4D6453D3:2"
i = InputSource.from_inline(10, input_source_str)
self.assertEqual(i.inline(10), input_source_str)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment