diff options
author | Ian Coleman <coleman.ian@gmail.com> | 2017-01-12 13:47:09 +1100 |
---|---|---|
committer | Ian Coleman <coleman.ian@gmail.com> | 2017-01-12 13:47:09 +1100 |
commit | 53aaab270d7031a05ffe66f424529ea84534fb40 (patch) | |
tree | 836610b56c6ed5096954e7a104b9437fe6bde794 /tests.js | |
parent | 40892aba5013cd75927f63e66492f46b2d206ec9 (diff) | |
download | BIP39-53aaab270d7031a05ffe66f424529ea84534fb40.tar.gz BIP39-53aaab270d7031a05ffe66f424529ea84534fb40.tar.zst BIP39-53aaab270d7031a05ffe66f424529ea84534fb40.zip |
Entropy is left-padded to 256 bits
Closes #49
Diffstat (limited to 'tests.js')
-rw-r--r-- | tests.js | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -3335,6 +3335,35 @@ page.open(url, function(status) { | |||
3335 | }); | 3335 | }); |
3336 | }, | 3336 | }, |
3337 | 3337 | ||
3338 | // Github issue 49 | ||
3339 | // padding for binary should give length with multiple of 256 | ||
3340 | // hashed entropy 1111 is length 252, so requires 4 leading zeros | ||
3341 | // prior to issue 49 it would only generate 2 leading zeros, ie missing 2 | ||
3342 | function() { | ||
3343 | page.open(url, function(status) { | ||
3344 | expected = "avocado valid quantum cross link predict excuse edit street able flame large galaxy ginger nuclear" | ||
3345 | // use entropy | ||
3346 | page.evaluate(function() { | ||
3347 | $(".use-entropy").prop("checked", true).trigger("change"); | ||
3348 | $(".entropy").val("1111").trigger("input"); | ||
3349 | }); | ||
3350 | waitForGenerate(function() { | ||
3351 | // get the mnemonic | ||
3352 | var actual = page.evaluate(function() { | ||
3353 | return $(".phrase").val(); | ||
3354 | }); | ||
3355 | // check the mnemonic is correct | ||
3356 | if (actual != expected) { | ||
3357 | console.log("Left padding error for entropy"); | ||
3358 | console.log("Expected: " + expected); | ||
3359 | console.log("Actual: " + actual); | ||
3360 | fail(); | ||
3361 | } | ||
3362 | next(); | ||
3363 | }); | ||
3364 | }); | ||
3365 | }, | ||
3366 | |||
3338 | // If you wish to add more tests, do so here... | 3367 | // If you wish to add more tests, do so here... |
3339 | 3368 | ||
3340 | // Here is a blank test template | 3369 | // Here is a blank test template |