// 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();
});
},
+// 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();
+ });
+});
+},
+
+// Network can be set to namecoin
+function() {
+page.open(url, function(status) {
+ // set the phrase and coin
+ var expected = "Mw2vK2Bvex1yYtYF6sfbEg2YGoUc98YUD2";
+ page.evaluate(function() {
+ $(".phrase").val("abandon abandon ability");
+ $(".phrase").trigger("input");
+ $(".network option[selected]").removeAttr("selected");
+ $(".network option[value=11]").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("Namecoin address is incorrect");
+ console.log("Expected: " + expected);
+ console.log("Actual: " + actual);
+ fail();
+ }
+ next();
+ });
+});
+},
+
+// Network can be set to peercoin
+function() {
+page.open(url, function(status) {
+ // set the phrase and coin
+ var expected = "PVAiioTaK2eDHSEo3tppT9AVdBYqxRTBAm";
+ page.evaluate(function() {
+ $(".phrase").val("abandon abandon ability");
+ $(".phrase").trigger("input");
+ $(".network option[selected]").removeAttr("selected");
+ $(".network option[value=12]").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("Peercoin 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) {
},
// 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");
+ });
+ 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
+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
+function() {
+page.open(url, function(status) {
+ // set the phrase
+ page.evaluate(function() {
+ $(".phrase").val("abandon abandon ability").trigger("input");
+ });
+ // get the derivation paths
+ waitForGenerate(function() {
+ var paths = page.evaluate(function() {
+ return $(".index").map(function(i, e) {
+ return $(e).text();
+ });
+ });
+ if (paths.length != 20) {
+ console.log("Total paths is less than expected: " + paths.length);
+ fail();
+ }
+ for (var i=0; i<paths.length; i++) {
+ var expected = "m/44'/0'/0'/0/" + i;
+ var actual = paths[i];
+ if (actual != expected) {
+ console.log("Path " + i + " is incorrect");
+ console.log("Expected: " + expected);
+ console.log("Actual: " + actual);
+ fail();
+ }
+ }
+ next();
+ });
+});
+},
+
// Address visibility can be toggled
+function() {
+page.open(url, function(status) {
+ // set the phrase
+ page.evaluate(function() {
+ $(".phrase").val("abandon abandon ability");
+ $(".phrase").trigger("input");
+ });
+ waitForGenerate(function() {
+ // toggle address visibility
+ page.evaluate(function() {
+ $(".address-toggle").click();
+ });
+ // check the address is not visible
+ var isInvisible = page.evaluate(function() {
+ return $(".address:first span").hasClass("invisible");
+ });
+ if (!isInvisible) {
+ console.log("Toggled address is visible");
+ fail();
+ }
+ next();
+ });
+});
+},
+
// Private key is shown
+function() {
+page.open(url, function(status) {
+ var expected = "L26cVSpWFkJ6aQkPkKmTzLqTdLJ923e6CzrVh9cmx21QHsoUmrEE";
+ // set the phrase
+ page.evaluate(function() {
+ $(".phrase").val("abandon abandon ability").trigger("input");
+ });
+ // get the address
+ waitForGenerate(function() {
+ var actual = page.evaluate(function() {
+ return $(".privkey:first").text();
+ });
+ if (actual != expected) {
+ console.log("Private key is not shown");
+ console.log("Expected: " + expected);
+ console.log("Got: " + actual);
+ fail();
+ }
+ next();
+ });
+});
+},
+
// Private key visibility can be toggled
+function() {
+page.open(url, function(status) {
+ // set the phrase
+ page.evaluate(function() {
+ $(".phrase").val("abandon abandon ability");
+ $(".phrase").trigger("input");
+ });
+ waitForGenerate(function() {
+ // toggle private key visibility
+ page.evaluate(function() {
+ $(".private-key-toggle").click();
+ });
+ // check the private key is not visible
+ var isInvisible = page.evaluate(function() {
+ return $(".privkey:first span").hasClass("invisible");
+ });
+ if (!isInvisible) {
+ console.log("Toggled private key is visible");
+ fail();
+ }
+ next();
+ });
+});
+},
// More addresses can be generated
+function() {
+page.open(url, function(status) {
+ // set the phrase
+ page.evaluate(function() {
+ $(".phrase").val("abandon abandon ability");
+ $(".phrase").trigger("input");
+ });
+ waitForGenerate(function() {
+ // generate more addresses
+ page.evaluate(function() {
+ $(".more").click();
+ });
+ waitForGenerate(function() {
+ // check there are more addresses
+ var addressCount = page.evaluate(function() {
+ return $(".address").length;
+ });
+ if (addressCount != 40) {
+ console.log("More addresses cannot be generated");
+ fail();
+ }
+ next();
+ });
+ });
+});
+},
+
// A custom number of additional addresses can be generated
+function() {
+page.open(url, function(status) {
+ // set the phrase
+ page.evaluate(function() {
+ $(".phrase").val("abandon abandon ability");
+ $(".phrase").trigger("input");
+ });
+ waitForGenerate(function() {
+ // get the current number of addresses
+ var oldAddressCount = page.evaluate(function() {
+ return $(".address").length;
+ });
+ // set a custom number of additional addresses
+ page.evaluate(function() {
+ $(".rows-to-add").val(1);
+ });
+ // generate more addresses
+ page.evaluate(function() {
+ $(".more").click();
+ });
+ waitForGenerate(function() {
+ // check there are the correct number of addresses
+ var newAddressCount = page.evaluate(function() {
+ return $(".address").length;
+ });
+ if (newAddressCount - oldAddressCount != 1) {
+ console.log("Number of additional addresses cannot be customized");
+ console.log(newAddressCount)
+ console.log(oldAddressCount)
+ fail();
+ }
+ next();
+ });
+ });
+});
+},
+
// Additional addresses are shown in order of derivation path
+function() {
+page.open(url, function(status) {
+ // set the phrase
+ page.evaluate(function() {
+ $(".phrase").val("abandon abandon ability").trigger("input");
+ });
+ waitForGenerate(function() {
+ // generate more addresses
+ page.evaluate(function() {
+ $(".more").click();
+ });
+ // get the derivation paths
+ waitForGenerate(function() {
+ var paths = page.evaluate(function() {
+ return $(".index").map(function(i, e) {
+ return $(e).text();
+ });
+ });
+ if (paths.length != 40) {
+ console.log("Total additional paths is less than expected: " + paths.length);
+ fail();
+ }
+ for (var i=0; i<paths.length; i++) {
+ var expected = "m/44'/0'/0'/0/" + i;
+ var actual = paths[i];
+ if (actual != expected) {
+ console.log("Path " + i + " is not in correct order");
+ console.log("Expected: " + expected);
+ console.log("Actual: " + actual);
+ fail();
+ }
+ }
+ next();
+ });
+ });
+});
+},
// BIP32 root key can be set by the user
+function() {
+page.open(url, function(status) {
+ var expected = "1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug";
+ // set the root key
+ page.evaluate(function() {
+ $(".root-key").val("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi").trigger("input");
+ });
+ waitForGenerate(function() {
+ var actual = page.evaluate(function() {
+ return $(".address:first").text();
+ });
+ if (actual != expected) {
+ console.log("Passphrase results in wrong address");
+ console.log("Expected: " + expected);
+ console.log("Actual: " + actual);
+ fail();
+ }
+ next();
+ });
+});
+},
+
// Setting BIP32 root key clears the existing phrase, passphrase and seed
// Clearing of phrase, passphrase and seed can be cancelled by user
// Custom BIP32 root key is used when changing the derivation path
// 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...");