From 3eef9d0d36adf3e1034fe7a11ccd4802505218ca Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 23 Aug 2016 17:45:23 +1000 Subject: Tests use waitForGenerate, not magical setTimeout --- tests.js | 89 ++++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 30 deletions(-) diff --git a/tests.js b/tests.js index f5ce6d3..812ed14 100644 --- a/tests.js +++ b/tests.js @@ -4,6 +4,7 @@ var page = require('webpage').create(); var url = 'src/index.html'; +var testMaxTime = 5000; page.onResourceError = function(e) { console.log("Error loading " + e.url); @@ -15,6 +16,34 @@ function fail() { phantom.exit(); } +function waitForGenerate(fn, maxTime) { + if (!maxTime) { + maxTime = testMaxTime; + } + var start = new Date().getTime(); + var prevAddressCount = -1; + var wait = function keepWaiting() { + var now = new Date().getTime(); + var hasTimedOut = now - start > maxTime; + var addressCount = page.evaluate(function() { + return $(".address").length; + }); + var hasFinished = addressCount > 0 && addressCount == prevAddressCount; + prevAddressCount = addressCount; + if (hasFinished) { + fn(); + } + else if (hasTimedOut) { + console.log("Test timed out"); + fn(); + } + else { + setTimeout(keepWaiting, 100); + } + } + wait(); +} + function next() { if (tests.length > 0) { var testsStr = tests.length == 1 ? "test" : "tests"; @@ -63,7 +92,7 @@ page.open(url, function(status) { $(".phrase").val("abandon abandon ability").trigger("input"); }); // get the address - setTimeout(function() { + waitForGenerate(function() { var actual = page.evaluate(function() { return $(".address:first").text(); }); @@ -74,7 +103,7 @@ page.open(url, function(status) { fail(); } next(); - }, 1000); + }); }); }, @@ -94,7 +123,7 @@ page.open(url, function(status) { $(".generate").click(); }); // get the new phrase - setTimeout(function() { + waitForGenerate(function() { var phrase = page.evaluate(function() { return $(".phrase").val(); }); @@ -103,7 +132,7 @@ page.open(url, function(status) { fail(); } next(); - }, 1000); + }); }); }, @@ -121,7 +150,7 @@ page.open(url, function(status) { $(".generate").click(); }); // check the new phrase is six words long - setTimeout(function() { + waitForGenerate(function() { var actualLength = page.evaluate(function() { var words = $(".phrase").val().split(" "); return words.length; @@ -133,7 +162,7 @@ page.open(url, function(status) { fail(); } next(); - }, 1000); + }); }); }, @@ -147,7 +176,7 @@ page.open(url, function(status) { $(".passphrase").val("secure_passphrase").trigger("input"); }); // check the address is generated correctly - setTimeout(function() { + waitForGenerate(function() { var actual = page.evaluate(function() { return $(".address:first").text(); }); @@ -158,7 +187,7 @@ page.open(url, function(status) { fail(); } next(); - }, 1000); + }); }); }, @@ -175,7 +204,7 @@ page.open(url, function(status) { $(".network").trigger("change"); }); // check the address is generated correctly - setTimeout(function() { + waitForGenerate(function() { var actual = page.evaluate(function() { return $(".address:first").text(); }); @@ -186,7 +215,7 @@ page.open(url, function(status) { fail(); } next(); - }, 1000); + }); }); }, @@ -203,7 +232,7 @@ page.open(url, function(status) { $(".network").trigger("change"); }); // check the address is generated correctly - setTimeout(function() { + waitForGenerate(function() { var actual = page.evaluate(function() { return $(".address:first").text(); }); @@ -214,7 +243,7 @@ page.open(url, function(status) { fail(); } next(); - }, 1000); + }); }); }, @@ -231,7 +260,7 @@ page.open(url, function(status) { $(".network").trigger("change"); }); // check the address is generated correctly - setTimeout(function() { + waitForGenerate(function() { var actual = page.evaluate(function() { return $(".address:first").text(); }); @@ -242,7 +271,7 @@ page.open(url, function(status) { fail(); } next(); - }, 1000); + }); }); }, @@ -259,7 +288,7 @@ page.open(url, function(status) { $(".network").trigger("change"); }); // check the address is generated correctly - setTimeout(function() { + waitForGenerate(function() { var actual = page.evaluate(function() { return $(".address:first").text(); }); @@ -270,7 +299,7 @@ page.open(url, function(status) { fail(); } next(); - }, 1000); + }); }); }, @@ -287,7 +316,7 @@ page.open(url, function(status) { $(".network").trigger("change"); }); // check the address is generated correctly - setTimeout(function() { + waitForGenerate(function() { var actual = page.evaluate(function() { return $(".address:first").text(); }); @@ -298,7 +327,7 @@ page.open(url, function(status) { fail(); } next(); - }, 1000); + }); }); }, @@ -315,7 +344,7 @@ page.open(url, function(status) { $(".network").trigger("change"); }); // check the address is generated correctly - setTimeout(function() { + waitForGenerate(function() { var actual = page.evaluate(function() { return $(".address:first").text(); }); @@ -326,7 +355,7 @@ page.open(url, function(status) { fail(); } next(); - }, 1000); + }); }); }, @@ -343,7 +372,7 @@ page.open(url, function(status) { $(".network").trigger("change"); }); // check the address is generated correctly - setTimeout(function() { + waitForGenerate(function() { var actual = page.evaluate(function() { return $(".address:first").text(); }); @@ -354,7 +383,7 @@ page.open(url, function(status) { fail(); } next(); - }, 1000); + }); }); }, @@ -371,7 +400,7 @@ page.open(url, function(status) { $(".network").trigger("change"); }); // check the address is generated correctly - setTimeout(function() { + waitForGenerate(function() { var actual = page.evaluate(function() { return $(".address:first").text(); }); @@ -382,7 +411,7 @@ page.open(url, function(status) { fail(); } next(); - }, 1000); + }); }); }, @@ -399,7 +428,7 @@ page.open(url, function(status) { $(".network").trigger("change"); }); // check the address is generated correctly - setTimeout(function() { + waitForGenerate(function() { var actual = page.evaluate(function() { return $(".address:first").text(); }); @@ -410,7 +439,7 @@ page.open(url, function(status) { fail(); } next(); - }, 1000); + }); }); }, @@ -424,7 +453,7 @@ page.open(url, function(status) { $(".phrase").trigger("input"); }); // check the address is generated correctly - setTimeout(function() { + waitForGenerate(function() { var actual = page.evaluate(function() { return $(".seed").val(); }); @@ -435,7 +464,7 @@ page.open(url, function(status) { fail(); } next(); - }, 1000); + }); }); }, @@ -449,7 +478,7 @@ page.open(url, function(status) { $(".phrase").trigger("input"); }); // check the address is generated correctly - setTimeout(function() { + waitForGenerate(function() { var actual = page.evaluate(function() { return $(".root-key").val(); }); @@ -460,7 +489,7 @@ page.open(url, function(status) { fail(); } next(); - }, 1000); + }); }); }, -- cgit v1.2.3 From cf7258fd4f822891f8906844177d2839f63e861b Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 23 Aug 2016 18:16:27 +1000 Subject: Test changing tabs --- tests.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tests.js b/tests.js index 812ed14..7f133cd 100644 --- a/tests.js +++ b/tests.js @@ -493,11 +493,40 @@ page.open(url, function(status) { }); }, -// TODO finish these tests - // Tabs show correct addresses when changed +function() { +page.open(url, function(status) { + // set the phrase + var expected = "17uQ7s2izWPwBmEVFikTmZUjbBKWYdJchz"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + // change tabs + waitForGenerate(function() { + page.evaluate(function() { + $("#bip32-tab a").click(); + }); + // check the address is generated correctly + waitForGenerate(function() { + var actual = page.evaluate(function() { + return $(".address:first").text(); + }); + if (actual != expected) { + console.log("Clicking tab generates incorrect address"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); + }); +}); +}, // BIP44 derivation path is shown +// TODO finish these tests + // BIP44 extended private key is shown // BIP44 extended public key is shown // BIP44 purpose field changes address list -- cgit v1.2.3 From d077e1e71643798614f66652509ca3a409e530a8 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 23 Aug 2016 18:22:12 +1000 Subject: Test BIP44 derivation path is shown --- tests.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests.js b/tests.js index 7f133cd..a04137f 100644 --- a/tests.js +++ b/tests.js @@ -525,6 +525,30 @@ page.open(url, function(status) { }, // BIP44 derivation path is shown +function() { +page.open(url, function(status) { + // set the phrase + var expected = "m/44'/0'/0'/0"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + // check the derivation path of the first address + waitForGenerate(function() { + var actual = page.evaluate(function() { + return $("#bip44 .path").val(); + }); + if (actual != expected) { + console.log("BIP44 derivation path is incorrect"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); +}); +}, + // TODO finish these tests // BIP44 extended private key is shown -- cgit v1.2.3 From fb3726873f9dd6d7319388a1a5e472042098248b Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 23 Aug 2016 18:25:38 +1000 Subject: Test order is randomized --- tests.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests.js b/tests.js index a04137f..bacaec0 100644 --- a/tests.js +++ b/tests.js @@ -56,6 +56,21 @@ function next() { } } +/** + * Randomize array element order in-place. + * Using Durstenfeld shuffle algorithm. + * See http://stackoverflow.com/a/12646864 + */ +function shuffle(array) { + for (var i = array.length - 1; i > 0; i--) { + var j = Math.floor(Math.random() * (i + 1)); + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + return array; +} + tests = [ // Page loads with status of 'success' @@ -602,4 +617,5 @@ page.open(url, function(status) { ]; console.log("Running tests..."); +tests = shuffle(tests); next(); -- cgit v1.2.3 From 4fd2925d08ab76479610db36c71d9827472dd291 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 23 Aug 2016 19:33:32 +1000 Subject: Test BIP44 extended private key --- tests.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tests.js b/tests.js index bacaec0..099d700 100644 --- a/tests.js +++ b/tests.js @@ -564,9 +564,31 @@ page.open(url, function(status) { }); }, -// TODO finish these tests - // BIP44 extended private key is shown +function() { +page.open(url, function(status) { + // set the phrase + var expected = "xprvA2DxxvPZcyRvYgZMGS53nadR32mVDeCyqQYyFhrCVbJNjPoxMeVf7QT5g7mQASbTf9Kp4cryvcXnu2qurjWKcrdsr91jXymdCDNxKgLFKJG"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + // check the derivation path of the first address + waitForGenerate(function() { + var actual = page.evaluate(function() { + return $(".extended-priv-key").val(); + }); + if (actual != expected) { + console.log("BIP44 extended private key is incorrect"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); +}); +}, + // BIP44 extended public key is shown // BIP44 purpose field changes address list // BIP44 coin field changes address list -- cgit v1.2.3 From 39fd45bb13bd3174546af033a3c3dc87c3b2b2f0 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 23 Aug 2016 19:33:48 +1000 Subject: Test BIP44 extended private key is shown --- tests.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests.js b/tests.js index 099d700..81c8504 100644 --- a/tests.js +++ b/tests.js @@ -590,6 +590,32 @@ page.open(url, function(status) { }, // BIP44 extended public key is shown +function() { +page.open(url, function(status) { + // set the phrase + var expected = "xpub6FDKNRvTTLzDmAdpNTc49ia9b4byd6vqCdUa46Fp3vqMcC96uBoufCmZXQLiN5AK3iSCJMhf9gT2sxkpyaPepRuA7W3MujV5tGmF5VfbueM"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + // check the derivation path of the first address + waitForGenerate(function() { + var actual = page.evaluate(function() { + return $(".extended-pub-key").val(); + }); + if (actual != expected) { + console.log("BIP44 extended public key is incorrect"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); +}); +}, + +// TODO finish these tests + // BIP44 purpose field changes address list // BIP44 coin field changes address list // BIP44 account field changes address list -- cgit v1.2.3 From 06286adb0f27d33ed72189c326aeff7142cb73db Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 23 Aug 2016 19:59:57 +1000 Subject: Test BIP44 purpose field --- tests.js | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/tests.js b/tests.js index 81c8504..435d5eb 100644 --- a/tests.js +++ b/tests.js @@ -573,7 +573,7 @@ page.open(url, function(status) { $(".phrase").val("abandon abandon ability"); $(".phrase").trigger("input"); }); - // check the derivation path of the first address + // check the BIP44 extended private key waitForGenerate(function() { var actual = page.evaluate(function() { return $(".extended-priv-key").val(); @@ -598,7 +598,7 @@ page.open(url, function(status) { $(".phrase").val("abandon abandon ability"); $(".phrase").trigger("input"); }); - // check the derivation path of the first address + // check the BIP44 extended public key waitForGenerate(function() { var actual = page.evaluate(function() { return $(".extended-pub-key").val(); @@ -614,9 +614,40 @@ page.open(url, function(status) { }); }, +// BIP44 purpose field changes address list +function() { +page.open(url, function(status) { + // set the phrase + var expected = "1JbDzRJ2cDT8aat2xwKd6Pb2zzavow5MhF"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + waitForGenerate(function() { + // change the bip44 purpose field to 45 + page.evaluate(function() { + $("#bip44 .purpose").val("45"); + $("#bip44 .purpose").trigger("input"); + }); + waitForGenerate(function() { + // check the address for the new derivation path + var actual = page.evaluate(function() { + return $(".address:first").text(); + }); + if (actual != expected) { + console.log("BIP44 purpose field generates incorrect address"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); + }); +}); +}, + // TODO finish these tests -// BIP44 purpose field changes address list // BIP44 coin field changes address list // BIP44 account field changes address list // BIP44 external/internal field changes address list -- cgit v1.2.3 From 9eb72cdfcf76cd6f8b57409f322e3c4e83ffdeec Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 23 Aug 2016 20:03:41 +1000 Subject: Test BIP44 coin field --- tests.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tests.js b/tests.js index 435d5eb..c6fa594 100644 --- a/tests.js +++ b/tests.js @@ -646,9 +646,38 @@ page.open(url, function(status) { }); }, -// TODO finish these tests - // BIP44 coin field changes address list +function() { +page.open(url, function(status) { + // set the phrase + var expected = "1F6dB2djQYrxoyfZZmfr6D5voH8GkJTghk"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + waitForGenerate(function() { + // change the bip44 purpose field to 45 + page.evaluate(function() { + $("#bip44 .coin").val("1"); + $("#bip44 .coin").trigger("input"); + }); + waitForGenerate(function() { + // check the address for the new derivation path + var actual = page.evaluate(function() { + return $(".address:first").text(); + }); + if (actual != expected) { + console.log("BIP44 coin field generates incorrect address"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); + }); +}); +}, + // BIP44 account field changes address list // BIP44 external/internal field changes address list -- cgit v1.2.3 From 048bc3e000567b0f54cbaaa8d4f6567051db2555 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 23 Aug 2016 20:03:52 +1000 Subject: Test BIP44 account field --- tests.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests.js b/tests.js index c6fa594..183411f 100644 --- a/tests.js +++ b/tests.js @@ -679,6 +679,39 @@ page.open(url, function(status) { }, // BIP44 account field changes address list +function() { +page.open(url, function(status) { + // set the phrase + var expected = "1Nq2Wmu726XHCuGhctEtGmhxo3wzk5wZ1H"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + waitForGenerate(function() { + // change the bip44 purpose field to 45 + page.evaluate(function() { + $("#bip44 .account").val("1"); + $("#bip44 .account").trigger("input"); + }); + waitForGenerate(function() { + // check the address for the new derivation path + var actual = page.evaluate(function() { + return $(".address:first").text(); + }); + if (actual != expected) { + console.log("BIP44 account field generates incorrect address"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); + }); +}); +}, + +// TODO finish these tests + // BIP44 external/internal field changes address list // BIP32 derivation path can be set -- cgit v1.2.3 From fa4da08668757f5f2ea6fb56011c2d048ab21429 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 23 Aug 2016 20:09:38 +1000 Subject: Test BIP44 change field --- tests.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/tests.js b/tests.js index 183411f..648b397 100644 --- a/tests.js +++ b/tests.js @@ -710,9 +710,39 @@ page.open(url, function(status) { }); }, -// TODO finish these tests +// BIP44 change field changes address list +function() { +page.open(url, function(status) { + // set the phrase + var expected = "1KAGfWgqfVbSSXY56fNQ7YnhyKuoskHtYo"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + waitForGenerate(function() { + // change the bip44 purpose field to 45 + page.evaluate(function() { + $("#bip44 .change").val("1"); + $("#bip44 .change").trigger("input"); + }); + waitForGenerate(function() { + // check the address for the new derivation path + var actual = page.evaluate(function() { + return $(".address:first").text(); + }); + if (actual != expected) { + console.log("BIP44 change field generates incorrect address"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); + }); +}); +}, -// BIP44 external/internal field changes address list +// TODO finish these tests // BIP32 derivation path can be set // BIP32 can use hardened derivation paths -- cgit v1.2.3 From 651382a376d7c70ae1bdc16e9d9fb8191d5cfec6 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Wed, 24 Aug 2016 15:26:38 +1000 Subject: Test custom BIP32 derivation path --- tests.js | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/tests.js b/tests.js index 648b397..1871163 100644 --- a/tests.js +++ b/tests.js @@ -742,10 +742,82 @@ page.open(url, function(status) { }); }, -// TODO finish these tests - // BIP32 derivation path can be set +function() { +page.open(url, function(status) { + // set the phrase + var expected = "16pYQQdLD1hH4hwTGLXBaZ9Teboi1AGL8L"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + // change tabs + waitForGenerate(function() { + page.evaluate(function() { + $("#bip32-tab a").click(); + }); + // set the derivation path to m/1 + waitForGenerate(function() { + page.evaluate(function() { + $("#bip32 .path").val("m/1"); + $("#bip32 .path").trigger("input"); + }); + // check the address is generated correctly + waitForGenerate(function() { + var actual = page.evaluate(function() { + return $(".address:first").text(); + }); + if (actual != expected) { + console.log("Custom BIP32 path generates incorrect address"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); + }); + }); +}); +}, + // BIP32 can use hardened derivation paths +function() { +page.open(url, function(status) { + // set the phrase + var expected = "14aXZeprXAE3UUKQc4ihvwBvww2LuEoHo4"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + // change tabs + waitForGenerate(function() { + page.evaluate(function() { + $("#bip32-tab a").click(); + }); + // set the derivation path to m/0' + waitForGenerate(function() { + page.evaluate(function() { + $("#bip32 .path").val("m/0'"); + $("#bip32 .path").trigger("input"); + }); + // check the address is generated correctly + waitForGenerate(function() { + var actual = page.evaluate(function() { + return $(".address:first").text(); + }); + if (actual != expected) { + console.log("Hardened BIP32 path generates incorrect address"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); + }); + }); +}); +}, + // BIP32 extended private key is shown // BIP32 extended public key is shown -- cgit v1.2.3 From 9e9dcfdaa38eeb1e7d19d6eedb8bfe1b18880f56 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Wed, 24 Aug 2016 15:45:25 +1000 Subject: Test extended priv/pub keys with BIP32 tab --- tests.js | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tests.js b/tests.js index 1871163..2c304f3 100644 --- a/tests.js +++ b/tests.js @@ -819,7 +819,66 @@ page.open(url, function(status) { }, // BIP32 extended private key is shown +function() { +page.open(url, function(status) { + // set the phrase + var expected = "xprv9va99uTVE5aLiutUVLTyfxfe8v8aaXjSQ1XxZbK6SezYVuikA9MnjQVTA8rQHpNA5LKvyQBpLiHbBQiiccKiBDs7eRmBogsvq3THFeLHYbe"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + // change tabs + waitForGenerate(function() { + page.evaluate(function() { + $("#bip32-tab a").click(); + }); + // check the extended private key is generated correctly + waitForGenerate(function() { + var actual = page.evaluate(function() { + return $(".extended-priv-key").val(); + }); + if (actual != expected) { + console.log("BIP32 extended private key is incorrect"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); + }); +}); +}, + // BIP32 extended public key is shown +function() { +page.open(url, function(status) { + // set the phrase + var expected = "xpub69ZVZQzP4T8dwPxwbMzz36cNgwy4yzTHmETZMyihzzXXNi3thgg3HCow1RtY252wdw5rS8369xKnraN5Q93y3FkFfJp2XEHWUrkyXsjS93P"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + // change tabs + waitForGenerate(function() { + page.evaluate(function() { + $("#bip32-tab a").click(); + }); + // check the extended public key is generated correctly + waitForGenerate(function() { + var actual = page.evaluate(function() { + return $(".extended-pub-key").val(); + }); + if (actual != expected) { + console.log("BIP32 extended public key is incorrect"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); + }); +}); +}, // Derivation path is shown in table // Derivation path for address can be hardened -- cgit v1.2.3 From 5f844c622fb0c133feb3472769c6ee5bd547c67b Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Wed, 24 Aug 2016 19:26:41 +1000 Subject: Test address table shows derivation path --- tests.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests.js b/tests.js index 2c304f3..83c99d9 100644 --- a/tests.js +++ b/tests.js @@ -881,6 +881,30 @@ page.open(url, function(status) { }, // Derivation path is shown in table +function() { +page.open(url, function(status) { + // set the phrase + var expected = "m/44'/0'/0'/0/0"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + // check for derivation path in table + waitForGenerate(function() { + var actual = page.evaluate(function() { + return $(".index:first").text(); + }); + if (actual != expected) { + console.log("Derivation path shown incorrectly in table"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); +}); +}, + // Derivation path for address can be hardened // Derivation path visibility can be toggled // Address is shown -- cgit v1.2.3 From 4974fd7f0024213a8b5af4ff569a2510e711e3b0 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Wed, 24 Aug 2016 19:49:24 +1000 Subject: Test hardened addresses --- tests.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests.js b/tests.js index 83c99d9..c9189a7 100644 --- a/tests.js +++ b/tests.js @@ -906,6 +906,43 @@ page.open(url, function(status) { }, // Derivation path for address can be hardened +function() { +page.open(url, function(status) { + // set the phrase + var expected = "18exLzUv7kfpiXRzmCjFDoC9qwNLFyvwyd"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + // change tabs + waitForGenerate(function() { + page.evaluate(function() { + $("#bip32-tab a").click(); + }); + waitForGenerate(function() { + // select the hardened addresses option + page.evaluate(function() { + $(".hardened-addresses").prop("checked", true); + $(".hardened-addresses").trigger("change"); + }); + waitForGenerate(function() { + // check the generated address is hardened + var actual = page.evaluate(function() { + return $(".address:first").text(); + }); + if (actual != expected) { + console.log("Hardened address is incorrect"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); + }); + }); +}); +}, + // Derivation path visibility can be toggled // Address is shown // Addresses are shown in order of derivation path -- cgit v1.2.3 From a775b5c66d26e4c57b3d2bb9515e31c6ecd187a8 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Wed, 24 Aug 2016 20:04:23 +1000 Subject: Test toggling derivation path --- tests.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests.js b/tests.js index c9189a7..bb3c4fc 100644 --- a/tests.js +++ b/tests.js @@ -944,6 +944,32 @@ page.open(url, function(status) { }, // Derivation path visibility can be toggled +function() { +page.open(url, function(status) { + // set the phrase + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + // check the path is not shown + waitForGenerate(function() { + // toggle path visibility + page.evaluate(function() { + $(".index-toggle").click(); + }); + // check the path is not visible + var isInvisible = page.evaluate(function() { + return $(".index:first span").hasClass("invisible"); + }); + if (!isInvisible) { + console.log("Toggled derivation path is visible"); + fail(); + } + next(); + }); +}); +}, + // Address is shown // Addresses are shown in order of derivation path // Address visibility can be toggled -- cgit v1.2.3 From 06c4c6e31411158c1e9ff1943f12886991005120 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Wed, 24 Aug 2016 20:18:05 +1000 Subject: Test table shows addresses --- tests.js | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/tests.js b/tests.js index bb3c4fc..9889e0b 100644 --- a/tests.js +++ b/tests.js @@ -101,18 +101,17 @@ page.open(url, function(status) { // Entering mnemonic generates addresses function() { page.open(url, function(status) { - var expected = "1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug"; // set the phrase page.evaluate(function() { $(".phrase").val("abandon abandon ability").trigger("input"); }); // get the address waitForGenerate(function() { - var actual = page.evaluate(function() { - return $(".address:first").text(); + var addressCount = page.evaluate(function() { + return $(".address").length; }); - if (actual != expected) { - console.log("Mnemonic did not generate address"); + if (addressCount != 20) { + console.log("Mnemonic did not generate addresses"); console.log("Expected: " + expected); console.log("Got: " + actual); fail(); @@ -971,6 +970,29 @@ page.open(url, function(status) { }, // Address is shown +function() { +page.open(url, function(status) { + var expected = "1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug"; + // set the phrase + page.evaluate(function() { + $(".phrase").val("abandon abandon ability").trigger("input"); + }); + // get the address + waitForGenerate(function() { + var actual = page.evaluate(function() { + return $(".address:first").text(); + }); + if (actual != expected) { + console.log("Address is not shown"); + console.log("Expected: " + expected); + console.log("Got: " + actual); + fail(); + } + next(); + }); +}); +}, + // Addresses are shown in order of derivation path // Address visibility can be toggled // Private key is shown -- cgit v1.2.3 From f3fad1b5a7f4155ea3762fa71ff5d682466eaa90 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Thu, 25 Aug 2016 08:07:25 +1000 Subject: Test for DASH coin --- tests.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests.js b/tests.js index 9889e0b..5531753 100644 --- a/tests.js +++ b/tests.js @@ -457,6 +457,34 @@ page.open(url, function(status) { }); }, +// Network can be set to dash +function() { +page.open(url, function(status) { + // set the phrase and coin + var expected = "XdbhtMuGsPSkE6bPdNTHoFSszQKmK4S5LT"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + $(".network option[selected]").removeAttr("selected"); + $(".network option[value=10]").prop("selected", true); + $(".network").trigger("change"); + }); + // check the address is generated correctly + waitForGenerate(function() { + var actual = page.evaluate(function() { + return $(".address:first").text(); + }); + if (actual != expected) { + console.log("DASH address is incorrect"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); +}); +}, + // BIP39 seed is set from phrase function() { page.open(url, function(status) { -- cgit v1.2.3 From f3d0aca14ba96f305eda5ae9ef3b49f16cd6c5bb Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Thu, 25 Aug 2016 08:09:58 +1000 Subject: Test placeholder for github issue 26 --- tests.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests.js b/tests.js index 5531753..47938a4 100644 --- a/tests.js +++ b/tests.js @@ -1053,6 +1053,9 @@ page.open(url, function(status) { // Github Issue 23: Use correct derivation path when changing tabs // https://github.com/dcpos/bip39/issues/23 +// Github Issue 26: When using a Root key derrived altcoins are incorrect +// https://github.com/dcpos/bip39/issues/26 + ]; console.log("Running tests..."); -- cgit v1.2.3