Diff

Differences From Artifact [0ce1525912]:

To Artifact [b8561a2b70]:


304
305
306
307
308
309
310
311










































































312
313
314
315
316
317
318
319

320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
		puts "\[3.FAIL\] Exp: true"

		return false
	}

	return true
}











































































set tests {
	selftest
	signatures
	hashing
	keygeneration
	addressformat
	blocks
	work

}

foreach test $tests {
	puts -nonewline "\[    \] $test"
	flush stdout

	if {[catch {
		if {![test_$test]} {
			puts "\[FAIL\] $test"
			exit 1
		} else {
			puts "\r\[ OK \] $test"
		}
	} testErr]} {
		puts "\[ERR \] $test: $testErr"
		exit 1
	}
}

puts "\[DONE\] All tests pass"

exit 0








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>








>








|





|







304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
		puts "\[3.FAIL\] Exp: true"

		return false
	}

	return true
}

proc test_balances {} {
	set balance 1001500000000000000000000000000
	set balance [::nano::balance::toUnit $balance Nano 3]
	set balance_expected "1.001"
	if {$balance != $balance_expected} {
		puts "\[1.FAIL\] Got: $balance"
		puts "\[1.FAIL\] Exp: $balance_expected"

		return false
	}

	set balance 1001510000000000000000000000000
	set balance [::nano::balance::toUnit $balance Nano 3]
	set balance_expected "1.002"
	if {$balance != $balance_expected} {
		puts "\[2.FAIL\] Got: $balance"
		puts "\[2.FAIL\] Exp: $balance_expected"

		return false
	}

	set balance 100150000000000000000000000000000000000
	set balance [::nano::balance::toUnit $balance unano 3]
	set balance_expected "100150000000000000000.000"
	if {$balance != $balance_expected} {
		puts "\[3.FAIL\] Got: $balance"
		puts "\[3.FAIL\] Exp: $balance_expected"

		return false
	}
	set balance 10
	set balance [::nano::balance::toRaw $balance Nano]
	set balance_expected 10000000000000000000000000000000
	if {$balance != $balance_expected} {
		puts "\[4.FAIL\] Got: $balance"
		puts "\[4.FAIL\] Exp: $balance_expected"

		return false
	}

	set balance 1.000000000000000000001
	set balance [::nano::balance::toRaw $balance Nano]
	set balance_expected 1000000000000000000001000000000
	if {$balance != $balance_expected} {
		puts "\[5.FAIL\] Got: $balance"
		puts "\[5.FAIL\] Exp: $balance_expected"

		return false
	}

	set unitName [::nano::balance::normalizeUnitName Mnano]
	set unitName_expected "Nano"
	if {$unitName != $unitName_expected} {
		puts "\[6.FAIL\] Got: $unitName"
		puts "\[6.FAIL\] Exp: $unitName_expected"

		return false
	}

	set balance 3.3346
	set balance [::nano::balance::toRaw $balance unano]
	set balance_expected $balance
	set balance [::nano::balance::toHuman $balance]
	set balance [::nano::balance::toRaw {*}$balance]
	if {$balance != $balance_expected} {
		puts ""
		puts "\[7.FAIL\] Got: $balance"
		puts "\[7.FAIL\] Exp: $balance_expected"

		return false
	}
	return true
}

set tests {
	selftest
	signatures
	hashing
	keygeneration
	addressformat
	blocks
	work
	balances
}

foreach test $tests {
	puts -nonewline "\[    \] $test"
	flush stdout

	if {[catch {
		if {![test_$test]} {
			puts "\r\[FAIL\] $test"
			exit 1
		} else {
			puts "\r\[ OK \] $test"
		}
	} testErr]} {
		puts "\r\[ERR!\] $test: $testErr"
		exit 1
	}
}

puts "\[DONE\] All tests pass"

exit 0