aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Coleman <coleman.ian@gmail.com>2016-08-23 16:16:41 +1000
committerIan Coleman <coleman.ian@gmail.com>2016-08-23 16:17:17 +1000
commit54563907c721a90f8fc9861a62fe7c214b5c5041 (patch)
tree5d752b975a02055ff93e06a86b0d7da786b489fe
parent1975bfbc2be03063046b24cb599c119675264186 (diff)
downloadBIP39-54563907c721a90f8fc9861a62fe7c214b5c5041.tar.gz
BIP39-54563907c721a90f8fc9861a62fe7c214b5c5041.tar.zst
BIP39-54563907c721a90f8fc9861a62fe7c214b5c5041.zip
Tests for passphrase and coin selection
-rw-r--r--bip39-standalone.html27
-rw-r--r--src/index.html16
-rw-r--r--src/js/index.js11
-rw-r--r--tests.js66
4 files changed, 91 insertions, 29 deletions
diff --git a/bip39-standalone.html b/bip39-standalone.html
index 5230003..5f9cf7c 100644
--- a/bip39-standalone.html
+++ b/bip39-standalone.html
@@ -71,14 +71,14 @@
71 <div class="col-sm-10"> 71 <div class="col-sm-10">
72 <div class="input-group"> 72 <div class="input-group">
73 <select id="strength" class="strength form-control"> 73 <select id="strength" class="strength form-control">
74 <option val="3">3</option> 74 <option value="3">3</option>
75 <option val="6">6</option> 75 <option value="6">6</option>
76 <option val="9">9</option> 76 <option value="9">9</option>
77 <option val="12">12</option> 77 <option value="12">12</option>
78 <option val="15" selected>15</option> 78 <option value="15" selected>15</option>
79 <option val="18">18</option> 79 <option value="18">18</option>
80 <option val="21">21</option> 80 <option value="21">21</option>
81 <option val="24">24</option> 81 <option value="24">24</option>
82 </select> 82 </select>
83 <span class="input-group-btn"> 83 <span class="input-group-btn">
84 <button class="btn generate">Generate Random Mnemonic</button> 84 <button class="btn generate">Generate Random Mnemonic</button>
@@ -14906,9 +14906,14 @@ var Mnemonic = function(language) {
14906 // Event handlers 14906 // Event handlers
14907 14907
14908 function networkChanged(e) { 14908 function networkChanged(e) {
14909 var network = e.target.value; 14909 var networkIndex = e.target.value;
14910 networks[network].onSelect(); 14910 networks[networkIndex].onSelect();
14911 displayBip32Info(); 14911 if (seed != null) {
14912 phraseChanged();
14913 }
14914 else {
14915 rootKeyChanged();
14916 }
14912 } 14917 }
14913 14918
14914 function delayedPhraseChanged() { 14919 function delayedPhraseChanged() {
diff --git a/src/index.html b/src/index.html
index 15fb063..ea7096c 100644
--- a/src/index.html
+++ b/src/index.html
@@ -67,14 +67,14 @@
67 <div class="col-sm-10"> 67 <div class="col-sm-10">
68 <div class="input-group"> 68 <div class="input-group">
69 <select id="strength" class="strength form-control"> 69 <select id="strength" class="strength form-control">
70 <option val="3">3</option> 70 <option value="3">3</option>
71 <option val="6">6</option> 71 <option value="6">6</option>
72 <option val="9">9</option> 72 <option value="9">9</option>
73 <option val="12">12</option> 73 <option value="12">12</option>
74 <option val="15" selected>15</option> 74 <option value="15" selected>15</option>
75 <option val="18">18</option> 75 <option value="18">18</option>
76 <option val="21">21</option> 76 <option value="21">21</option>
77 <option val="24">24</option> 77 <option value="24">24</option>
78 </select> 78 </select>
79 <span class="input-group-btn"> 79 <span class="input-group-btn">
80 <button class="btn generate">Generate Random Mnemonic</button> 80 <button class="btn generate">Generate Random Mnemonic</button>
diff --git a/src/js/index.js b/src/js/index.js
index 68f1cda..8f7d658 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -72,9 +72,14 @@
72 // Event handlers 72 // Event handlers
73 73
74 function networkChanged(e) { 74 function networkChanged(e) {
75 var network = e.target.value; 75 var networkIndex = e.target.value;
76 networks[network].onSelect(); 76 networks[networkIndex].onSelect();
77 displayBip32Info(); 77 if (seed != null) {
78 phraseChanged();
79 }
80 else {
81 rootKeyChanged();
82 }
78 } 83 }
79 84
80 function delayedPhraseChanged() { 85 function delayedPhraseChanged() {
diff --git a/tests.js b/tests.js
index 12b779e..7a3a842 100644
--- a/tests.js
+++ b/tests.js
@@ -111,9 +111,10 @@ page.open(url, function(status) {
111function() { 111function() {
112page.open(url, function(status) { 112page.open(url, function(status) {
113 // set the length to 6 113 // set the length to 6
114 var expectedLength = 6; 114 var expectedLength = "6";
115 page.evaluate(function() { 115 page.evaluate(function() {
116 $(".strength").val(expectedLength); 116 $(".strength option[selected]").removeAttr("selected");
117 $(".strength option[value=6]").prop("selected", true);
117 }); 118 });
118 // press the 'generate' button 119 // press the 'generate' button
119 page.evaluate(function() { 120 page.evaluate(function() {
@@ -131,15 +132,65 @@ page.open(url, function(status) {
131 console.log("Actual: " + actualLength); 132 console.log("Actual: " + actualLength);
132 fail(); 133 fail();
133 } 134 }
134 }, 200); 135 next();
135 next(); 136 }, 1000);
136}); 137});
137}, 138},
138 139
139// TODO finish these tests
140
141// Passphrase can be set 140// Passphrase can be set
141function() {
142page.open(url, function(status) {
143 // set the phrase and passphrase
144 var expected = "15pJzUWPGzR7avffV9nY5by4PSgSKG9rba";
145 page.evaluate(function() {
146 $(".phrase").val("abandon abandon ability");
147 $(".passphrase").val("secure_passphrase").trigger("input");
148 });
149 // check the address is generated correctly
150 setTimeout(function() {
151 var actual = page.evaluate(function() {
152 return $(".address:first").text();
153 });
154 if (actual != expected) {
155 console.log("Passphrase results in wrong address");
156 console.log("Expected: " + expected);
157 console.log("Actual: " + actual);
158 fail();
159 }
160 next();
161 }, 1000);
162});
163},
164
142// Network can be set to bitcoin testnet 165// Network can be set to bitcoin testnet
166function() {
167page.open(url, function(status) {
168 // set the phrase and passphrase
169 var expected = "mucaU5iiDaJDb69BHLeDv8JFfGiyg2nJKi";
170 page.evaluate(function() {
171 $(".phrase").val("abandon abandon ability");
172 $(".phrase").trigger("input");
173 $(".network option[selected]").removeAttr("selected");
174 $(".network option[value=1]").prop("selected", true);
175 $(".network").trigger("change");
176 });
177 // check the address is generated correctly
178 setTimeout(function() {
179 var actual = page.evaluate(function() {
180 return $(".address:first").text();
181 });
182 if (actual != expected) {
183 console.log("Bitcoin testnet address is incorrect");
184 console.log("Expected: " + expected);
185 console.log("Actual: " + actual);
186 fail();
187 }
188 next();
189 }, 1000);
190});
191},
192
193// TODO finish these tests
143// Network can be set to litecoin 194// Network can be set to litecoin
144// Network can be set to dogecoin 195// Network can be set to dogecoin
145// Network can be set to shadowcash 196// Network can be set to shadowcash
@@ -180,7 +231,8 @@ page.open(url, function(status) {
180// Additional addresses are shown in order of derivation path 231// Additional addresses are shown in order of derivation path
181 232
182// BIP32 root key can be set by the user 233// BIP32 root key can be set by the user
183// Setting BIP32 clears the existing phrase, passphrase and seed 234// Setting BIP32 root key clears the existing phrase, passphrase and seed
235// Clearing of phrase, passphrase and seed can be cancelled by user
184// Custom BIP32 root key is used when changing the derivation path 236// Custom BIP32 root key is used when changing the derivation path
185 237
186// Incorrect mnemonic shows error 238// Incorrect mnemonic shows error