]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blobdiff - tests/spec/tests.js
Add test for Beetlecoin
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / tests / spec / tests.js
index 07b7b1aba31dd03099c001c9c1ffb2b4d0fef33d..80add739b978ad652968fcd1080c0fe17306c7bc 100644 (file)
@@ -30,9 +30,10 @@ var until = webdriver.until;
 var newDriver = null;
 var driver = null;
 // Delays in ms
-var generateDelay = 1000;
+var generateDelay = 1500;
 var feedbackDelay = 500;
 var entropyFeedbackDelay = 500;
+var bip38delay = 15000;
 
 // url uses file:// scheme
 var path = require('path')
@@ -422,6 +423,13 @@ it('Allows selection of dogecoin', function(done) {
     };
     testNetwork(done, params);
 });
+it('Allows selection of denarius', function(done) {
+    var params = {
+        selectText: "DNR - Denarius",
+        firstAddress: "DFdFMVUMzU9xX88EywXvAGwjiwpxyh9vKb",
+    };
+    testNetwork(done, params);
+});
 it('Allows selection of shadowcash', function(done) {
     var params = {
         selectText: "SDC - ShadowCash",
@@ -495,7 +503,7 @@ it('Allows selection of game', function(done) {
 it('Allows selection of komodo', function(done) {
     var params = {
         selectText: "KMD - Komodo",
-        firstAddress: "RJL777dmaB3PYqHEJGMJKWWkLPdu1ypGi4",
+        firstAddress: "RMPPzJwAjPVZZAwJvXivHJGGjdCx6WBD2t",
     };
     testNetwork(done, params);
 });
@@ -594,7 +602,7 @@ it('Allows selection of nubits', function(done) {
 it('Allows selection of bitcoin gold', function(done) {
     var params = {
         selectText: "BTG - Bitcoin Gold",
-        firstAddress: "GWYxuwSqANWGV3WT7Gpr6HE91euYXBqtwQ",
+        firstAddress: "GdDqug4WUsn5syNbSTHatNn4XnuwZtzedx",
     };
     testNetwork(done, params);
 });
@@ -605,6 +613,34 @@ it('Allows selection of monacoin', function(done) {
     };
     testNetwork(done, params);
 });
+it('Allows selection of AXE', function(done) {
+    var params = {
+        selectText: "AXE - Axe",
+        firstAddress: "XQ4HLxUVS3egk5ff1o9e2vJFJKSSsUH3B7",
+    };
+    testNetwork(done, params);
+});
+it('Allows selection of BlackCoin', function(done) {
+    var params = {
+        selectText: "BLK - BlackCoin",
+        firstAddress: "B5MznAKwj7uQ42vDz3w4onhBXPcqhTwJ9z",
+    };
+    testNetwork(done, params);
+});
+it('Allows selection of Neblio', function(done) {
+    var params = {
+        selectText: "NEBL - Neblio",
+        firstAddress: "NefkeEEvhusbHMmTRrxx7H9wFnUXd8qQsE",
+    };
+    testNetwork(done, params);
+});
+it('Allows selection of Beetlecoin', function(done) {
+    var params = {
+        selectText: "BEET - Beetlecoin",
+        firstAddress: "BVmtbEsGrjpknprmpHFq26z4kYHJUFHE71",
+    };
+    testNetwork(done, params);
+});
 
 // BIP39 seed is set from phrase
 it('Sets the bip39 seed from the prhase', function(done) {
@@ -933,13 +969,13 @@ it('Can generate more rows in the table', function(done) {
 
 // A custom number of additional addresses can be generated
 it('Can generate more rows in the table', function(done) {
-    driver.findElement(By.css('.rows-to-add'))
-        .clear();
-    driver.findElement(By.css('.rows-to-add'))
-        .sendKeys('1');
     driver.findElement(By.css('.phrase'))
         .sendKeys('abandon abandon ability');
     driver.sleep(generateDelay).then(function() {
+        driver.findElement(By.css('.rows-to-add'))
+            .clear();
+        driver.findElement(By.css('.rows-to-add'))
+            .sendKeys('1');
         driver.findElement(By.css('.more'))
             .click();
         driver.sleep(generateDelay).then(function() {
@@ -2159,10 +2195,11 @@ it('Can change details while old addresses are still being generated', function(
     driver.findElement(By.css('.phrase'))
         .sendKeys("abandon abandon ability");
     driver.sleep(generateDelay).then(function() {
-        // generate more addresses
-        driver.findElement(By.css('.more'))
-            .click();
         // change tabs which should cancel the previous generating
+        driver.findElement(By.css('.rows-to-add'))
+            .clear();
+        driver.findElement(By.css('.rows-to-add'))
+            .sendKeys('20');
         driver.findElement(By.css('#bip32-tab a'))
             .click()
         driver.sleep(generateDelay).then(function() {
@@ -2175,7 +2212,7 @@ it('Can change details while old addresses are still being generated', function(
                 });
         });
     });
-});
+}, generateDelay + 5000);
 
 // Github issue 49
 // padding for binary should give length with multiple of 256
@@ -2832,4 +2869,103 @@ it('Passes the official BIP84 test spec for account 0 first change address', fun
     });
 });
 
+it('Can display the table as csv', function(done) {
+    var headings = "path,address,public key,private key";
+    var row1 = "m/44'/0'/0'/0/0,1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug,033f5aed5f6cfbafaf223188095b5980814897295f723815fea5d3f4b648d0d0b3,L26cVSpWFkJ6aQkPkKmTzLqTdLJ923e6CzrVh9cmx21QHsoUmrEE";
+    var row20 = "m/44'/0'/0'/0/19,1KhBy28XLAciXnnRvm71PvQJaETyrxGV55,02b4b3e396434d8cdd20c03ac4aaa07387784d5d867b75987f516f5705ee68cb3a,L4GrDrjReMsCAu5DkLXn79jSb95qR7Zfx7eshybCQZ1qL32MXJab";
+    driver.findElement(By.css('.phrase'))
+        .sendKeys('abandon abandon ability');
+    driver.sleep(generateDelay).then(function() {
+        driver.findElement(By.css('.csv'))
+            .getAttribute("value")
+            .then(function(csv) {
+                expect(csv).toContain(headings);
+                expect(csv).toContain(row1);
+                expect(csv).toContain(row20);
+                done();
+            });
+    });
+});
+
+it('LeftPads ethereum keys that are less than 32 bytes', function(done) {
+    // see https://github.com/iancoleman/bip39/issues/155
+    selectNetwork("ETH - Ethereum");
+    driver.findElement(By.css('#bip32-tab a'))
+        .click()
+    driver.findElement(By.css('#bip32-path'))
+        .clear();
+    driver.findElement(By.css('#bip32-path'))
+        .sendKeys("m/44'/60'/0'");
+    driver.findElement(By.css('.phrase'))
+        .sendKeys('scout sort custom elite radar rare vivid thing trophy gesture cover snake change narrow kite list nation sustain buffalo erode open balance system young');
+    driver.sleep(generateDelay).then(function() {
+        getFirstAddress(function(address) {
+            expect(address).toBe("0x8943E785B4a5714FC87a3aFAad1eB1FeB602B118");
+            done();
+        });
+    });
+});
+
+it('Can encrypt private keys using BIP38', function(done) {
+    // see https://github.com/iancoleman/bip39/issues/140
+    driver.executeScript(function() {
+        $(".use-bip38").prop("checked", true);
+    });
+    driver.findElement(By.css('.bip38-password'))
+        .sendKeys('bip38password');
+    driver.findElement(By.css('.rows-to-add'))
+        .clear();
+    driver.findElement(By.css('.rows-to-add'))
+        .sendKeys('1');
+    driver.findElement(By.css('.phrase'))
+        .sendKeys('abandon abandon ability');
+    driver.sleep(bip38delay).then(function() {
+        // address
+        getFirstRowValue(function(address) {
+            expect(address).toBe("1NCvSdumA3ngMM9c4aqU56AM6rqXddfuXB");
+            // pubkey
+            getFirstRowValue(function(pubkey) {
+                expect(pubkey).toBe("043f5aed5f6cfbafaf223188095b5980814897295f723815fea5d3f4b648d0d0b3884a74447ea901729b1e73a999b7520e7cb55b4120e6432c64153ccab8a848e1");
+                // privkey
+                getFirstRowValue(function(privkey) {
+                    expect(privkey).toBe("6PRNRiFnj1RoR3sXhymdCvoZCgnUHQpfupNdKkFbWJkwWQEKesWt1EDMDM");
+                    done();
+                }, ".privkey");
+            }, ".pubkey");
+        }, ".address");
+    });
+}, bip38delay + 5000);
+
+it('Shows the checksum for the entropy', function(done) {
+    driver.findElement(By.css('.use-entropy'))
+        .click();
+    driver.findElement(By.css('.entropy'))
+        .sendKeys("00000000000000000000000000000000");
+    driver.sleep(generateDelay).then(function() {
+        driver.findElement(By.css('.checksum'))
+            .getText()
+            .then(function(text) {
+                expect(text).toBe("1");
+                done();
+            });
+    });
+});
+
+it('Shows the checksum for the entropy with the correct groupings', function(done) {
+    driver.findElement(By.css('.use-entropy'))
+        .click();
+    // create a checksum of 20 bits, which spans multiple words
+    driver.findElement(By.css('.entropy'))
+        .sendKeys("F000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
+    driver.sleep(generateDelay).then(function() {
+        driver.findElement(By.css('.checksum'))
+            .getText()
+            .then(function(text) {
+                // first group is 9 bits, second group is 11
+                expect(text).toBe("011010111 01110000110");
+                done();
+            });
+    });
+});
+
 });