test_block.py 23 KB
Newer Older
1
"""
2 3 4
Created on 12 déc. 2014

@author: inso
5
"""
inso's avatar
inso committed
6
import unittest
7

8 9
from duniterpy.documents.block import Block
from duniterpy.documents.block_uid import BlockUID, block_uid
10

11
raw_block = """Version: 11
inso's avatar
inso committed
12 13 14 15 16 17
Type: Block
Currency: zeta_brouzouf
Number: 15
PoWMin: 4
Time: 1418083330
MedianTime: 1418080208
18
UnitBase: 0
inso's avatar
inso committed
19
Issuer: HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk
20 21 22
IssuersFrame: 1
IssuersFrameVar: 0
DifferentIssuersCount: 0
inso's avatar
inso committed
23 24 25 26 27 28 29
PreviousHash: 0000E73C340601ACA1AD5AAA5B5E56B03E178EF8
PreviousIssuer: HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk
MembersCount: 4
Identities:
Joiners:
Actives:
Leavers:
inso's avatar
inso committed
30
Revoked:
inso's avatar
inso committed
31 32 33
Excluded:
Certifications:
Transactions:
inso's avatar
inso committed
34
InnerHash: DB30D958EE5CB75186972286ED3F4686B8A1C2CD
inso's avatar
inso committed
35
Nonce: 45079
inso's avatar
inso committed
36 37
42yQm4hGTJYWkPg39hQAUgP6S6EQ4vTfXdJuxKEHL1ih6YHiDL2hcwrFgBHjXLRgxRhj2VNVqqc6b4JayKqTE14r
"""
38

