]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blobdiff - tests.js
Test additional addresses ordering
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / tests.js
index 0c28ec8a68ff34a08f22233fb33a691b9b335739..2800e6cf073b4ee6cc0f8a1dbcac9480eed55f63 100644 (file)
--- a/tests.js
+++ b/tests.js
@@ -1214,7 +1214,81 @@ page.open(url, function(status) {
 },
 
 // 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
 // Setting BIP32 root key clears the existing phrase, passphrase and seed