262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
## Verify Proof of Work
set verify [::nano::block::json::validateWork $block]
if {!$verify} {
puts "\[8.FAIL\] Got: $verify"
puts "\[8.FAIL\] Exp: true"
return false
}
# A typical block cycle
set seed DB4FDFD0F2ABED9E18ACF7FF20EC83ABAD34AAC6A77270A09EDEA5786E4CCF11
set key [::nano::key::fromSeed $seed]
set account [::nano::address::fromPrivateKey $key]
set frontierHash $seed
::nano::account::setFrontier $account $frontierHash 1 $account
set block [::nano::account::send $account $account 1 $key]
set block [::nano::block::json::work $block -update]
set block [::nano::block::json::filter $block]
set block [::nano::block::dict::fromJSON $block]
set signature [dict get $block "signature"]
set signature_expected "1E7AA03DB5CFCB1692A23D8F0DD29C854640B8954E96ECC84BD535D8D1FAADC7FE1008BB3473BE0DC328723E224D40F4B7B309CB78C33CAFC64635CA725FA50E"
if {$signature ne $signature_expected} {
puts "\[9.FAIL\] Got: $signature"
puts "\[9.FAIL\] Exp: $signature_expected"
return false
}
set verify [::nano::block::dict::validateWork $block]
if {!$verify} {
puts "\[10.FAIL\] Got: $verify"
puts "\[10.FAIL\] Exp: true"
return false
}
return true
}
proc test_work {} {
|