]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blobdiff - tests/spec/tests.js
Fix tests for altcoins
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / tests / spec / tests.js
index 034b50fc805e5407ff0d547c636415b5b2da68d3..b81294b64a532bf0a59d0db958b17a30d26cf539 100644 (file)
@@ -553,7 +553,7 @@ it('Allows selection of slimcoin testnet', function(done) {
 it('Allows selection of bitcoin cash', function(done) {
     var params = {
         selectText: "BCH - Bitcoin Cash",
-        firstAddress: "1JKvb6wKtsjNoCRxpZ4DGrbniML7z5U16A",
+        firstAddress: "bitcoincash:qzlquk7w4hkudxypl4fgv8x279r754dkvur7jpcsps",
     };
     testNetwork(done, params);
 });
@@ -616,7 +616,7 @@ it('Allows selection of monacoin', function(done) {
 it('Allows selection of AXE', function(done) {
     var params = {
         selectText: "AXE - Axe",
-        firstAddress: "XQ4HLxUVS3egk5ff1o9e2vJFJKSSsUH3B7",
+        firstAddress: "PScwtLUyPiGrqtKXrHF37DGETLXLZdw4up",
     };
     testNetwork(done, params);
 });
@@ -690,6 +690,20 @@ it('Allows selection of Bitcoinplus', function(done) {
     };
     testNetwork(done, params);
 });
+it('Allows selection of Bitcoin Private', function(done) {
+    var params = {
+        selectText: "BTCP - Bitcoin Private",
+        firstAddress: "b1M3PbiXXyN6Hdivdw5rJv5VKpLjPzhm4jM",
+    };
+    testNetwork(done, params);
+});
+it('Allows selection of Bitcoinz', function(done) {
+    var params = {
+        selectText: "BTCZ - Bitcoinz",
+        firstAddress: "t1X2YQoxs8cYRo2oaBYgVEwW5QNjCC59NYc",
+    };
+    testNetwork(done, params);
+});
 it('Allows selection of Bitcore', function(done) {
     var params = {
         selectText: "BTX - Bitcore",
@@ -900,6 +914,13 @@ it('Allows selection of Ixcoin', function(done) {
     };
     testNetwork(done, params);
 });
+it('Allows selection of Kobocoin', function(done) {
+    var params = {
+        selectText: "KOBO - Kobocoin",
+        firstAddress: "FTVoNJETXDAM8x7MnmdE8RwWndSr9PQWhy",
+    };
+    testNetwork(done, params);
+});
 it('Allows selection of Landcoin', function(done) {
     var params = {
         selectText: "LDCN - Landcoin",
@@ -1036,7 +1057,7 @@ it('Allows selection of Putincoin', function(done) {
 it('Allows selection of Reddcoin', function(done) {
     var params = {
         selectText: "RDD - Reddcoin",
-        firstAddress: "1M4druAcUfkXBaAcQ4cCgCLPHChiaib6kL",
+        firstAddress: "RtgRvXMBng1y51ftteveFqwNfyRG18HpxQ",
     };
     testNetwork(done, params);
 });
@@ -1159,6 +1180,34 @@ it('Allows selection of Zcoin', function(done) {
     };
     testNetwork(done, params);
 });
+it('Allows selection of Zcash', function(done) {
+    var params = {
+        selectText: "ZEC - Zcash",
+        firstAddress: "t1Sz8AneMcVuzUg3tPJ8et5AS5LFJ7K2EF9",
+    };
+    testNetwork(done, params);
+});
+it('Allows selection of Zclassic', function(done) {
+    var params = {
+        selectText: "ZCL - Zclassic",
+        firstAddress: "t1TBMxTvVJRybUbMLGWq8H4A8F4VUL7czEc",
+    };
+    testNetwork(done, params);
+});
+it('Allows selection of Zencash', function(done) {
+    var params = {
+        selectText: "ZEN - Zencash",
+        firstAddress: "znWh9XASyW2dZq5tck84wFjiwuqVysi7q3p",
+    };
+    testNetwork(done, params);
+});
+it('Allows selection of Energi', function(done) {
+    var params = {
+        selectText: "NRG - Energi",
+        firstAddress: "EejRy4t4nidzhGGzkJUgFP3z4HYBjhTsRt",
+    };
+    testNetwork(done, params);
+});
 
 
 // BIP39 seed is set from phrase
@@ -3106,10 +3155,26 @@ it('Warns when entropy is filtered and discarded', function(done) {
     });
 });
 
+// Bitcoin Cash address can be set to use cashaddr format
+it('Can use cashaddr format for bitcoin cash addresses', function(done) {
+    driver.executeScript(function() {
+        $(".use-bch-cashaddr-addresses").prop("checked", true);
+    });
+    driver.findElement(By.css('.phrase'))
+        .sendKeys("abandon abandon ability");
+    selectNetwork("BCH - Bitcoin Cash");
+    driver.sleep(generateDelay).then(function() {
+        getFirstAddress(function(address) {
+            expect(address).toBe("bitcoincash:qzlquk7w4hkudxypl4fgv8x279r754dkvur7jpcsps");
+            done();
+        });
+    });
+});
+
 // Bitcoin Cash address can be set to use bitpay format
 it('Can use bitpay format for bitcoin cash addresses', function(done) {
     driver.executeScript(function() {
-        $(".use-bitpay-addresses").prop("checked", true);
+        $(".use-bch-bitpay-addresses").prop("checked", true);
     });
     driver.findElement(By.css('.phrase'))
         .sendKeys("abandon abandon ability");
@@ -3122,6 +3187,22 @@ it('Can use bitpay format for bitcoin cash addresses', function(done) {
     });
 });
 
+// Bitcoin Cash address can be set to use legacy format
+it('Can use legacy format for bitcoin cash addresses', function(done) {
+    driver.executeScript(function() {
+        $(".use-bch-legacy-addresses").prop("checked", true);
+    });
+    driver.findElement(By.css('.phrase'))
+        .sendKeys("abandon abandon ability");
+    selectNetwork("BCH - Bitcoin Cash");
+    driver.sleep(generateDelay).then(function() {
+        getFirstAddress(function(address) {
+            expect(address).toBe("1JKvb6wKtsjNoCRxpZ4DGrbniML7z5U16A");
+            done();
+        });
+    });
+});
+
 // End of tests ported from old suit, so no more comments above each test now
 
 it('Can generate more addresses from a custom index', function(done) {
@@ -3562,4 +3643,61 @@ it('Does not show a warning if entropy is stronger than mnemonic length', functi
         });
 });
 
+it('Shows a warning for litecoin BIP84 (which does not have p2wpkh params)', function(done) {
+    driver.findElement(By.css('.phrase'))
+        .sendKeys('abandon abandon ability');
+    selectNetwork("LTC - Litecoin");
+    driver.findElement(By.css('#bip84-tab a'))
+        .click()
+    // bip84 unavailable is shown
+    driver.sleep(feedbackDelay).then(function() {
+        driver.findElement(By.css('#bip84 .unavailable'))
+            .getAttribute("class")
+            .then(function(classes) {
+                expect(classes).not.toContain("hidden");
+                done();
+            });
+    });
+});
+
+it('Shows litecoin BIP49 addresses', function(done) {
+    driver.findElement(By.css('.phrase'))
+        .sendKeys('abandon abandon ability');
+    selectNetwork("LTC - Litecoin");
+    driver.findElement(By.css('#bip49-tab a'))
+        .click()
+    // bip49 addresses are shown
+    driver.sleep(generateDelay).then(function() {
+        driver.findElement(By.css('#bip49 .available'))
+            .getAttribute("class")
+            .then(function(classes) {
+                expect(classes).not.toContain("hidden");
+                // check first address
+                getFirstAddress(function(address) {
+                    expect(address).toBe("MFwLPhsXoBuSLL8cLmW9uK6tChkzduV8qN");
+                    done();
+                });
+            });
+    });
+});
+
+it('Can use root keys to generate segwit table rows', function(done) {
+    // segwit uses ypub / zpub instead of xpub but the root key should still
+    // be valid regardless of the encoding used to import that key.
+    // Maybe this breaks the reason for the different extended key prefixes, but
+    // since the parsed root key is used behind the scenes anyhow this should be
+    // allowed.
+    driver.findElement(By.css('#root-key'))
+        .sendKeys('xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi');
+    driver.findElement(By.css('#bip49-tab a'))
+        .click()
+    // bip49 addresses are shown
+    driver.sleep(generateDelay).then(function() {
+        getFirstAddress(function(address) {
+            expect(address).toBe("3QG2Y9AA4xZ846gKHZqNf7mvVKbLqMKxr2");
+            done();
+        });
+    });
+});
+
 });