In the browser, sometimes the config for bignum wasn't being set up if (somehow
... still not sure how this is possible) you use bitcore without using
require('bitcore'). This would by pass the code that set the config for bignum.
Solution is to put the config for bignum in bignum itself (in the browser).
This fixes, in particular, an issue with base58 where it was depending on
bignum having the proper config.
Also I add the base58 tests to run in the browser which they weren't
previously.
And finally I add a small test for Bignum in the browser that makes sure the
config is set properly.
19 lines
672 B
JavaScript
19 lines
672 B
JavaScript
var chai = chai || require('chai');
|
|
var bitcore = bitcore || require('../bitcore');
|
|
var coinUtil = coinUtil || bitcore.util;
|
|
var should = chai.should();
|
|
var assert = chai.assert;
|
|
|
|
var Bignum = bitcore.Bignum;
|
|
|
|
if (typeof process == 'undefined' || typeof process.versions == 'undefined') {
|
|
describe('#Bignum.browser', function() {
|
|
it('should have proper config settings', function() {
|
|
bitcore.Bignum.config().EXPONENTIAL_AT[0].should.equal(-9999999);
|
|
bitcore.Bignum.config().EXPONENTIAL_AT[1].should.equal(9999999);
|
|
bitcore.Bignum.config().DECIMAL_PLACES.should.equal(0);
|
|
bitcore.Bignum.config().ROUNDING_MODE.should.equal(1);
|
|
});
|
|
});
|
|
}
|