223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
|
"type" : "send",
"previous" : "F685856D73A488894F7F3A62BC3A88E17E985F9969629FF3FDD4A0D4FD823F24",
"work" : "efe5bf06a43d0e0a",
"signature" : "E373A1A38C9A239F4D2AAE52B40EF6DFC8BFEDCEB476588958073B7F462746854282FFE4B98FA6782E92798DAD0E5483C3356550A31339E1D7934B487EF4570D",
"balance" : "00F035A9C7D818E7C34148C524FFFFEE"
}
}]
## Ensure the balance was converted
set balance [dict get $block "balance"]
set balance_expected "1247239665165579623600346831066759150"
if {$balance != $balance_expected} {
puts "\[5.FAIL\] Got: $balance"
puts "\[5.FAIL\] Exp: $balance_expected"
return false
}
## Convert to JSON
set block [::nano::block::json::fromDict $block]
## Ensure balance is in hex again
set balance [dict get [::json::json2dict $block] "balance"]
set balance_expected "00F035A9C7D818E7C34148C524FFFFEE"
if {$balance != $balance_expected} {
puts "\[6.FAIL\] Got: $balance"
puts "\[6.FAIL\] Exp: $balance_expected"
return false
}
## Convert back and verify signature
set verify [::nano::block::json::verifySignature $block]
if {!$verify} {
puts "\[5.FAIL\] Got: $verify"
puts "\[5.FAIL\] Exp: true"
puts "\[7.FAIL\] Got: $verify"
puts "\[7.FAIL\] Exp: true"
return false
}
## Verify Proof of Work
set verify [::nano::block::json::validateWork $block]
if {!$verify} {
puts "\[6.FAIL\] Got: $verify"
puts "\[6.FAIL\] Exp: true"
puts "\[8.FAIL\] Got: $verify"
puts "\[8.FAIL\] Exp: true"
return false
}
return true
}
|