39
raw_block_with_tx = """Version: 11
inso's avatar
inso committed
40 41 42 43 44 45
Type: Block
Currency: meta_brouzouf
Number: 34436
PoWMin: 5
Time: 1443896211
MedianTime: 1443881811
46
UnitBase: 0
inso's avatar
inso committed
47
Issuer: HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk
48 49 50
IssuersFrame: 1
IssuersFrameVar: 0
DifferentIssuersCount: 0
inso's avatar
inso committed
51 52 53 54 55 56
PreviousHash: 000002B06C990DEBD5C1D947289C2CF4F4396FB2
PreviousIssuer: HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk
MembersCount: 19
Identities:
Joiners:
Actives:
inso's avatar
inso committed
57
ATkjQPa4sn4LBF69jqEPzFtRdHYJs6MJQjvP8JdN7MtN:QTowsupV+uXrcomL44WCxbu3LQoJM2C2VPMet5Xg6gXGAHEtGRp47FfQLb2ok1+/588JiIHskCyazj3UOsmKDw==:34434-00000D21F80687248A8C02F16BB19A975B4F983D:34432-00000D21F80687248A8C02F16BB19A975B4F983D:urodelus
inso's avatar
inso committed
58
Leavers:
inso's avatar
inso committed
59
Revoked:
inso's avatar
inso committed
60 61
Excluded:
Certifications:
inso's avatar
inso committed
62 63
5ocqzyDMMWf1V8bsoNhWb1iNwax1e9M7VTUN6navs8of:ATkjQPa4sn4LBF69jqEPzFtRdHYJs6MJQjvP8JdN7MtN:0:6TuxRcARnpo13l3cXtgPTkjJlv8DZOUvsAzmZJMbjHZbbZfDQ6MJpH9DIuH0eyG3WGc0EX/046mbMGBrKKg9DQ==
ATkjQPa4sn4LBF69jqEPzFtRdHYJs6MJQjvP8JdN7MtN:2qwGeLWoPG7db72bKXPfJpAtj67FYDnPaJn2JB7tyXxJ:0:LusTbb7CgwrqqacDKjtldw60swwvDBH8wVUIJN4SWRb2pZPJSpDxgqaGyjC5P9i/DendfyQWc7cfzPDqSZmZAg==
inso's avatar
inso committed
64
Transactions:
65 66
TX:10:1:3:3:1:0:0
33363-000021C4B5BE2DA996F953DC09482F4FA2FA68774B1A38FAB03B2AAB4A08EBE0
inso's avatar
inso committed
67
HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY
68 69 70
5200:0:T:6991C993631BED4733972ED7538E41CCC33660F554E3C51963E2A0AC4D6453D3:0
500:0:T:3A09A20E9014110FD224889F13357BAB4EC78A72F95CA03394D8CCA2936A7435:10
20:0:D:HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY:88
inso's avatar
inso committed
71 72 73 74 75
0:SIG(0)
1:SIG(0)
2:SIG(0)
30:2:SIG(BYfWYFrsyjpvpFysgu19rGK3VHBkz4MqmQbNyEuVU64g)
42yQm4hGTJYWkPg39hQAUgP6S6EQ4vTfXdJuxKEHL1ih6YHiDL2hcwrFgBHjXLRgxRhj2VNVqqc6b4JayKqTE14r
76 77
TX:10:3:6:6:3:1:0
33363-000021C4B5BE2DA996F953DC09482F4FA2FA68774B1A38FAB03B2AAB4A08EBE0
inso's avatar
inso committed
78 79 80
HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY
CYYjHsNyg3HMRMpTHqCJAN9McjH5BwFLmDKGV3PmCuKp
9WYHTavL1pmhunFCzUwiiq4pXwvgGG5ysjZnjz9H8yB
81 82 83 84 85 86
78900:0:T:6991C993631BED4733972ED7538E41CCC33660F554E3C51963E2A0AC4D6453D3:2
700:0:T:3A09A20E9014110FD224889F13357BAB4EC78A72F95CA03394D8CCA2936A7435:8
8900:0:D:HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY:46
780:0:T:A0D9B4CDC113ECE1145C5525873821398890AE842F4B318BD076095A23E70956:3
780:0:T:67F2045B5318777CC52CD38B424F3E40DDA823FA0364625F124BABE0030E7B5B:5
8900:0:D:9WYHTavL1pmhunFCzUwiiq4pXwvgGG5ysjZnjz9H8yB:46
inso's avatar
inso committed
87 88 89 90 91 92 93 94
0:SIG(0)
1:XHX(7665798292)
2:SIG(0)
3:SIG(0) SIG(2)
4:SIG(0) SIG(1) SIG(2)
5:SIG(2)
120:2:SIG(BYfWYFrsyjpvpFysgu19rGK3VHBkz4MqmQbNyEuVU64g)
146:2:SIG(DSz4rgncXCytsUMW2JU2yhLquZECD2XpEkpP9gG5HyAx)
inso's avatar
inso committed
95
49:2:(SIG(6DyGr5LFtFmbaJYRvcs9WmBsr4cbJbJ1EV9zBbqG7A6i) OR XHX(12CCC75A48B1502E4A4E5E9EC2C5153AE2DDF760D5B70262103309D4C7FA86EE))
inso's avatar
inso committed
96 97 98 99
-----@@@----- (why not this comment?)
42yQm4hGTJYWkPg39hQAUgP6S6EQ4vTfXdJuxKEHL1ih6YHiDL2hcwrFgBHjXLRgxRhj2VNVqqc6b4JayKqTE14r
2D96KZwNUvVtcapQPq2mm7J9isFcDCfykwJpVEZwBc7tCgL4qPyu17BT5ePozAE9HS6Yvj51f62Mp4n9d9dkzJoX
2XiBDpuUdu6zCPWGzHXXy8c4ATSscfFQG9DjmqMZUxDZVt1Dp4m2N5oHYVUfoPdrU9SLk4qxi65RNrfCVnvQtQJk
inso's avatar
inso committed
100
InnerHash: DB30D958EE5CB75186972286ED3F4686B8A1C2CD
inso's avatar
inso committed
101
Nonce: 581
inso's avatar
inso committed
102 103 104
nY/MsFU2luiohLmSiOOimL1RIqbriOBgc22ua03Z2dhxtSJxKZeGNGDvl1jaXgmEBRnXU87yXbZ7ioOS/AAVCA==
"""

