]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blobdiff - tests.js
update root key network
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / tests.js
index 12b779ee723dab8af30e07cb00dea968e3db80cb..f5ce6d3d64c26a7cdfbc16690d30891557848b53 100644 (file)
--- a/tests.js
+++ b/tests.js
@@ -111,9 +111,10 @@ page.open(url, function(status) {
 function() {
 page.open(url, function(status) {
     // set the length to 6
-    var expectedLength = 6;
+    var expectedLength = "6";
     page.evaluate(function() {
-        $(".strength").val(expectedLength);
+        $(".strength option[selected]").removeAttr("selected");
+        $(".strength option[value=6]").prop("selected", true);
     });
     // press the 'generate' button
     page.evaluate(function() {
@@ -131,25 +132,339 @@ page.open(url, function(status) {
             console.log("Actual: " + actualLength);
             fail();
         }
-    }, 200);
-    next();
+        next();
+    }, 1000);
 });
 },
 
-// TODO finish these tests
-
 // Passphrase can be set
+function() {
+page.open(url, function(status) {
+    // set the phrase and passphrase
+    var expected = "15pJzUWPGzR7avffV9nY5by4PSgSKG9rba";
+    page.evaluate(function() {
+        $(".phrase").val("abandon abandon ability");
+        $(".passphrase").val("secure_passphrase").trigger("input");
+    });
+    // check the address is generated correctly
+    setTimeout(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();
+    }, 1000);
+});
+},
+
 // Network can be set to bitcoin testnet
+function() {
+page.open(url, function(status) {
+    // set the phrase and coin
+    var expected = "mucaU5iiDaJDb69BHLeDv8JFfGiyg2nJKi";
+    page.evaluate(function() {
+        $(".phrase").val("abandon abandon ability");
+        $(".phrase").trigger("input");
+        $(".network option[selected]").removeAttr("selected");
+        $(".network option[value=1]").prop("selected", true);
+        $(".network").trigger("change");
+    });
+    // check the address is generated correctly
+    setTimeout(function() {
+        var actual = page.evaluate(function() {
+            return $(".address:first").text();
+        });
+        if (actual != expected) {
+            console.log("Bitcoin testnet address is incorrect");
+            console.log("Expected: " + expected);
+            console.log("Actual: " + actual);
+            fail();
+        }
+        next();
+    }, 1000);
+});
+},
+
 // Network can be set to litecoin
+function() {
+page.open(url, function(status) {
+    // set the phrase and coin
+    var expected = "LQ4XU8RX2ULPmPq9FcUHdVmPVchP9nwXdn";
+    page.evaluate(function() {
+        $(".phrase").val("abandon abandon ability");
+        $(".phrase").trigger("input");
+        $(".network option[selected]").removeAttr("selected");
+        $(".network option[value=2]").prop("selected", true);
+        $(".network").trigger("change");
+    });
+    // check the address is generated correctly
+    setTimeout(function() {
+        var actual = page.evaluate(function() {
+            return $(".address:first").text();
+        });
+        if (actual != expected) {
+            console.log("Litecoin address is incorrect");
+            console.log("Expected: " + expected);
+            console.log("Actual: " + actual);
+            fail();
+        }
+        next();
+    }, 1000);
+});
+},
+
 // Network can be set to dogecoin
+function() {
+page.open(url, function(status) {
+    // set the phrase and coin
+    var expected = "DPQH2AtuzkVSG6ovjKk4jbUmZ6iXLpgbJA";
+    page.evaluate(function() {
+        $(".phrase").val("abandon abandon ability");
+        $(".phrase").trigger("input");
+        $(".network option[selected]").removeAttr("selected");
+        $(".network option[value=3]").prop("selected", true);
+        $(".network").trigger("change");
+    });
+    // check the address is generated correctly
+    setTimeout(function() {
+        var actual = page.evaluate(function() {
+            return $(".address:first").text();
+        });
+        if (actual != expected) {
+            console.log("Dogecoin address is incorrect");
+            console.log("Expected: " + expected);
+            console.log("Actual: " + actual);
+            fail();
+        }
+        next();
+    }, 1000);
+});
+},
+
 // Network can be set to shadowcash
+function() {
+page.open(url, function(status) {
+    // set the phrase and coin
+    var expected = "SiSZtfYAXEFvMm3XM8hmtkGDyViRwErtCG";
+    page.evaluate(function() {
+        $(".phrase").val("abandon abandon ability");
+        $(".phrase").trigger("input");
+        $(".network option[selected]").removeAttr("selected");
+        $(".network option[value=4]").prop("selected", true);
+        $(".network").trigger("change");
+    });
+    // check the address is generated correctly
+    setTimeout(function() {
+        var actual = page.evaluate(function() {
+            return $(".address:first").text();
+        });
+        if (actual != expected) {
+            console.log("Shadowcash address is incorrect");
+            console.log("Expected: " + expected);
+            console.log("Actual: " + actual);
+            fail();
+        }
+        next();
+    }, 1000);
+});
+},
+
 // Network can be set to shadowcash testnet
+function() {
+page.open(url, function(status) {
+    // set the phrase and coin
+    var expected = "tM2EDpVKaTiEg2NZg3yKg8eqjLr55BErHe";
+    page.evaluate(function() {
+        $(".phrase").val("abandon abandon ability");
+        $(".phrase").trigger("input");
+        $(".network option[selected]").removeAttr("selected");
+        $(".network option[value=5]").prop("selected", true);
+        $(".network").trigger("change");
+    });
+    // check the address is generated correctly
+    setTimeout(function() {
+        var actual = page.evaluate(function() {
+            return $(".address:first").text();
+        });
+        if (actual != expected) {
+            console.log("Shadowcash testnet address is incorrect");
+            console.log("Expected: " + expected);
+            console.log("Actual: " + actual);
+            fail();
+        }
+        next();
+    }, 1000);
+});
+},
+
 // Network can be set to viacoin
