Check-in [33f9a7b27a]
Overview
Comment:Added a complete block generation cycle test
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 33f9a7b27ae72dababc1fd6a1972ba71633209759fb9378ebe3d8098d69ba09f
User & Date: rkeene on 2018-07-11 17:23:30
Other Links: manifest | tags
Context
2018-07-11
17:28
Even faster block work generation test check-in: dfb2005c0f user: rkeene tags: trunk
17:23
Added a complete block generation cycle test check-in: 33f9a7b27a user: rkeene tags: trunk
17:04
Simplified balance to human readable handling to only deal with two units -- Nano and raw check-in: dd09cf79e5 user: rkeene tags: trunk
Changes

Modified test/test.tcl from [b8561a2b70] to [0b36e2ea3f].

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 {} {