105
raw_block_zero = """Version: 11
106 107 108 109 110 111
Type: Block
Currency: zeta_brouzouf
Number: 0
PoWMin: 3
Time: 1418077277
MedianTime: 1418077277
112
UnitBase: 0
113
Issuer: HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk
114 115 116 117
IssuersFrame: 1
IssuersFrameVar: 0
DifferentIssuersCount: 0
Parameters: 0.0488:86400:1000:432000:100:5259600:63115200:5:5259600:5259600:0.8:31557600:5:24:300:12:0.67:1488970800:1490094000:15778800
118 119
MembersCount: 4
Identities:
inso's avatar
inso committed
120 121 122 123
HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk:h/H8tDIEbfA4yxMQcvfOXVDQhi1sUa9qYtPKrM59Bulv97ouwbAvAsEkC1Uyit1IOpeAV+CQQs4IaAyjE8F1Cw==:0-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709:cgeek
8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU:lAW4mCPqA3cnEubHAGpMXR0o8euEdDVeSLplRgdLPf8Bty7R7FqVqwoAlL/4q/7p3O57Cz9z3mvhRSNwt23qBw==:0-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709:inso
RdrHvL179Rw62UuyBrqy2M1crx7RPajaViBatS59EGS:Ah55O8cvdkGS4at6AGOKUjy+wrFwAq8iKRJ5xLIb6Xdi3M8WfGOUdMjwZA6GlSkdtlMgEhQPm+r2PMebxKrCBg==:0-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709:vit
9fx25FmeBDJcikZLWxK5HuzKNbY6MaWYXoK1ajteE42Y:ZjlNz2k/7Y38xwzaVEtyteOD12ukRT+x8NBFVTrcZtUHSJdqt7ejBAC0ULu7eCTLlmJk0jS6cuJ3IeVTLfFRDg==:0-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709:ManUtopiK
124
Joiners:
inso's avatar
inso committed
125 126 127 128
HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk:dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu84rraDg==:0-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709:0-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709:cgeek
8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU:43FEO5wwKzo79k+WmZsrUDsNNceStYkrweEntwYGoGn9+YNjyyCbMmKcEU38xzMV2M0ZMgjvlTK30/vWwrD5CQ==:0-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709:0-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709:inso
RdrHvL179Rw62UuyBrqy2M1crx7RPajaViBatS59EGS:zPg1kgjVstsaKDBq3Re6Z84hlw0Ja2pjJEORmn7w5ifT6/e45BnEPJaqoVgImzSnytjOpzXN/rhAO4+UDJOUBQ==:0-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709:0-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709:vit
9fx25FmeBDJcikZLWxK5HuzKNbY6MaWYXoK1ajteE42Y:ox/t5um2bbFJfc6NdRDM8DniGxlRB5zmKuW7WK+MiDpE32GUhf/tDcyfBkIpwIFcaY0hqLYW1OQlgbm2qT6xAw==:0-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709:0-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709:ManUtopiK
129 130
Actives:
Leavers:
inso's avatar
inso committed
131
Revoked:
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
Excluded:
Certifications:
8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU:HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk:0:TgmDuMxZdyutroj9jiLJA8tQp/389JIzDKuxW5+h7GIfjDu1ZbwI7HNm5rlUDhR2KreaV/QJjEaItT4Cf75rCQ==
RdrHvL179Rw62UuyBrqy2M1crx7RPajaViBatS59EGS:HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk:0:xvIlhFdTUwqWx7XIG980xatL0JULOj1Ex15Q9nDcDLVtyFXZZCp1ZeRewkGjkJoGyOFGCJ1iDSB/qFzsPtrsDQ==
9fx25FmeBDJcikZLWxK5HuzKNbY6MaWYXoK1ajteE42Y:HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk:0:mNsbLvezg8Zx1NPfs2gdGwmCKtoVWbw64yEHZE7uPkDvF+iexk93O8IT06HKgo1VI5SennwDfh0qp3Ko1OB5BQ==
HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk:8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU:0:wIdLq6EYKSLoVXcXoSMLciBPMvJvvP1t5cTCIrvPH4qvo/y02al6vFfQR+wUGwFtoXulUSr8C+U1FRHWfUTCBg==
RdrHvL179Rw62UuyBrqy2M1crx7RPajaViBatS59EGS:8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU:0:Gr4EHqCEt+uuLbGPdu1qT/YObkqVthVzmFWCBlKRnRUz3xUt828W25GRtvdVn8hlycvCX/05mMlWeRMBUI/LDA==
9fx25FmeBDJcikZLWxK5HuzKNbY6MaWYXoK1ajteE42Y:8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU:0:qn/XNJjaGIwfnR+wGrDME6YviCQbG+ywsQWnETlAsL6q7o3k1UhpR5ZTVY9dvejLKuC+1mUEXVTmH+8Ib55DBA==
HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk:RdrHvL179Rw62UuyBrqy2M1crx7RPajaViBatS59EGS:0:QLaYgLndAqRIk2uRAuxxhNUEQtSLpPqpfKvGBfClpQV0y7YTm1GnEoX9bY3DPhXU8GjUThngkFR0+M4Fx5R6DQ==
8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU:RdrHvL179Rw62UuyBrqy2M1crx7RPajaViBatS59EGS:0:T+MkH18Eyddq5o93v2tSyBMd/RSkL/mcnE017t/t11QrMmFrXFZeufUhkVfRPi89kLSap4sLV/weEETXX8S7Aw==
9fx25FmeBDJcikZLWxK5HuzKNbY6MaWYXoK1ajteE42Y:RdrHvL179Rw62UuyBrqy2M1crx7RPajaViBatS59EGS:0:mWARDngVFmw76JPmHRZHUOh1MFjddNyJ3OMPQHMERFdeev1hKQ3pEUY9lQc6BL524GjIOcvLWufo65Ie0XTDCQ==
8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU:9fx25FmeBDJcikZLWxK5HuzKNbY6MaWYXoK1ajteE42Y:0:4vLU/VUE5VxcMnvv4mtJs9bky45o2fddKZCnP0FVGZD3BHC20YMPabTZ2RWcNiCc97zig1Munqj2Ss5RQMBDBA==
RdrHvL179Rw62UuyBrqy2M1crx7RPajaViBatS59EGS:9fx25FmeBDJcikZLWxK5HuzKNbY6MaWYXoK1ajteE42Y:0:90w2HrbdsKIc6YJq3Ksa4sSgjpYSMM05+UuowAlYjrk1ixHIyWyg5odyZPRwO50aiIyUsbikoOWsMc3G8ob/Cg==
HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk:9fx25FmeBDJcikZLWxK5HuzKNbY6MaWYXoK1ajteE42Y:0:28lv0p8EPHpVgAMiPvXvIe5lMvYJxwko2tv5bPO4voHRHSaDcTz5BR7Oe69S6wjANIEAMfebXiFMqZdj+mWRAA==
Transactions:
inso's avatar
inso committed
147
InnerHash: DB30D958EE5CB75186972286ED3F4686B8A1C2CD
inso's avatar
inso committed
148
Nonce: 2125
inso's avatar
inso committed
149
42yQm4hGTJYWkPg39hQAUgP6S6EQ4vTfXdJuxKEHL1ih6YHiDL2hcwrFgBHjXLRgxRhj2VNVqqc6b4JayKqTE14r
150 151
"""

152
raw_block_with_leavers = """Version: 11
inso's avatar
inso committed
153 154 155 156 157 158
Type: Block
Currency: meta_brouzouf
Number: 34895
PoWMin: 4
Time: 1444434128
MedianTime: 1444426438
159
UnitBase: 0
inso's avatar
inso committed
160
Issuer: HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk
161 162 163
IssuersFrame: 1
IssuersFrameVar: 0
DifferentIssuersCount: 0
inso's avatar
inso committed
164 165 166 167 168 169 170
PreviousHash: 0000E88115ADDF79344372C0212928501E21622B
PreviousIssuer: HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk
MembersCount: 21
Identities:
Joiners:
Actives:
Leavers:
inso's avatar
inso committed
171 172
2sq8bBDQGK74f1eD3mAPQVgHCmFdijZr9nbv16FwbokX:4MsVEpiL5YXQ0w8KgkbeKR73Y/aSLtQS5HxPFoQJuG5pt+Zl0Q2dLCQfmfvePW4/ANLzcOGnZJH2Tgsw5inJDw==:34893-0000CC15C495623FFAF370D87A7E025FCF01D0AF:0-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709:smoul
Revoked:
inso's avatar
inso committed
173 174 175
Excluded:
Certifications:
Transactions:
inso's avatar
inso committed
176
InnerHash: DB30D958EE5CB75186972286ED3F4686B8A1C2CD
inso's avatar
inso committed
177
Nonce: 9906
inso's avatar
inso committed
178 179 180
5LZCFSnm5FkFihPBTpmsPyILEdvu8MXfJOp6OR4d1s+/e2jVWg4J6YSDfO2KBBPgubASyr2QwQuiBlYD2918Bw==
"""

