diff --git a/duniterpy/documents/transaction.py b/duniterpy/documents/transaction.py index adc764c5808d009c93dfaf797a224253c4be9bc3..a4cfc8ee4817d4668a531eb737ad59f3846b6fe6 100644 --- a/duniterpy/documents/transaction.py +++ b/duniterpy/documents/transaction.py @@ -254,7 +254,7 @@ class SIGParameter: return self.index == other.index def __hash__(self) -> int: - return hash((self.index)) + return hash(self.index) @classmethod def from_parameter( @@ -310,7 +310,7 @@ class XHXParameter: return self.integer == other.integer def __hash__(self) -> int: - return hash((self.integer)) + return hash(self.integer) @classmethod def from_parameter( @@ -380,7 +380,7 @@ class Unlock: A Transaction UNLOCK """ - re_inline = re.compile("([0-9]+):((?:SIG\\([0-9]+\\)|XHX\\([0-9]+\\)|\\s)+)\n") + re_inline = re.compile("([0-9]+):((?:SIG\\([0-9]+\\)|XHX\\([0-9]+\\)|\\s)+)") def __init__( self, index: int, parameters: List[Union[SIGParameter, XHXParameter]] @@ -425,8 +425,8 @@ class Unlock: index = int(data.group(1)) parameters_str = data.group(2).split(" ") parameters = [] - for p in parameters_str: - param = UnlockParameter.from_parameter(p) + for parameter in parameters_str: + param = UnlockParameter.from_parameter(parameter) if param: parameters.append(param) return cls(index, parameters) @@ -437,7 +437,9 @@ class Unlock: :return: """ - return "{0}:{1}".format(self.index, " ".join([str(p) for p in self.parameters])) + return "{0}:{1}".format( + self.index, " ".join([str(parameter) for parameter in self.parameters]) + ) # required to type hint cls in classmethod diff --git a/tests/documents/test_transaction.py b/tests/documents/test_transaction.py index 108a31790acbe3bd91d6633ebc62c7a26187f0ff..47d6432f751112190f6df0acce22104127b9ade9 100644 --- a/tests/documents/test_transaction.py +++ b/tests/documents/test_transaction.py @@ -436,3 +436,8 @@ class TestTransaction(unittest.TestCase): self.assertTrue(transaction.time is None) self.assertTrue(transaction.currency == "gtest") self.assertTrue(transaction.inputs[0].amount == 30) + + def test_unlock(self): + unlock1 = Unlock(0, [SIGParameter(0)]) + unlock2 = Unlock.from_inline(unlock1.inline()) + self.assertEqual(unlock1.inline(), unlock2.inline())