Skip to content
Snippets Groups Projects
Commit c05e7d38 authored by Moul's avatar Moul
Browse files

[fix] typos in Block: noonce −> nonce, hash

- Update test accordingly
- Block.nonce is not used by Sakia
parent b2faf741
Branches
Tags
2 merge requests!94Merge dev into master for release 0.56.0,!87Typos in Block: noonce −> nonce, hash
Pipeline #7416 canceled
...@@ -98,7 +98,7 @@ The class Block handles Block documents. ...@@ -98,7 +98,7 @@ The class Block handles Block documents.
re_hash = re.compile( re_hash = re.compile(
"InnerHash: ({block_hash_regex})\n".format(block_hash_regex=BLOCK_HASH_REGEX) "InnerHash: ({block_hash_regex})\n".format(block_hash_regex=BLOCK_HASH_REGEX)
) )
re_noonce = re.compile("Nonce: ([0-9]+)\n") re_nonce = re.compile("Nonce: ([0-9]+)\n")
fields_parsers = { fields_parsers = {
**Document.fields_parsers, **Document.fields_parsers,
...@@ -127,7 +127,7 @@ The class Block handles Block documents. ...@@ -127,7 +127,7 @@ The class Block handles Block documents.
"Certifications": re_certifications, "Certifications": re_certifications,
"Transactions": re_transactions, "Transactions": re_transactions,
"InnerHash": re_hash, "InnerHash": re_hash,
"Noonce": re_noonce, "Nonce": re_nonce,
}, },
} }
...@@ -158,7 +158,7 @@ The class Block handles Block documents. ...@@ -158,7 +158,7 @@ The class Block handles Block documents.
certifications: List[Certification], certifications: List[Certification],
transactions: List[Transaction], transactions: List[Transaction],
inner_hash: str, inner_hash: str,
noonce: int, nonce: int,
signature: str, signature: str,
) -> None: ) -> None:
""" """
...@@ -188,8 +188,8 @@ The class Block handles Block documents. ...@@ -188,8 +188,8 @@ The class Block handles Block documents.
:param excluded: members excluded because of missing certifications :param excluded: members excluded because of missing certifications
:param certifications: certifications documents :param certifications: certifications documents
:param transactions: transactions documents :param transactions: transactions documents
:param inner_hash: the block hah :param inner_hash: the block hash
:param noonce: the noonce value of the block :param nonce: the nonce value of the block
:param signature: the block signature :param signature: the block signature
""" """
super().__init__(version, currency, [signature]) super().__init__(version, currency, [signature])
...@@ -229,7 +229,7 @@ The class Block handles Block documents. ...@@ -229,7 +229,7 @@ The class Block handles Block documents.
self.certifications = certifications self.certifications = certifications
self.transactions = transactions self.transactions = transactions
self.inner_hash = inner_hash self.inner_hash = inner_hash
self.noonce = noonce self.nonce = nonce
@property @property
def blockUID(self) -> BlockUID: def blockUID(self) -> BlockUID:
...@@ -399,7 +399,7 @@ The class Block handles Block documents. ...@@ -399,7 +399,7 @@ The class Block handles Block documents.
inner_hash = Block.parse_field("InnerHash", lines[n]) inner_hash = Block.parse_field("InnerHash", lines[n])
n += 1 n += 1
noonce = int(Block.parse_field("Noonce", lines[n])) nonce = int(Block.parse_field("Nonce", lines[n]))
n += 1 n += 1
signature = Block.parse_field("Signature", lines[n]) signature = Block.parse_field("Signature", lines[n])
...@@ -430,7 +430,7 @@ The class Block handles Block documents. ...@@ -430,7 +430,7 @@ The class Block handles Block documents.
certifications, certifications,
transactions, transactions,
inner_hash, inner_hash,
noonce, nonce,
signature, signature,
) )
...@@ -509,7 +509,7 @@ PreviousIssuer: {1}\n".format( ...@@ -509,7 +509,7 @@ PreviousIssuer: {1}\n".format(
doc += "InnerHash: {0}\n".format(self.inner_hash) doc += "InnerHash: {0}\n".format(self.inner_hash)
doc += "Nonce: {0}\n".format(self.noonce) doc += "Nonce: {0}\n".format(self.nonce)
return doc return doc
...@@ -518,7 +518,7 @@ PreviousIssuer: {1}\n".format( ...@@ -518,7 +518,7 @@ PreviousIssuer: {1}\n".format(
Nonce: {nonce} Nonce: {nonce}
{signature} {signature}
""".format( """.format(
inner_hash=self.inner_hash, nonce=self.noonce, signature=self.signatures[0] inner_hash=self.inner_hash, nonce=self.nonce, signature=self.signatures[0]
) )
return hashlib.sha256(doc_str.encode("ascii")).hexdigest().upper() return hashlib.sha256(doc_str.encode("ascii")).hexdigest().upper()
......
...@@ -282,7 +282,7 @@ class TestBlock(unittest.TestCase): ...@@ -282,7 +282,7 @@ class TestBlock(unittest.TestCase):
block = Block.from_signed_raw(raw_block) block = Block.from_signed_raw(raw_block)
self.assertEqual(block.version, 11) self.assertEqual(block.version, 11)
self.assertEqual(block.currency, "zeta_brouzouf") self.assertEqual(block.currency, "zeta_brouzouf")
self.assertEqual(block.noonce, 45079) self.assertEqual(block.nonce, 45079)
self.assertEqual(block.number, 15) self.assertEqual(block.number, 15)
self.assertEqual(block.powmin, 4) self.assertEqual(block.powmin, 4)
self.assertEqual(block.time, 1418083330) self.assertEqual(block.time, 1418083330)
...@@ -305,7 +305,7 @@ class TestBlock(unittest.TestCase): ...@@ -305,7 +305,7 @@ class TestBlock(unittest.TestCase):
block = Block.from_signed_raw(raw_block_zero) block = Block.from_signed_raw(raw_block_zero)
self.assertEqual(block.version, 11) self.assertEqual(block.version, 11)
self.assertEqual(block.currency, "zeta_brouzouf") self.assertEqual(block.currency, "zeta_brouzouf")
self.assertEqual(block.noonce, 2125) self.assertEqual(block.nonce, 2125)
self.assertEqual(block.number, 0) self.assertEqual(block.number, 0)
self.assertEqual(block.powmin, 3) self.assertEqual(block.powmin, 3)
self.assertEqual(block.time, 1418077277) self.assertEqual(block.time, 1418077277)
...@@ -354,7 +354,7 @@ class TestBlock(unittest.TestCase): ...@@ -354,7 +354,7 @@ class TestBlock(unittest.TestCase):
self.assertEqual(from_rendered_raw.version, 11) self.assertEqual(from_rendered_raw.version, 11)
self.assertEqual(from_rendered_raw.currency, "zeta_brouzouf") self.assertEqual(from_rendered_raw.currency, "zeta_brouzouf")
self.assertEqual(from_rendered_raw.noonce, 45079) self.assertEqual(from_rendered_raw.nonce, 45079)
self.assertEqual(from_rendered_raw.number, 15) self.assertEqual(from_rendered_raw.number, 15)
self.assertEqual(from_rendered_raw.powmin, 4) self.assertEqual(from_rendered_raw.powmin, 4)
self.assertEqual(from_rendered_raw.time, 1418083330) self.assertEqual(from_rendered_raw.time, 1418083330)
...@@ -387,7 +387,7 @@ class TestBlock(unittest.TestCase): ...@@ -387,7 +387,7 @@ class TestBlock(unittest.TestCase):
self.assertEqual(from_rendered_raw.version, 11) self.assertEqual(from_rendered_raw.version, 11)
self.assertEqual(from_rendered_raw.currency, "zeta_brouzouf") self.assertEqual(from_rendered_raw.currency, "zeta_brouzouf")
self.assertEqual(from_rendered_raw.noonce, 2125) self.assertEqual(from_rendered_raw.nonce, 2125)
self.assertEqual(from_rendered_raw.number, 0) self.assertEqual(from_rendered_raw.number, 0)
self.assertEqual(from_rendered_raw.powmin, 3) self.assertEqual(from_rendered_raw.powmin, 3)
self.assertEqual(from_rendered_raw.time, 1418077277) self.assertEqual(from_rendered_raw.time, 1418077277)
...@@ -413,7 +413,7 @@ class TestBlock(unittest.TestCase): ...@@ -413,7 +413,7 @@ class TestBlock(unittest.TestCase):
self.assertEqual(from_rendered_raw.version, 11) self.assertEqual(from_rendered_raw.version, 11)
self.assertEqual(from_rendered_raw.currency, "meta_brouzouf") self.assertEqual(from_rendered_raw.currency, "meta_brouzouf")
self.assertEqual(from_rendered_raw.noonce, 581) self.assertEqual(from_rendered_raw.nonce, 581)
self.assertEqual(from_rendered_raw.number, 34436) self.assertEqual(from_rendered_raw.number, 34436)
self.assertEqual(from_rendered_raw.powmin, 5) self.assertEqual(from_rendered_raw.powmin, 5)
self.assertEqual(from_rendered_raw.time, 1443896211) self.assertEqual(from_rendered_raw.time, 1443896211)
...@@ -439,7 +439,7 @@ class TestBlock(unittest.TestCase): ...@@ -439,7 +439,7 @@ class TestBlock(unittest.TestCase):
from_rendered_raw = block.from_signed_raw(rendered_raw) from_rendered_raw = block.from_signed_raw(rendered_raw)
self.assertEqual(from_rendered_raw.version, 11) self.assertEqual(from_rendered_raw.version, 11)
self.assertEqual(from_rendered_raw.currency, "meta_brouzouf") self.assertEqual(from_rendered_raw.currency, "meta_brouzouf")
self.assertEqual(from_rendered_raw.noonce, 9906) self.assertEqual(from_rendered_raw.nonce, 9906)
self.assertEqual(from_rendered_raw.number, 34895) self.assertEqual(from_rendered_raw.number, 34895)
self.assertEqual(from_rendered_raw.powmin, 4) self.assertEqual(from_rendered_raw.powmin, 4)
self.assertEqual(from_rendered_raw.time, 1444434128) self.assertEqual(from_rendered_raw.time, 1444434128)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment