X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fspec%2Ftests.js;h=7691fccb5884fb81b5d93d4ac6f295c14da55870;hb=91eb2cbcfd404e088a36d1ef03f4b174ee640ec7;hp=f10f7a402a85e050fbffa74b47474aa9f527fd4b;hpb=9183f9f658222dc3a24c8b4794887b6ecd80ba1e;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FBIP39.git diff --git a/tests/spec/tests.js b/tests/spec/tests.js index f10f7a4..7691fcc 100644 --- a/tests/spec/tests.js +++ b/tests/spec/tests.js @@ -492,6 +492,13 @@ it('Allows selection of game', function(done) { }; testNetwork(done, params); }); +it('Allows selection of komodo', function(done) { + var params = { + selectText: "KMD - Komodo", + firstAddress: "RJL777dmaB3PYqHEJGMJKWWkLPdu1ypGi4", + }; + testNetwork(done, params); +}); it('Allows selection of namecoin', function(done) { var params = { selectText: "NMC - Namecoin", @@ -499,6 +506,13 @@ it('Allows selection of namecoin', function(done) { }; testNetwork(done, params); }); +it('Allows selection of onixcoin', function(done) { + var params = { + selectText: "ONX - Onixcoin", + firstAddress: "XGwMqddeKjT3ddgX73QokjVbCL3aK6Yxfk", + }; + testNetwork(done, params); +}); it('Allows selection of peercoin', function(done) { var params = { selectText: "PPC - Peercoin", @@ -2473,11 +2487,11 @@ it('Shows error for hardened addresses with xpub root key', function(done) { }); }); -// Litecoin uses xprv by default, and can optionally be set to ltpv +// Litecoin uses ltub by default, and can optionally be set to xprv // github issue 96 // https://github.com/iancoleman/bip39/issues/96 // Issue with extended keys on Litecoin -it('Uses xprv by default for litecoin, but can be set to ltpv', function(done) { +it('Uses ltub by default for litecoin, but can be set to xprv', function(done) { driver.findElement(By.css('.phrase')) .sendKeys("abandon abandon ability"); selectNetwork("LTC - Litecoin"); @@ -2486,17 +2500,17 @@ it('Uses xprv by default for litecoin, but can be set to ltpv', function(done) { driver.findElement(By.css('.root-key')) .getAttribute("value") .then(function(rootKey) { - expect(rootKey).toBe("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi"); + expect(rootKey).toBe("Ltpv71G8qDifUiNesiPqf6h5V6eQ8ic77oxQiYtawiACjBEx3sTXNR2HGDGnHETYxESjqkMLFBkKhWVq67ey1B2MKQXannUqNy1RZVHbmrEjnEU"); // set litecoin to use ltub driver.executeScript(function() { - $(".litecoin-use-ltub").prop("checked", true); + $(".litecoin-use-ltub").prop("checked", false); $(".litecoin-use-ltub").trigger("change"); }); driver.sleep(generateDelay).then(function() { driver.findElement(By.css('.root-key')) .getAttribute("value") .then(function(rootKey) { - expect(rootKey).toBe("Ltpv71G8qDifUiNesiPqf6h5V6eQ8ic77oxQiYtawiACjBEx3sTXNR2HGDGnHETYxESjqkMLFBkKhWVq67ey1B2MKQXannUqNy1RZVHbmrEjnEU"); + expect(rootKey).toBe("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi"); done(); }); }) @@ -2504,31 +2518,6 @@ it('Uses xprv by default for litecoin, but can be set to ltpv', function(done) { }); }); -// BIP32 tab can use P2WPKH Nested In P2SH -// github issue 91 part 2 -// https://github.com/iancoleman/bip39/issues/91 -// generate new addresses from xpub? -it('Uses xprv by default for litecoin, but can be set to ltpv', function(done) { - // use p2wpkh addresses - driver.executeScript(function() { - $(".p2wpkh-nested-in-p2sh").prop("checked", true); - }); - // use bip32 tab - driver.findElement(By.css('#bip32-tab a')) - .click() - // use testnet - selectNetwork("BTC - Bitcoin Testnet"); - // Set root xpub to BIP49 official test vector account 0 - driver.findElement(By.css('.root-key')) - .sendKeys("tpubDD7tXK8KeQ3YY83yWq755fHY2JW8Ha8Q765tknUM5rSvjPcGWfUppDFMpQ1ScziKfW3ZNtZvAD7M3u7bSs7HofjTD3KP3YxPK7X6hwV8Rk2"); - driver.sleep(generateDelay).then(function() { - getFirstAddress(function(address) { - expect(address).toBe("2Mww8dCYPUpKHofjgcXcBCEGmniw9CoaiD2"); - done(); - }); - }); -}); - // github issue 99 // https://github.com/iancoleman/bip39/issues/99#issuecomment-327094159 // "warn me emphatically when they have detected invalid input" to the entropy field @@ -2621,4 +2610,78 @@ it('Can generate more addresses from a custom index', function(done) { }); }); +it('Can generate BIP141 addresses with P2WPKH-in-P2SH semanitcs', function(done) { + // Sourced from BIP49 official test specs + driver.findElement(By.css('#bip141-tab a')) + .click(); + driver.findElement(By.css('.bip141-path')) + .clear(); + driver.findElement(By.css('.bip141-path')) + .sendKeys("m/49'/1'/0'/0"); + selectNetwork("BTC - Bitcoin Testnet"); + driver.findElement(By.css(".phrase")) + .sendKeys("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"); + driver.sleep(generateDelay).then(function() { + getFirstAddress(function(address) { + expect(address).toBe("2Mww8dCYPUpKHofjgcXcBCEGmniw9CoaiD2"); + done(); + }); + }); +}); + +it('Can generate BIP141 addresses with P2WPKH semanitcs', function(done) { + // This result tested against bitcoinjs-lib test spec for segwit address + // using the first private key of this mnemonic and default path m/0 + // https://github.com/bitcoinjs/bitcoinjs-lib/blob/9c8503cab0c6c30a95127042703bc18e8d28c76d/test/integration/addresses.js#L50 + // so whilst not directly comparable, substituting the private key produces + // identical results between this tool and the bitcoinjs-lib test. + // Private key generated is: + // L3L8Nu9whawPBNLGtFqDhKut9DKKfG3CQoysupT7BimqVCZsLFNP + driver.findElement(By.css('#bip141-tab a')) + .click(); + // Choose P2WPKH + driver.executeScript(function() { + $(".bip141-semantics option[selected]").removeAttr("selected"); + $(".bip141-semantics option").filter(function(i,e) { + return $(e).html() == "P2WPKH"; + }).prop("selected", true); + $(".bip141-semantics").trigger("change"); + }); + driver.findElement(By.css(".phrase")) + .sendKeys("abandon abandon ability"); + driver.sleep(generateDelay).then(function() { + getFirstAddress(function(address) { + expect(address).toBe("bc1qfwu6a5a3evygrk8zvdxxvz4547lmpyx5vsfxe9"); + done(); + }); + }); +}); + +it('Shows the entropy used by the PRNG when clicking generate', function(done) { + driver.findElement(By.css('.generate')).click(); + driver.sleep(generateDelay).then(function() { + driver.findElement(By.css('.entropy')) + .getAttribute("value") + .then(function(entropy) { + expect(entropy).not.toBe(""); + done(); + }); + }); +}); + +it('Shows the index of each word in the mnemonic', function(done) { + driver.findElement(By.css('.phrase')) + .sendKeys("abandon abandon ability"); + driver.sleep(generateDelay).then(function() { + driver.findElement(By.css('.use-entropy')) + .click(); + driver.findElement(By.css('.word-indexes')) + .getText() + .then(function(indexes) { + expect(indexes).toBe("0, 0, 1"); + done(); + }); + }); +}); + });