181
raw_block_with_excluded = """Version: 11
inso's avatar
inso committed
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
Type: Block
Currency: test_net
Number: 33365
PoWMin: 76
Time: 1472075456
MedianTime: 1472072569
UnitBase: 3
Issuer: HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk
IssuersFrame: 50
IssuersFrameVar: 0
DifferentIssuersCount: 9
PreviousHash: 0000338C775613399FA508A8F8B22EB60F525884730639E2A707299E373F43C0
PreviousIssuer: DesHja7gonANRJB7YUkfCgQpnDjgGeDXAeArdhcbXPmJ
MembersCount: 128
Identities:
Joiners:
Actives:
Leavers:
Revoked:
2VAxjr8QoJtSzhE7APno4AkR2RAQNySpNNvDzMgPotSF:DGXpXwnxIP+j6fyLeaa8Toys9TN/fzumIrAslzAf+Tv50PTIrzBkxjE5oHGtI4AvytApW14rFWgWljmbtrVDAw==
Excluded:
2VAxjr8QoJtSzhE7APno4AkR2RAQNySpNNvDzMgPotSF
Certifications:
Transactions:
206
TX:10:1:4:4:12:1:0
inso's avatar
inso committed
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
33363-000021C4B5BE2DA996F953DC09482F4FA2FA68774B1A38FAB03B2AAB4A08EBE0
TENGx7WtzFsTXwnbrPEvb6odX2WnqYcnnrjiiLvp1mS
5:0:T:D25272F1D778B52798B7A51CF0CE21F7C5812F841374508F4367872D4A47F0F7:0
6:1:T:D25272F1D778B52798B7A51CF0CE21F7C5812F841374508F4367872D4A47F0F7:1
7:2:T:D25272F1D778B52798B7A51CF0CE21F7C5812F841374508F4367872D4A47F0F7:2
2300962:3:T:D25272F1D778B52798B7A51CF0CE21F7C5812F841374508F4367872D4A47F0F7:10
0:SIG(0)
1:SIG(0)
2:SIG(0)
3:SIG(0)
5:0:SIG(TENGx7WtzFsTXwnbrPEvb6odX2WnqYcnnrjiiLvp1mS)
6:1:SIG(TENGx7WtzFsTXwnbrPEvb6odX2WnqYcnnrjiiLvp1mS)
7:2:SIG(TENGx7WtzFsTXwnbrPEvb6odX2WnqYcnnrjiiLvp1mS)
10000:3:SIG(5ocqzyDMMWf1V8bsoNhWb1iNwax1e9M7VTUN6navs8of)
13000:3:SIG(XeBpJwRLkF5J4mnwyEDriEcNB13iFpe1MAKR4mH3fzN)
8000:3:SIG(9bZEATXBGPUSsk8oAYi4KAChg3rHKwNt67hVdErbNGCW)
2250:3:SIG(J78bPUvLjxmjaEkdjxWLeENQtcfXm7iobqB49uT1Bgp3)
4750:3:SIG(HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk)
3000:3:SIG(6KXBjAFceD1gp8RBVZfy5YQyKFXG8GaX8tKaLAyPWHrj)
500:3:SIG(ACkHkjDj1SPUu8LhtSAWJLRLoWEXWFuzFPL65zFbe7Yb)
500:3:SIG(5bxtdmC7RGGJEmcdnJ3ut5zg7KdUH2pYZepSHbwNYs7z)
2258962:3:SIG(TENGx7WtzFsTXwnbrPEvb6odX2WnqYcnnrjiiLvp1mS)
REMU:30244:30411
Yo5waBymzDRd0AAMPH8dBj/GnSjtCJUn4EKWaze/4CaU39lf7JAysYmc6yoQGSnGUKZwKT0P0/FvJr9kzX6RBA==
InnerHash: EB2926354963AA21E99E4D304B7765811BA385C9A1976B9A5FACBBCB12F4C969
Nonce: 137387
GmgYhWrwCtsK7t2B/omPpxZ8EfJgv9UYzJIFo++Za+A0Mo70xRfZG7kywxbQTTxDk/V7r90P946N89vdVjv1Bg==
"""

236
negative_issuers_frame_var = """Version: 11
inso's avatar
inso committed
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
Type: Block
Currency: test_net
Number: 34662
PoWMin: 78
Time: 1472499945
MedianTime: 1472496896
UnitBase: 3
Issuer: ATkjQPa4sn4LBF69jqEPzFtRdHYJs6MJQjvP8JdN7MtN
IssuersFrame: 65
IssuersFrameVar: 10
DifferentIssuersCount: 14
PreviousHash: 0000069B5B8B86220D5AAF7E4912FA06860FD72A3C9E2A00E0FE11EA0BDD977C
PreviousIssuer: E2uioubZeK5SDMoxkTkizRnhE8qDL24v5oUNNa1sQKMH
MembersCount: 129
Identities:
Joiners:
Actives:
Leavers:
Revoked:
Excluded:
Certifications:
Transactions:
259
TX:10:1:4:4:2:1:0
inso's avatar
inso committed
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
34660-00001EEB3FDCEB2F9F39F931ED8F6D419C4C64B4D3F7EA52C35FB6B07A085664
5ocqzyDMMWf1V8bsoNhWb1iNwax1e9M7VTUN6navs8of
765201:3:T:636150D38D565DA0B9717E93C2AD8D6270FA032BF963360ECFCDD55F44493F08:1
435871:3:D:5ocqzyDMMWf1V8bsoNhWb1iNwax1e9M7VTUN6navs8of:34596
5500:3:T:84BB2ADBB690F9204E1139DC4967F364847E68B910D6DA52CD71E09F59A4FB9A:5
5500:3:T:A47000FA1B1DE4E72EF18D77033E2B97D815C39A2D7F132418CB3BEDD1A55D6F:5
0:SIG(0)
1:SIG(0)
2:SIG(0)
3:SIG(0)
217935:3:SIG(BnSRjMjJ7gWy13asCRz9rQ6G5Njytdf3pvR1GMkJgtu6)
994137:3:SIG(5ocqzyDMMWf1V8bsoNhWb1iNwax1e9M7VTUN6navs8of)
tu peux maintenant supprimer les annonces dans cesium - nouveau bouton
PkCYSNLQaM1m6cRzgRTknrQ1BjvoyUYO5XRMNNYfjwUigg62guPd79QXZqmBIlUb5RPPI6EF1SMdArhaoYc7Cg==
InnerHash: 96C3CBEC2EF6C7AD768EC787EADEA41B0ADA80FBC611EED6976BBCEDA3D2D6CE
Nonce: 202829
WnJvw204wccmSBQK9UE2rCFw0EG34zf+b58n2KTLwSIhTpgmGsnr5ohkSyYZYcLEKjisLXKNCmMl7D1Q9bJiBQ==
"""