+function() {
+page.open(url, function(status) {
+    // set the phrase and coin
+    var expected = "Vq9Eq4N5SQnjqZvxtxzo7hZPW5XnyJsmXT";
+    page.evaluate(function() {
+        $(".phrase").val("abandon abandon ability");
+        $(".phrase").trigger("input");
+        $(".network option[selected]").removeAttr("selected");
+        $(".network option[value=6]").prop("selected", true);
+        $(".network").trigger("change");
+    });
+    // check the address is generated correctly
+    setTimeout(function() {
+        var actual = page.evaluate(function() {
+            return $(".address:first").text();
+        });
+        if (actual != expected) {
+            console.log("Viacoin address is incorrect");
+            console.log("Expected: " + expected);
+            console.log("Actual: " + actual);
+            fail();
+        }
+        next();
+    }, 1000);
+});
+},
+
 // Network can be set to viacoin testnet
+function() {
+page.open(url, function(status) {
+    // set the phrase and coin
+    var expected = "tM2EDpVKaTiEg2NZg3yKg8eqjLr55BErHe";
+    page.evaluate(function() {
+        $(".phrase").val("abandon abandon ability");
+        $(".phrase").trigger("input");
+        $(".network option[selected]").removeAttr("selected");
+        $(".network option[value=7]").prop("selected", true);
+        $(".network").trigger("change");
+    });
+    // check the address is generated correctly
+    setTimeout(function() {
+        var actual = page.evaluate(function() {
+            return $(".address:first").text();
+        });
+        if (actual != expected) {
+            console.log("Viacoin testnet address is incorrect");
+            console.log("Expected: " + expected);
+            console.log("Actual: " + actual);
+            fail();
+        }
+        next();
+    }, 1000);
+});
+},
+
 // Network can be set to jumbucks
+function() {
+page.open(url, function(status) {
+    // set the phrase and coin
+    var expected = "JLEXccwDXADK4RxBPkRez7mqsHVoJBEUew";
+    page.evaluate(function() {
+        $(".phrase").val("abandon abandon ability");
+        $(".phrase").trigger("input");
+        $(".network option[selected]").removeAttr("selected");
+        $(".network option[value=8]").prop("selected", true);
+        $(".network").trigger("change");
+    });
+    // check the address is generated correctly
+    setTimeout(function() {
+        var actual = page.evaluate(function() {
+            return $(".address:first").text();
+        });
+        if (actual != expected) {
+            console.log("Jumbucks address is incorrect");
+            console.log("Expected: " + expected);
+            console.log("Actual: " + actual);
+            fail();
+        }
+        next();
+    }, 1000);
+});
+},
+
 // Network can be set to clam
+function() {
+page.open(url, function(status) {
+    // set the phrase and coin
+    var expected = "xCp4sakjVx4pUAZ6cBCtuin8Ddb6U1sk9y";
+    page.evaluate(function() {
+        $(".phrase").val("abandon abandon ability");
+        $(".phrase").trigger("input");
+        $(".network option[selected]").removeAttr("selected");
+        $(".network option[value=9]").prop("selected", true);
+        $(".network").trigger("change");
+    });
+    // check the address is generated correctly
+    setTimeout(function() {
+        var actual = page.evaluate(function() {
+            return $(".address:first").text();
+        });
+        if (actual != expected) {
+            console.log("CLAM address is incorrect");
+            console.log("Expected: " + expected);
+            console.log("Actual: " + actual);
+            fail();
+        }
+        next();
+    }, 1000);
+});
+},
+
 // BIP39 seed is set from phrase
+function() {
+page.open(url, function(status) {
+    // set the phrase
+    var expected = "20da140d3dd1df8713cefcc4d54ce0e445b4151027a1ab567b832f6da5fcc5afc1c3a3f199ab78b8e0ab4652efd7f414ac2c9a3b81bceb879a70f377aa0a58f3";
+    page.evaluate(function() {
+        $(".phrase").val("abandon abandon ability");
+        $(".phrase").trigger("input");
+    });
+    // check the address is generated correctly
+    setTimeout(function() {
+        var actual = page.evaluate(function() {
+            return $(".seed").val();
+        });
+        if (actual != expected) {
+            console.log("BIP39 seed is incorrectly generated from mnemonic");
+            console.log("Expected: " + expected);
+            console.log("Actual: " + actual);
+            fail();
+        }
+        next();
+    }, 1000);
+});
+},
+
 // BIP32 root key is set from phrase
+function() {
+page.open(url, function(status) {
+    // set the phrase
+    var expected = "xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi";
+    page.evaluate(function() {
+        $(".phrase").val("abandon abandon ability");
+        $(".phrase").trigger("input");
+    });
+    // check the address is generated correctly
+    setTimeout(function() {
+        var actual = page.evaluate(function() {
+            return $(".root-key").val();
+        });
+        if (actual != expected) {
+            console.log("Root key is incorrectly generated from mnemonic");
+            console.log("Expected: " + expected);
+            console.log("Actual: " + actual);
+            fail();
+        }
+        next();
+    }, 1000);
+});
+},
+
+// TODO finish these tests
 
 // Tabs show correct addresses when changed
 
@@ -180,7 +495,8 @@ page.open(url, function(status) {
 // Additional addresses are shown in order of derivation path
 
 // BIP32 root key can be set by the user
-// Setting BIP32 clears the existing phrase, passphrase and seed
+// 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
 
 // Incorrect mnemonic shows error