aboutsummaryrefslogtreecommitdiff
path: root/tests/spec
diff options
context:
space:
mode:
Diffstat (limited to 'tests/spec')
-rw-r--r--tests/spec/tests.js117
1 files changed, 72 insertions, 45 deletions
diff --git a/tests/spec/tests.js b/tests/spec/tests.js
index d17c8ef..78110af 100644
--- a/tests/spec/tests.js
+++ b/tests/spec/tests.js
@@ -2285,6 +2285,27 @@ it('Allows selection of Scribe', function(done) {
2285 }; 2285 };
2286 testNetwork(done, params); 2286 testNetwork(done, params);
2287}); 2287});
2288it('Allows selection of Binance Smart Chain', function(done) {
2289 var params = {
2290 selectText: "BSC - Binance Smart Chain",
2291 phrase: "abandon abandon ability",
2292 firstAddress: "0xe5815d5902Ad612d49283DEdEc02100Bd44C2772",
2293 firstPubKey: "0x03e723e5b3aa7d72213f01139aa4783e1b34f74e1a04534e3fd8e29bfe2768af8a",
2294 firstPrivKey: "0x8f253078b73d7498302bb78c171b23ce7a8fb511987d2b2702b731638a4a15e7",
2295 };
2296 testNetwork(done, params);
2297});
2298
2299it('Allows selection of TRX on Tron', function(done) {
2300 var params = {
2301 selectText: "TRX - Tron",
2302 phrase: "abandon abandon ability",
2303 firstAddress: "TA891Fu7vVz595BGQpNX2MCzr7yBcxuoC7",
2304 firstPubKey: "0337bbb060e6166066f7f9e59e52f67bc23a6c9d0cbc815b82b6d89112444842e7",
2305 firstPrivKey: "3a8fbd0379a815764979de86a3fcda759cb62d49e784e7b2a9a03206c90cfae2",
2306 };
2307 testNetwork(done, params);
2308});
2288 2309
2289// BIP39 seed is set from phrase 2310// BIP39 seed is set from phrase
2290it('Sets the bip39 seed from the prhase', function(done) { 2311it('Sets the bip39 seed from the prhase', function(done) {
@@ -3130,7 +3151,7 @@ it("Shows the number of bits of entropy for 4 bits of binary", function(done) {
3130 testEntropyBits(done, "0000", "4"); 3151 testEntropyBits(done, "0000", "4");
3131}); 3152});
3132it("Shows the number of bits of entropy for 1 character of base 6 (dice)", function(done) { 3153it("Shows the number of bits of entropy for 1 character of base 6 (dice)", function(done) {
3133 // 6 in card is 0 in base 6, 0 in base 6 is 2.6 bits (rounded down to 2 bits) 3154 // 6 in card is 0 in base 6, 0 is mapped to 00 by entropy.js
3134 testEntropyBits(done, "6", "2"); 3155 testEntropyBits(done, "6", "2");
3135}); 3156});
3136it("Shows the number of bits of entropy for 1 character of base 10 with 3 bits", function(done) { 3157it("Shows the number of bits of entropy for 1 character of base 10 with 3 bits", function(done) {
@@ -3138,13 +3159,15 @@ it("Shows the number of bits of entropy for 1 character of base 10 with 3 bits",
3138 testEntropyBits(done, "7", "3"); 3159 testEntropyBits(done, "7", "3");
3139}); 3160});
3140it("Shows the number of bits of entropy for 1 character of base 10 with 4 bis", function(done) { 3161it("Shows the number of bits of entropy for 1 character of base 10 with 4 bis", function(done) {
3141 testEntropyBits(done, "8", "4"); 3162 // 8 in base 10 is mapped to 0 by entropy.js
3163 testEntropyBits(done, "8", "1");
3142}); 3164});
3143it("Shows the number of bits of entropy for 1 character of hex", function(done) { 3165it("Shows the number of bits of entropy for 1 character of hex", function(done) {
3144 testEntropyBits(done, "F", "4"); 3166 testEntropyBits(done, "F", "4");
3145}); 3167});
3146it("Shows the number of bits of entropy for 2 characters of base 10", function(done) { 3168it("Shows the number of bits of entropy for 2 characters of base 10", function(done) {
3147 testEntropyBits(done, "29", "6"); 3169 // 2 as base 10 is binary 010, 9 is mapped to binary 1 by entropy.js
3170 testEntropyBits(done, "29", "4");
3148}); 3171});
3149it("Shows the number of bits of entropy for 2 characters of hex", function(done) { 3172it("Shows the number of bits of entropy for 2 characters of hex", function(done) {
3150 testEntropyBits(done, "0A", "8"); 3173 testEntropyBits(done, "0A", "8");
@@ -3169,17 +3192,17 @@ it("Shows the number of bits of entropy for 4 characters of hex with leading zer
3169 testEntropyBits(done, "000A", "16"); 3192 testEntropyBits(done, "000A", "16");
3170}); 3193});
3171it("Shows the number of bits of entropy for 4 characters of base 6", function(done) { 3194it("Shows the number of bits of entropy for 4 characters of base 6", function(done) {
3172 testEntropyBits(done, "5555", "11"); 3195 // 5 in base 6 is mapped to binary 1
3196 testEntropyBits(done, "5555", "4");
3173}); 3197});
3174it("Shows the number of bits of entropy for 4 characters of base 6 dice", function(done) { 3198it("Shows the number of bits of entropy for 4 characters of base 6 dice", function(done) {
3175 // uses dice, so entropy is actually 0000 in base 6, which is 4 lots of 3199 // uses dice, so entropy is actually 0000 in base 6, which is 4 lots of
3176 // 2.58 bits, which is 10.32 bits (rounded down to 10 bits) 3200 // binary 00
3177 testEntropyBits(done, "6666", "10"); 3201 testEntropyBits(done, "6666", "8");
3178}); 3202});
3179it("Shows the number of bits of entropy for 4 charactes of base 10", function(done) { 3203it("Shows the number of bits of entropy for 4 charactes of base 10", function(done) {
3180 // Uses base 10, which is 4 lots of 3.32 bits, which is 13.3 bits (rounded 3204 // 2 in base 10 is binary 010 and 7 is binary 111 so is 4 events of 3 bits
3181 // down to 13) 3205 testEntropyBits(done, "2227", "12");
3182 testEntropyBits(done, "2227", "13");
3183}); 3206});
3184it("Shows the number of bits of entropy for 4 characters of hex with 2 leading zeros", function(done) { 3207it("Shows the number of bits of entropy for 4 characters of hex with 2 leading zeros", function(done) {
3185 testEntropyBits(done, "222F", "16"); 3208 testEntropyBits(done, "222F", "16");
@@ -3188,13 +3211,16 @@ it("Shows the number of bits of entropy for 4 characters of hex starting with F"
3188 testEntropyBits(done, "FFFF", "16"); 3211 testEntropyBits(done, "FFFF", "16");
3189}); 3212});
3190it("Shows the number of bits of entropy for 10 characters of base 10", function(done) { 3213it("Shows the number of bits of entropy for 10 characters of base 10", function(done) {
3191 // 10 events at 3.32 bits per event 3214 // 10 events with 3 bits for each event
3192 testEntropyBits(done, "0000101017", "33"); 3215 testEntropyBits(done, "0000101017", "30");
3216});
3217it("Shows the number of bits of entropy for 10 characters of base 10 account for bias", function(done) {
3218 // 9 events with 3 bits per event and 1 event with 1 bit per event
3219 testEntropyBits(done, "0000101018", "28");
3193}); 3220});
3194it("Shows the number of bits of entropy for a full deck of cards", function(done) { 3221it("Shows the number of bits of entropy for a full deck of cards", function(done) {
3195 // cards are not replaced, so a full deck is not 52^52 entropy which is 296 3222 // removing bias is 32*5 + 16*4 + 4*2
3196 // bits, it's 52!, which is 225 bits 3223 testEntropyBits(done, "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", "232");
3197 testEntropyBits(done, "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", "225");
3198}); 3224});
3199 3225
3200it("Shows details about the entered entropy", function(done) { 3226it("Shows details about the entered entropy", function(done) {
@@ -3320,7 +3346,7 @@ it("Shows details about the entered entropy", function(done) {
3320 entropy: "7d", 3346 entropy: "7d",
3321 type: "card", 3347 type: "card",
3322 events: "1", 3348 events: "1",
3323 bits: "4", 3349 bits: "5",
3324 words: 0, 3350 words: 0,
3325 strength: "less than a second", 3351 strength: "less than a second",
3326 } 3352 }
@@ -3332,7 +3358,7 @@ it("Shows details about the entered entropy", function(done) {
3332 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", 3358 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
3333 type: "card (full deck)", 3359 type: "card (full deck)",
3334 events: "52", 3360 events: "52",
3335 bits: "225", 3361 bits: "232",
3336 words: 21, 3362 words: 21,
3337 strength: "centuries", 3363 strength: "centuries",
3338 } 3364 }
@@ -3344,7 +3370,7 @@ it("Shows details about the entered entropy", function(done) {
3344 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks3d", 3370 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks3d",
3345 type: "card (full deck, 1 duplicate: 3d)", 3371 type: "card (full deck, 1 duplicate: 3d)",
3346 events: "53", 3372 events: "53",
3347 bits: "254", 3373 bits: "237",
3348 words: 21, 3374 words: 21,
3349 strength: "centuries", 3375 strength: "centuries",
3350 } 3376 }
@@ -3356,7 +3382,7 @@ it("Shows details about the entered entropy", function(done) {
3356 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d", 3382 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d",
3357 type: "card (2 duplicates: 3d 4d, 1 missing: KS)", 3383 type: "card (2 duplicates: 3d 4d, 1 missing: KS)",
3358 events: "53", 3384 events: "53",
3359 bits: "254", 3385 bits: "240",
3360 words: 21, 3386 words: 21,
3361 strength: "centuries", 3387 strength: "centuries",
3362 } 3388 }
@@ -3368,8 +3394,8 @@ it("Shows details about the entered entropy", function(done) {
3368 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d5d6d", 3394 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d5d6d",
3369 type: "card (4 duplicates: 3d 4d 5d..., 1 missing: KS)", 3395 type: "card (4 duplicates: 3d 4d 5d..., 1 missing: KS)",
3370 events: "55", 3396 events: "55",
3371 bits: "264", 3397 bits: "250",
3372 words: 24, 3398 words: 21,
3373 strength: "centuries", 3399 strength: "centuries",
3374 } 3400 }
3375 ); 3401 );
@@ -3377,13 +3403,12 @@ it("Shows details about the entered entropy", function(done) {
3377it("Shows details about the entered entropy", function(done) { 3403it("Shows details about the entered entropy", function(done) {
3378 testEntropyFeedback(done, 3404 testEntropyFeedback(done,
3379 // Next test was throwing uncaught error in zxcvbn 3405 // Next test was throwing uncaught error in zxcvbn
3380 // Also tests 451 bits, ie Math.log2(52!)*2 = 225.58 * 2
3381 { 3406 {
3382 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsksac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", 3407 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsksac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
3383 type: "card (full deck, 52 duplicates: ac 2c 3c...)", 3408 type: "card (full deck, 52 duplicates: ac 2c 3c...)",
3384 events: "104", 3409 events: "104",
3385 bits: "499", 3410 bits: "464",
3386 words: 45, 3411 words: 42,
3387 strength: "centuries", 3412 strength: "centuries",
3388 } 3413 }
3389 ); 3414 );
@@ -3395,7 +3420,7 @@ it("Shows details about the entered entropy", function(done) {
3395 entropy: "asAS", 3420 entropy: "asAS",
3396 type: "card (1 duplicate: AS)", 3421 type: "card (1 duplicate: AS)",
3397 events: "2", 3422 events: "2",
3398 bits: "9", 3423 bits: "8",
3399 words: 0, 3424 words: 0,
3400 strength: "less than a second", 3425 strength: "less than a second",
3401 } 3426 }
@@ -3407,7 +3432,7 @@ it("Shows details about the entered entropy", function(done) {
3407 entropy: "ASas", 3432 entropy: "ASas",
3408 type: "card (1 duplicate: as)", 3433 type: "card (1 duplicate: as)",
3409 events: "2", 3434 events: "2",
3410 bits: "9", 3435 bits: "8",
3411 words: 0, 3436 words: 0,
3412 strength: "less than a second", 3437 strength: "less than a second",
3413 } 3438 }
@@ -3420,8 +3445,8 @@ it("Shows details about the entered entropy", function(done) {
3420 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", 3445 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
3421 type: "card (1 missing: 9C)", 3446 type: "card (1 missing: 9C)",
3422 events: "51", 3447 events: "51",
3423 bits: "221", 3448 bits: "227",
3424 words: 18, 3449 words: 21,
3425 strength: "centuries", 3450 strength: "centuries",
3426 } 3451 }
3427 ); 3452 );
@@ -3432,7 +3457,7 @@ it("Shows details about the entered entropy", function(done) {
3432 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", 3457 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
3433 type: "card (2 missing: 9C 5D)", 3458 type: "card (2 missing: 9C 5D)",
3434 events: "50", 3459 events: "50",
3435 bits: "216", 3460 bits: "222",
3436 words: 18, 3461 words: 18,
3437 strength: "centuries", 3462 strength: "centuries",
3438 } 3463 }
@@ -3444,7 +3469,7 @@ it("Shows details about the entered entropy", function(done) {
3444 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjd kdah2h3h 5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", 3469 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjd kdah2h3h 5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
3445 type: "card (4 missing: 9C 5D QD...)", 3470 type: "card (4 missing: 9C 5D QD...)",
3446 events: "48", 3471 events: "48",
3447 bits: "208", 3472 bits: "212",
3448 words: 18, 3473 words: 18,
3449 strength: "centuries", 3474 strength: "centuries",
3450 } 3475 }
@@ -3457,20 +3482,21 @@ it("Shows details about the entered entropy", function(done) {
3457 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d 8d9d jd kdah2h3h 5h6h7h8h9hthjhqhkh 2s3s4s5s6s7s8s9stsjsqsks", 3482 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d 8d9d jd kdah2h3h 5h6h7h8h9hthjhqhkh 2s3s4s5s6s7s8s9stsjsqsks",
3458 type: "card", 3483 type: "card",
3459 events: "45", 3484 events: "45",
3460 bits: "195", 3485 bits: "198",
3461 words: 18, 3486 words: 18,
3462 strength: "centuries", 3487 strength: "centuries",
3463 } 3488 }
3464 ); 3489 );
3465}); 3490});
3466it("Shows details about the entered entropy", function(done) { 3491it("Shows details about the entered entropy", function(done) {
3492 // multiple decks does not affect the bits per event
3493 // since the bits are hardcoded in entropy.js
3467 testEntropyFeedback(done, 3494 testEntropyFeedback(done,
3468 // Multiple decks of cards increases bits per event
3469 { 3495 {
3470 entropy: "3d", 3496 entropy: "3d",
3471 events: "1", 3497 events: "1",
3472 bits: "4", 3498 bits: "5",
3473 bitsPerEvent: "4.34", 3499 bitsPerEvent: "4.46",
3474 } 3500 }
3475 ); 3501 );
3476}); 3502});
@@ -3479,8 +3505,8 @@ it("Shows details about the entered entropy", function(done) {
3479 { 3505 {
3480 entropy: "3d3d", 3506 entropy: "3d3d",
3481 events: "2", 3507 events: "2",
3482 bits: "9", 3508 bits: "10",
3483 bitsPerEvent: "4.80", 3509 bitsPerEvent: "4.46",
3484 } 3510 }
3485 ); 3511 );
3486}); 3512});
@@ -3490,7 +3516,7 @@ it("Shows details about the entered entropy", function(done) {
3490 entropy: "3d3d3d", 3516 entropy: "3d3d3d",
3491 events: "3", 3517 events: "3",
3492 bits: "15", 3518 bits: "15",
3493 bitsPerEvent: "5.01", 3519 bitsPerEvent: "4.46",
3494 } 3520 }
3495 ); 3521 );
3496}); 3522});
@@ -3500,7 +3526,7 @@ it("Shows details about the entered entropy", function(done) {
3500 entropy: "3d3d3d3d", 3526 entropy: "3d3d3d3d",
3501 events: "4", 3527 events: "4",
3502 bits: "20", 3528 bits: "20",
3503 bitsPerEvent: "5.14", 3529 bitsPerEvent: "4.46",
3504 } 3530 }
3505 ); 3531 );
3506}); 3532});
@@ -3509,8 +3535,8 @@ it("Shows details about the entered entropy", function(done) {
3509 { 3535 {
3510 entropy: "3d3d3d3d3d", 3536 entropy: "3d3d3d3d3d",
3511 events: "5", 3537 events: "5",
3512 bits: "26", 3538 bits: "25",
3513 bitsPerEvent: "5.22", 3539 bitsPerEvent: "4.46",
3514 } 3540 }
3515 ); 3541 );
3516}); 3542});
@@ -3519,8 +3545,8 @@ it("Shows details about the entered entropy", function(done) {
3519 { 3545 {
3520 entropy: "3d3d3d3d3d3d", 3546 entropy: "3d3d3d3d3d3d",
3521 events: "6", 3547 events: "6",
3522 bits: "31", 3548 bits: "30",
3523 bitsPerEvent: "5.28", 3549 bitsPerEvent: "4.46",
3524 } 3550 }
3525 ); 3551 );
3526}); 3552});
@@ -3529,8 +3555,8 @@ it("Shows details about the entered entropy", function(done) {
3529 { 3555 {
3530 entropy: "3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d", 3556 entropy: "3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d",
3531 events: "33", 3557 events: "33",
3532 bits: "184", 3558 bits: "165",
3533 bitsPerEvent: "5.59", 3559 bitsPerEvent: "4.46",
3534 strength: 'less than a second - Repeats like "abcabcabc" are only slightly harder to guess than "abc"', 3560 strength: 'less than a second - Repeats like "abcabcabc" are only slightly harder to guess than "abc"',
3535 } 3561 }
3536 ); 3562 );
@@ -3581,10 +3607,11 @@ it('Converts very long entropy to very long mnemonics', function(done) {
3581// https://bip32jp.github.io/english/index.html 3607// https://bip32jp.github.io/english/index.html
3582// NOTES: 3608// NOTES:
3583// Is incompatible with: 3609// Is incompatible with:
3610// base 6
3584// base 20 3611// base 20
3585it('Is compatible with bip32jp.github.io', function(done) { 3612it('Is compatible with bip32jp.github.io', function(done) {
3586 var entropy = "543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543"; 3613 var entropy = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
3587 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"; 3614 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";
3588 driver.findElement(By.css('.use-entropy')) 3615 driver.findElement(By.css('.use-entropy'))
3589 .click(); 3616 .click();
3590 driver.findElement(By.css('.entropy')) 3617 driver.findElement(By.css('.entropy'))