280
class TestBlock(unittest.TestCase):
281
    def test_fromraw(self):
inso's avatar
inso committed
282
        block = Block.from_signed_raw(raw_block)
283
        self.assertEqual(block.version, 11)
inso's avatar
inso committed
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
        self.assertEqual(block.currency, "zeta_brouzouf")
        self.assertEqual(block.noonce, 45079)
        self.assertEqual(block.number, 15)
        self.assertEqual(block.powmin, 4)
        self.assertEqual(block.time, 1418083330)
        self.assertEqual(block.mediantime, 1418080208)
        self.assertEqual(block.issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
        self.assertEqual(block.prev_hash, "0000E73C340601ACA1AD5AAA5B5E56B03E178EF8")
        self.assertEqual(block.prev_issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
        self.assertEqual(block.members_count, 4)
        self.assertEqual(block.identities, [])
        self.assertEqual(block.joiners, [])
        self.assertEqual(block.actives, [])
        self.assertEqual(block.leavers, [])
        self.assertEqual(block.excluded, [])
        self.assertEqual(block.certifications, [])
        self.assertEqual(block.transactions, [])
301

inso's avatar
inso committed
302 303
    def test_from_signed_raw_block_zero(self):
        block = Block.from_signed_raw(raw_block_zero)
304
        self.assertEqual(block.version, 11)
inso's avatar
inso committed
305 306 307 308 309 310 311
        self.assertEqual(block.currency, "zeta_brouzouf")
        self.assertEqual(block.noonce, 2125)
        self.assertEqual(block.number, 0)
        self.assertEqual(block.powmin, 3)
        self.assertEqual(block.time, 1418077277)
        self.assertEqual(block.mediantime, 1418077277)
        self.assertEqual(block.issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
312 313 314 315
        self.assertEqual(block.parameters,
                         ("0.0488", "86400", "1000", "432000", "100", "5259600", "63115200", "5", "5259600",
                          "5259600", "0.8", "31557600", "5", "24", "300", "12", "0.67", "1488970800",
                          "1490094000", "15778800"))
inso's avatar
inso committed
316 317 318 319 320 321 322 323
        self.assertEqual(block.members_count, 4)
        self.assertEqual(len(block.identities), 4)
        self.assertEqual(len(block.joiners), 4)
        self.assertEqual(block.actives, [])
        self.assertEqual(block.leavers, [])
        self.assertEqual(block.excluded, [])
        self.assertEqual(len(block.certifications), 12)
        self.assertEqual(block.transactions, [])
inso's avatar
inso committed
324 325

        self.assertEqual(block.signed_raw(), raw_block_zero)
inso's avatar
inso committed
326

inso's avatar
inso committed
327
    def test_toraw_fromsignedraw(self):
inso's avatar
inso committed
328 329 330 331
        block = Block.from_signed_raw(raw_block)
        rendered_raw = block.signed_raw()
        from_rendered_raw = Block.from_signed_raw(rendered_raw)

332
        self.assertEqual(from_rendered_raw.version, 11)
inso's avatar
inso committed
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
        self.assertEqual(from_rendered_raw.currency, "zeta_brouzouf")
        self.assertEqual(from_rendered_raw.noonce, 45079)
        self.assertEqual(from_rendered_raw.number, 15)
        self.assertEqual(from_rendered_raw.powmin, 4)
        self.assertEqual(from_rendered_raw.time, 1418083330)
        self.assertEqual(from_rendered_raw.mediantime, 1418080208)
        self.assertEqual(from_rendered_raw.issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
        self.assertEqual(from_rendered_raw.prev_hash, "0000E73C340601ACA1AD5AAA5B5E56B03E178EF8")
        self.assertEqual(from_rendered_raw.prev_issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
        self.assertEqual(from_rendered_raw.members_count, 4)
        self.assertEqual(from_rendered_raw.identities, [])
        self.assertEqual(from_rendered_raw.joiners, [])
        self.assertEqual(from_rendered_raw.actives, [])
        self.assertEqual(from_rendered_raw.leavers, [])
        self.assertEqual(from_rendered_raw.excluded, [])
        self.assertEqual(from_rendered_raw.certifications, [])
        self.assertEqual(from_rendered_raw.transactions, [])
inso's avatar
inso committed
350 351

        self.assertEqual(block.signed_raw(), raw_block)
inso's avatar
inso committed
352

inso's avatar
inso committed
353
    def test_toraw_fromrawzero(self):
inso's avatar
inso committed
354 355 356 357
        block = Block.from_signed_raw(raw_block_zero)
        rendered_raw = block.signed_raw()
        from_rendered_raw = block.from_signed_raw(rendered_raw)

358
        self.assertEqual(from_rendered_raw.version, 11)
inso's avatar
inso committed
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
        self.assertEqual(from_rendered_raw.currency, "zeta_brouzouf")
        self.assertEqual(from_rendered_raw.noonce, 2125)
        self.assertEqual(from_rendered_raw.number, 0)
        self.assertEqual(from_rendered_raw.powmin, 3)
        self.assertEqual(from_rendered_raw.time, 1418077277)
        self.assertEqual(from_rendered_raw.mediantime, 1418077277)
        self.assertEqual(from_rendered_raw.issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
        self.assertEqual(from_rendered_raw.members_count, 4)
        self.assertEqual(len(from_rendered_raw.identities), 4)
        self.assertEqual(len(from_rendered_raw.joiners), 4)
        self.assertEqual(from_rendered_raw.actives, [])
        self.assertEqual(from_rendered_raw.leavers, [])
        self.assertEqual(from_rendered_raw.excluded, [])
        self.assertEqual(len(from_rendered_raw.certifications), 12)
        self.assertEqual(from_rendered_raw.transactions, [])
inso's avatar
inso committed
374

inso's avatar
inso committed
375 376 377 378 379 380 381
        self.assertEqual(block.signed_raw(), raw_block_zero)

    def test_raw_with_tx(self):
        block = Block.from_signed_raw(raw_block_with_tx)
        rendered_raw = block.signed_raw()
        from_rendered_raw = block.from_signed_raw(rendered_raw)

382
        self.assertEqual(from_rendered_raw.version, 11)
inso's avatar
inso committed
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
        self.assertEqual(from_rendered_raw.currency, "meta_brouzouf")
        self.assertEqual(from_rendered_raw.noonce, 581)
        self.assertEqual(from_rendered_raw.number, 34436)
        self.assertEqual(from_rendered_raw.powmin, 5)
        self.assertEqual(from_rendered_raw.time, 1443896211)
        self.assertEqual(from_rendered_raw.mediantime, 1443881811)
        self.assertEqual(from_rendered_raw.issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
        self.assertEqual(from_rendered_raw.parameters, None)
        self.assertEqual(from_rendered_raw.members_count, 19)
        self.assertEqual(from_rendered_raw.identities, [])
        self.assertEqual(from_rendered_raw.joiners, [])
        self.assertEqual(len(from_rendered_raw.actives), 1)
        self.assertEqual(from_rendered_raw.leavers, [])
        self.assertEqual(from_rendered_raw.excluded, [])
        self.assertEqual(len(from_rendered_raw.certifications), 2)
        self.assertEqual(len(from_rendered_raw.transactions), 2)
inso's avatar
inso committed
399 400

        self.assertEqual(block.signed_raw(), raw_block_with_tx)
inso's avatar
inso committed
401

inso's avatar
inso committed
402 403 404 405
    def test_raw_with_leavers(self):
        block = Block.from_signed_raw(raw_block_with_leavers)
        rendered_raw = block.signed_raw()
        from_rendered_raw = block.from_signed_raw(rendered_raw)
406
        self.assertEqual(from_rendered_raw.version, 11)
inso's avatar
inso committed
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
        self.assertEqual(from_rendered_raw.currency, "meta_brouzouf")
        self.assertEqual(from_rendered_raw.noonce, 9906)
        self.assertEqual(from_rendered_raw.number, 34895)
        self.assertEqual(from_rendered_raw.powmin, 4)
        self.assertEqual(from_rendered_raw.time, 1444434128)
        self.assertEqual(from_rendered_raw.mediantime, 1444426438)
        self.assertEqual(from_rendered_raw.issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
        self.assertEqual(from_rendered_raw.prev_hash, "0000E88115ADDF79344372C0212928501E21622B")
        self.assertEqual(from_rendered_raw.prev_issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
        self.assertEqual(from_rendered_raw.parameters, None)
        self.assertEqual(from_rendered_raw.members_count, 21)
        self.assertEqual(from_rendered_raw.identities, [])
        self.assertEqual(from_rendered_raw.joiners, [])
        self.assertEqual(from_rendered_raw.actives, [])
        self.assertEqual(len(from_rendered_raw.leavers), 1)
        self.assertEqual(from_rendered_raw.excluded, [])
        self.assertEqual(from_rendered_raw.certifications, [])
        self.assertEqual(from_rendered_raw.transactions, [])
inso's avatar
inso committed
425 426 427

        self.assertEqual(block.signed_raw(), raw_block_with_leavers)

inso's avatar
inso committed
428 429 430 431 432 433
    def test_block_uid__compare(self):
        lower = BlockUID(10, "8101618234DBE5AAD529C13C8BE45E2F9BBE1150CD2FAA25095671F56C1DCDA5")
        higher = BlockUID(14, "E1C0AD728983D8A57335E52CF1064F1AFFD1D454173D8CEBD3ED8B4A72B48704")
        self.assertTrue(lower < higher)
        self.assertFalse(lower > higher)
        self.assertFalse(lower == higher)
inso's avatar
inso committed
434

inso's avatar
inso committed
435 436 437 438 439 440
    def test_parse_with_excluded(self):
        block = Block.from_signed_raw(raw_block_with_excluded)
        rendered_raw = block.signed_raw()
        from_rendered_raw = block.from_signed_raw(rendered_raw)
        self.assertEqual(from_rendered_raw.signed_raw(), raw_block_with_excluded)

inso's avatar
inso committed
441 442 443 444 445 446
    def test_parse_negative_issuers_frame_var(self):
        block = Block.from_signed_raw(negative_issuers_frame_var)
        rendered_raw = block.signed_raw()
        from_rendered_raw = block.from_signed_raw(rendered_raw)
        self.assertEqual(from_rendered_raw.signed_raw(), negative_issuers_frame_var)

447 448 449 450 451 452 453
    def test_block_uid_converter(self):
        buid = block_uid("1345-0000338C775613399FA508A8F8B22EB60F525884730639E2A707299E373F43C0")
        self.assertEqual(buid.number, 1345)
        self.assertEqual(buid.sha_hash, "0000338C775613399FA508A8F8B22EB60F525884730639E2A707299E373F43C0")

    def test_block_uid_converter_error(self):
        with self.assertRaises(TypeError):
454
            block_uid(1235654)
455 456 457 458 459

    def test_block_uid_no_convert(self):
        buid = block_uid(BlockUID(1345, "0000338C775613399FA508A8F8B22EB60F525884730639E2A707299E373F43C0"))
        self.assertEqual(buid.number, 1345)
        self.assertEqual(buid.sha_hash, "0000338C775613399FA508A8F8B22EB60F525884730639E2A707299E373F43C0")
inso's avatar
inso committed
460

inso's avatar
inso committed
461 462 463 464 465 466 467
    def test_block_uid_non_zero(self):
        buid = BlockUID(1345, "0000338C775613399FA508A8F8B22EB60F525884730639E2A707299E373F43C0")
        if not buid:
            self.fail("__nonzero__ comparison failed")
        elif BlockUID.empty():
            self.fail("Empty blockuid __nonzero__ comparison failed")

inso's avatar
inso committed
468
    def test_proof_of_work(self):
469
        block = """Version: 11
inso's avatar
inso committed
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498
Type: Block
Currency: test_net
Number: 60803
PoWMin: 80
Time: 1480979125
MedianTime: 1480975879
UnitBase: 7
Issuer: 9bZEATXBGPUSsk8oAYi4KAChg3rHKwNt67hVdErbNGCW
IssuersFrame: 120
IssuersFrameVar: 0
DifferentIssuersCount: 18
PreviousHash: 0000083FB6E3435ADCDF0F86B0A1BCA108B6B47D4B4BA61D0B4FDC21A262CF4C
PreviousIssuer: BnSRjMjJ7gWy13asCRz9rQ6G5Njytdf3pvR1GMkJgtu6
MembersCount: 187
Identities:
Joiners:
Actives:
Leavers:
Revoked:
Excluded:
Certifications:
Transactions:
InnerHash: 310F57575EA865EF47BFA236108B2B1CAEBFBF8EF70960E32E214E413E9C836B
Nonce: 10200000037440
AywstQpC0S5iaA/YQvbz2alpP6zTYG3tjkWpxy1jgeCo028Te2V327bBZbfDGDzsjxOrF4UVmEBiGsgbqhL9CA==
"""
        block_doc = Block.from_signed_raw(block)
        self.assertEqual(block_doc.proof_of_work(), "00000A84839226046082E2B1AD49664E382D98C845644945D133D4A90408813A")

499

inso's avatar
inso committed
500 501
if __name__ == '__main__':
    unittest.main()