]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
Add BIP38 test
authorIan Coleman <ian@iancoleman.io>
Mon, 5 Feb 2018 23:14:22 +0000 (10:14 +1100)
committerIan Coleman <ian@iancoleman.io>
Mon, 5 Feb 2018 23:14:22 +0000 (10:14 +1100)
tests/spec/tests.js

index b30cbe4d86b1c82ff8c8ab4755ebea0f0237469e..9a8042434eb2ecc2b044ff4d2edc10468d53994c 100644 (file)
@@ -33,6 +33,7 @@ var driver = null;
 var generateDelay = 1500;
 var feedbackDelay = 500;
 var entropyFeedbackDelay = 500;
+var bip38delay = 15000;
 
 // url uses file:// scheme
 var path = require('path')
@@ -2876,4 +2877,34 @@ it('LeftPads ethereum keys that are less than 32 bytes', function(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);
+
 });