File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -165,12 +165,21 @@ describe('ECPair', function () {
165165 assert . strictEqual ( keyPair . network , NETWORKS . testnet )
166166 } )
167167
168- it ( 'loops until d is within interval [1, n - 1]' , sinon . test ( function ( ) {
168+ it ( 'loops until d is within interval [1, n - 1] : 1' , sinon . test ( function ( ) {
169+ var rng = this . mock ( )
170+ rng . exactly ( 2 )
171+ rng . onCall ( 0 ) . returns ( BigInteger . ZERO . toBuffer ( 32 ) ) // invalid length
172+ rng . onCall ( 1 ) . returns ( BigInteger . ONE . toBuffer ( 32 ) ) // === 1
173+
174+ ECPair . makeRandom ( { rng : rng } )
175+ } ) )
176+
177+ it ( 'loops until d is within interval [1, n - 1] : n - 1' , sinon . test ( function ( ) {
169178 var rng = this . mock ( )
170179 rng . exactly ( 3 )
171- rng . onCall ( 0 ) . returns ( new BigInteger ( '0' ) . toBuffer ( 32 ) ) // < 1
180+ rng . onCall ( 0 ) . returns ( BigInteger . ZERO . toBuffer ( 32 ) ) // < 1
172181 rng . onCall ( 1 ) . returns ( curve . n . toBuffer ( 32 ) ) // > n-1
173- rng . onCall ( 2 ) . returns ( new BigInteger ( '42' ) . toBuffer ( 32 ) ) // valid
182+ rng . onCall ( 2 ) . returns ( curve . n . subtract ( BigInteger . ONE ) . toBuffer ( 32 ) ) // === n-1
174183
175184 ECPair . makeRandom ( { rng : rng } )
176185 } ) )
You can’t perform that action at this time.
0 commit comments