]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
Test custom BIP32 derivation path
authorIan Coleman <coleman.ian@gmail.com>
Wed, 24 Aug 2016 05:26:38 +0000 (15:26 +1000)
committerIan Coleman <coleman.ian@gmail.com>
Wed, 24 Aug 2016 05:40:58 +0000 (15:40 +1000)
tests.js

index 648b3974f07c221e973cb73d2974e800ba3d351f..1871163a5de32e958a08417faf5792a2123d4fcb 100644 (file)
--- 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