aboutsummaryrefslogtreecommitdiff
path: root/tests/spec/tests.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/spec/tests.js')
-rw-r--r--tests/spec/tests.js106
1 files changed, 61 insertions, 45 deletions
diff --git a/tests/spec/tests.js b/tests/spec/tests.js
index d73f17d..8b3b07b 100644
--- a/tests/spec/tests.js
+++ b/tests/spec/tests.js
@@ -2275,6 +2275,16 @@ it('Allows selection of Scribe', function(done) {
2275 }; 2275 };
2276 testNetwork(done, params); 2276 testNetwork(done, params);
2277}); 2277});
2278it('Allows selection of Binance Smart Chain', function(done) {
2279 var params = {
2280 selectText: "BSC - Binance Smart Chain",
2281 phrase: "abandon abandon ability",
2282 firstAddress: "0xe5815d5902Ad612d49283DEdEc02100Bd44C2772",
2283 firstPubKey: "0x03e723e5b3aa7d72213f01139aa4783e1b34f74e1a04534e3fd8e29bfe2768af8a",
2284 firstPrivKey: "0x8f253078b73d7498302bb78c171b23ce7a8fb511987d2b2702b731638a4a15e7",
2285 };
2286 testNetwork(done, params);
2287});
2278 2288
2279it('Allows selection of TRX on Tron', function(done) { 2289it('Allows selection of TRX on Tron', function(done) {
2280 var params = { 2290 var params = {
@@ -3131,7 +3141,7 @@ it("Shows the number of bits of entropy for 4 bits of binary", function(done) {
3131 testEntropyBits(done, "0000", "4"); 3141 testEntropyBits(done, "0000", "4");
3132}); 3142});
3133it("Shows the number of bits of entropy for 1 character of base 6 (dice)", function(done) { 3143it("Shows the number of bits of entropy for 1 character of base 6 (dice)", function(done) {
3134 // 6 in card is 0 in base 6, 0 in base 6 is 2.6 bits (rounded down to 2 bits) 3144 // 6 in card is 0 in base 6, 0 is mapped to 00 by entropy.js
3135 testEntropyBits(done, "6", "2"); 3145 testEntropyBits(done, "6", "2");
3136}); 3146});
3137it("Shows the number of bits of entropy for 1 character of base 10 with 3 bits", function(done) { 3147it("Shows the number of bits of entropy for 1 character of base 10 with 3 bits", function(done) {
@@ -3139,13 +3149,15 @@ it("Shows the number of bits of entropy for 1 character of base 10 with 3 bits",
3139 testEntropyBits(done, "7", "3"); 3149 testEntropyBits(done, "7", "3");
3140}); 3150});
3141it("Shows the number of bits of entropy for 1 character of base 10 with 4 bis", function(done) { 3151it("Shows the number of bits of entropy for 1 character of base 10 with 4 bis", function(done) {
3142 testEntropyBits(done, "8", "4"); 3152 // 8 in base 10 is mapped to 0 by entropy.js
3153 testEntropyBits(done, "8", "1");
3143}); 3154});
3144it("Shows the number of bits of entropy for 1 character of hex", function(done) { 3155it("Shows the number of bits of entropy for 1 character of hex", function(done) {
3145 testEntropyBits(done, "F", "4"); 3156 testEntropyBits(done, "F", "4");
3146}); 3157});
3147it("Shows the number of bits of entropy for 2 characters of base 10", function(done) { 3158it("Shows the number of bits of entropy for 2 characters of base 10", function(done) {
3148 testEntropyBits(done, "29", "6"); 3159 // 2 as base 10 is binary 010, 9 is mapped to binary 1 by entropy.js
3160 testEntropyBits(done, "29", "4");
3149}); 3161});
3150it("Shows the number of bits of entropy for 2 characters of hex", function(done) { 3162it("Shows the number of bits of entropy for 2 characters of hex", function(done) {
3151 testEntropyBits(done, "0A", "8"); 3163 testEntropyBits(done, "0A", "8");
@@ -3170,17 +3182,17 @@ it("Shows the number of bits of entropy for 4 characters of hex with leading zer
3170 testEntropyBits(done, "000A", "16"); 3182 testEntropyBits(done, "000A", "16");
3171}); 3183});
3172it("Shows the number of bits of entropy for 4 characters of base 6", function(done) { 3184it("Shows the number of bits of entropy for 4 characters of base 6", function(done) {
3173 testEntropyBits(done, "5555", "11"); 3185 // 5 in base 6 is mapped to binary 1
3186 testEntropyBits(done, "5555", "4");
3174}); 3187});
3175it("Shows the number of bits of entropy for 4 characters of base 6 dice", function(done) { 3188it("Shows the number of bits of entropy for 4 characters of base 6 dice", function(done) {
3176 // uses dice, so entropy is actually 0000 in base 6, which is 4 lots of 3189 // uses dice, so entropy is actually 0000 in base 6, which is 4 lots of
3177 // 2.58 bits, which is 10.32 bits (rounded down to 10 bits) 3190 // binary 00
3178 testEntropyBits(done, "6666", "10"); 3191 testEntropyBits(done, "6666", "8");
3179}); 3192});
3180it("Shows the number of bits of entropy for 4 charactes of base 10", function(done) { 3193it("Shows the number of bits of entropy for 4 charactes of base 10", function(done) {
3181 // Uses base 10, which is 4 lots of 3.32 bits, which is 13.3 bits (rounded 3194 // 2 in base 10 is binary 010 and 7 is binary 111 so is 4 events of 3 bits
3182 // down to 13) 3195 testEntropyBits(done, "2227", "12");
3183 testEntropyBits(done, "2227", "13");
3184}); 3196});
3185it("Shows the number of bits of entropy for 4 characters of hex with 2 leading zeros", function(done) { 3197it("Shows the number of bits of entropy for 4 characters of hex with 2 leading zeros", function(done) {
3186 testEntropyBits(done, "222F", "16"); 3198 testEntropyBits(done, "222F", "16");
@@ -3189,13 +3201,16 @@ it("Shows the number of bits of entropy for 4 characters of hex starting with F"
3189 testEntropyBits(done, "FFFF", "16"); 3201 testEntropyBits(done, "FFFF", "16");
3190}); 3202});
3191it("Shows the number of bits of entropy for 10 characters of base 10", function(done) { 3203it("Shows the number of bits of entropy for 10 characters of base 10", function(done) {
3192 // 10 events at 3.32 bits per event 3204 // 10 events with 3 bits for each event
3193 testEntropyBits(done, "0000101017", "33"); 3205 testEntropyBits(done, "0000101017", "30");
3206});
3207it("Shows the number of bits of entropy for 10 characters of base 10 account for bias", function(done) {
3208 // 9 events with 3 bits per event and 1 event with 1 bit per event
3209 testEntropyBits(done, "0000101018", "28");
3194}); 3210});
3195it("Shows the number of bits of entropy for a full deck of cards", function(done) { 3211it("Shows the number of bits of entropy for a full deck of cards", function(done) {
3196 // cards are not replaced, so a full deck is not 52^52 entropy which is 296 3212 // removing bias is 32*5 + 16*4 + 4*2
3197 // bits, it's 52!, which is 225 bits 3213 testEntropyBits(done, "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", "232");
3198 testEntropyBits(done, "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", "225");
3199}); 3214});
3200 3215
3201it("Shows details about the entered entropy", function(done) { 3216it("Shows details about the entered entropy", function(done) {
@@ -3321,7 +3336,7 @@ it("Shows details about the entered entropy", function(done) {
3321 entropy: "7d", 3336 entropy: "7d",
3322 type: "card", 3337 type: "card",
3323 events: "1", 3338 events: "1",
3324 bits: "4", 3339 bits: "5",
3325 words: 0, 3340 words: 0,
3326 strength: "less than a second", 3341 strength: "less than a second",
3327 } 3342 }
@@ -3333,7 +3348,7 @@ it("Shows details about the entered entropy", function(done) {
3333 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", 3348 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
3334 type: "card (full deck)", 3349 type: "card (full deck)",
3335 events: "52", 3350 events: "52",
3336 bits: "225", 3351 bits: "232",
3337 words: 21, 3352 words: 21,
3338 strength: "centuries", 3353 strength: "centuries",
3339 } 3354 }
@@ -3345,7 +3360,7 @@ it("Shows details about the entered entropy", function(done) {
3345 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks3d", 3360 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks3d",
3346 type: "card (full deck, 1 duplicate: 3d)", 3361 type: "card (full deck, 1 duplicate: 3d)",
3347 events: "53", 3362 events: "53",
3348 bits: "254", 3363 bits: "237",
3349 words: 21, 3364 words: 21,
3350 strength: "centuries", 3365 strength: "centuries",
3351 } 3366 }
@@ -3357,7 +3372,7 @@ it("Shows details about the entered entropy", function(done) {
3357 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d", 3372 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d",
3358 type: "card (2 duplicates: 3d 4d, 1 missing: KS)", 3373 type: "card (2 duplicates: 3d 4d, 1 missing: KS)",
3359 events: "53", 3374 events: "53",
3360 bits: "254", 3375 bits: "240",
3361 words: 21, 3376 words: 21,
3362 strength: "centuries", 3377 strength: "centuries",
3363 } 3378 }
@@ -3369,8 +3384,8 @@ it("Shows details about the entered entropy", function(done) {
3369 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d5d6d", 3384 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d5d6d",
3370 type: "card (4 duplicates: 3d 4d 5d..., 1 missing: KS)", 3385 type: "card (4 duplicates: 3d 4d 5d..., 1 missing: KS)",
3371 events: "55", 3386 events: "55",
3372 bits: "264", 3387 bits: "250",
3373 words: 24, 3388 words: 21,
3374 strength: "centuries", 3389 strength: "centuries",
3375 } 3390 }
3376 ); 3391 );
@@ -3378,13 +3393,12 @@ it("Shows details about the entered entropy", function(done) {
3378it("Shows details about the entered entropy", function(done) { 3393it("Shows details about the entered entropy", function(done) {
3379 testEntropyFeedback(done, 3394 testEntropyFeedback(done,
3380 // Next test was throwing uncaught error in zxcvbn 3395 // Next test was throwing uncaught error in zxcvbn
3381 // Also tests 451 bits, ie Math.log2(52!)*2 = 225.58 * 2
3382 { 3396 {
3383 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsksac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", 3397 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsksac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
3384 type: "card (full deck, 52 duplicates: ac 2c 3c...)", 3398 type: "card (full deck, 52 duplicates: ac 2c 3c...)",
3385 events: "104", 3399 events: "104",
3386 bits: "499", 3400 bits: "464",
3387 words: 45, 3401 words: 42,
3388 strength: "centuries", 3402 strength: "centuries",
3389 } 3403 }
3390 ); 3404 );
@@ -3396,7 +3410,7 @@ it("Shows details about the entered entropy", function(done) {
3396 entropy: "asAS", 3410 entropy: "asAS",
3397 type: "card (1 duplicate: AS)", 3411 type: "card (1 duplicate: AS)",
3398 events: "2", 3412 events: "2",
3399 bits: "9", 3413 bits: "8",
3400 words: 0, 3414 words: 0,
3401 strength: "less than a second", 3415 strength: "less than a second",
3402 } 3416 }
@@ -3408,7 +3422,7 @@ it("Shows details about the entered entropy", function(done) {
3408 entropy: "ASas", 3422 entropy: "ASas",
3409 type: "card (1 duplicate: as)", 3423 type: "card (1 duplicate: as)",
3410 events: "2", 3424 events: "2",
3411 bits: "9", 3425 bits: "8",
3412 words: 0, 3426 words: 0,
3413 strength: "less than a second", 3427 strength: "less than a second",
3414 } 3428 }
@@ -3421,8 +3435,8 @@ it("Shows details about the entered entropy", function(done) {
3421 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", 3435 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
3422 type: "card (1 missing: 9C)", 3436 type: "card (1 missing: 9C)",
3423 events: "51", 3437 events: "51",
3424 bits: "221", 3438 bits: "227",
3425 words: 18, 3439 words: 21,
3426 strength: "centuries", 3440 strength: "centuries",
3427 } 3441 }
3428 ); 3442 );
@@ -3433,7 +3447,7 @@ it("Shows details about the entered entropy", function(done) {
3433 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", 3447 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
3434 type: "card (2 missing: 9C 5D)", 3448 type: "card (2 missing: 9C 5D)",
3435 events: "50", 3449 events: "50",
3436 bits: "216", 3450 bits: "222",
3437 words: 18, 3451 words: 18,
3438 strength: "centuries", 3452 strength: "centuries",
3439 } 3453 }
@@ -3445,7 +3459,7 @@ it("Shows details about the entered entropy", function(done) {
3445 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjd kdah2h3h 5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", 3459 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjd kdah2h3h 5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
3446 type: "card (4 missing: 9C 5D QD...)", 3460 type: "card (4 missing: 9C 5D QD...)",
3447 events: "48", 3461 events: "48",
3448 bits: "208", 3462 bits: "212",
3449 words: 18, 3463 words: 18,
3450 strength: "centuries", 3464 strength: "centuries",
3451 } 3465 }
@@ -3458,20 +3472,21 @@ it("Shows details about the entered entropy", function(done) {
3458 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d 8d9d jd kdah2h3h 5h6h7h8h9hthjhqhkh 2s3s4s5s6s7s8s9stsjsqsks", 3472 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d 8d9d jd kdah2h3h 5h6h7h8h9hthjhqhkh 2s3s4s5s6s7s8s9stsjsqsks",
3459 type: "card", 3473 type: "card",
3460 events: "45", 3474 events: "45",
3461 bits: "195", 3475 bits: "198",
3462 words: 18, 3476 words: 18,
3463 strength: "centuries", 3477 strength: "centuries",
3464 } 3478 }
3465 ); 3479 );
3466}); 3480});
3467it("Shows details about the entered entropy", function(done) { 3481it("Shows details about the entered entropy", function(done) {
3482 // multiple decks does not affect the bits per event
3483 // since the bits are hardcoded in entropy.js
3468 testEntropyFeedback(done, 3484 testEntropyFeedback(done,
3469 // Multiple decks of cards increases bits per event
3470 { 3485 {
3471 entropy: "3d", 3486 entropy: "3d",
3472 events: "1", 3487 events: "1",
3473 bits: "4", 3488 bits: "5",
3474 bitsPerEvent: "4.34", 3489 bitsPerEvent: "4.46",
3475 } 3490 }
3476 ); 3491 );
3477}); 3492});
@@ -3480,8 +3495,8 @@ it("Shows details about the entered entropy", function(done) {
3480 { 3495 {
3481 entropy: "3d3d", 3496 entropy: "3d3d",
3482 events: "2", 3497 events: "2",
3483 bits: "9", 3498 bits: "10",
3484 bitsPerEvent: "4.80", 3499 bitsPerEvent: "4.46",
3485 } 3500 }
3486 ); 3501 );
3487}); 3502});
@@ -3491,7 +3506,7 @@ it("Shows details about the entered entropy", function(done) {
3491 entropy: "3d3d3d", 3506 entropy: "3d3d3d",
3492 events: "3", 3507 events: "3",
3493 bits: "15", 3508 bits: "15",
3494 bitsPerEvent: "5.01", 3509 bitsPerEvent: "4.46",
3495 } 3510 }
3496 ); 3511 );
3497}); 3512});
@@ -3501,7 +3516,7 @@ it("Shows details about the entered entropy", function(done) {
3501 entropy: "3d3d3d3d", 3516 entropy: "3d3d3d3d",
3502 events: "4", 3517 events: "4",
3503 bits: "20", 3518 bits: "20",
3504 bitsPerEvent: "5.14", 3519 bitsPerEvent: "4.46",
3505 } 3520 }
3506 ); 3521 );
3507}); 3522});
@@ -3510,8 +3525,8 @@ it("Shows details about the entered entropy", function(done) {
3510 { 3525 {
3511 entropy: "3d3d3d3d3d", 3526 entropy: "3d3d3d3d3d",
3512 events: "5", 3527 events: "5",
3513 bits: "26", 3528 bits: "25",
3514 bitsPerEvent: "5.22", 3529 bitsPerEvent: "4.46",
3515 } 3530 }
3516 ); 3531 );
3517}); 3532});
@@ -3520,8 +3535,8 @@ it("Shows details about the entered entropy", function(done) {
3520 { 3535 {
3521 entropy: "3d3d3d3d3d3d", 3536 entropy: "3d3d3d3d3d3d",
3522 events: "6", 3537 events: "6",
3523 bits: "31", 3538 bits: "30",
3524 bitsPerEvent: "5.28", 3539 bitsPerEvent: "4.46",
3525 } 3540 }
3526 ); 3541 );
3527}); 3542});
@@ -3530,8 +3545,8 @@ it("Shows details about the entered entropy", function(done) {
3530 { 3545 {
3531 entropy: "3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d", 3546 entropy: "3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d",
3532 events: "33", 3547 events: "33",
3533 bits: "184", 3548 bits: "165",
3534 bitsPerEvent: "5.59", 3549 bitsPerEvent: "4.46",
3535 strength: 'less than a second - Repeats like "abcabcabc" are only slightly harder to guess than "abc"', 3550 strength: 'less than a second - Repeats like "abcabcabc" are only slightly harder to guess than "abc"',
3536 } 3551 }
3537 ); 3552 );
@@ -3582,10 +3597,11 @@ it('Converts very long entropy to very long mnemonics', function(done) {
3582// https://bip32jp.github.io/english/index.html 3597// https://bip32jp.github.io/english/index.html
3583// NOTES: 3598// NOTES:
3584// Is incompatible with: 3599// Is incompatible with:
3600// base 6
3585// base 20 3601// base 20
3586it('Is compatible with bip32jp.github.io', function(done) { 3602it('Is compatible with bip32jp.github.io', function(done) {
3587 var entropy = "543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543"; 3603 var entropy = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
3588 var expectedPhrase = "train then jungle barely whip fiber purpose puppy eagle cloud clump hospital robot brave balcony utility detect estate old green desk skill multiply virus"; 3604 var expectedPhrase = "primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary foster";
3589 driver.findElement(By.css('.use-entropy')) 3605 driver.findElement(By.css('.use-entropy'))
3590 .click(); 3606 .click();
3591 driver.findElement(By.css('.entropy')) 3607 driver.findElement(By.css('.entropy'))