mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
Refactor JavaScript library.
- Separate classes in separate modules (files) - Constants should be associated with a class - Replace exports.config scheme with a config singleton - Refactor base58 functions as a static class
This commit is contained in:
@@ -8,7 +8,8 @@ var amount = require("../src/js/amount.js");
|
||||
var Amount = require("../src/js/amount.js").Amount;
|
||||
var UInt160 = require("../src/js/amount.js").UInt160;
|
||||
|
||||
require("../src/js/amount.js").config = require("./config.js");
|
||||
var extend = require('extend');
|
||||
extend(require('../src/js/config'), require('./config'));
|
||||
|
||||
var config = require('./config.js');
|
||||
|
||||
@@ -20,16 +21,16 @@ buster.testCase("Amount", {
|
||||
buster.assert.equals(nbi(), UInt160.from_generic("0")._value);
|
||||
},
|
||||
"Parse 0 export" : function () {
|
||||
buster.assert.equals(amount.consts.address_xns, UInt160.from_generic("0").to_json());
|
||||
buster.assert.equals(UInt160.ADDRESS_ZERO, UInt160.from_generic("0").to_json());
|
||||
},
|
||||
"Parse 1" : function () {
|
||||
buster.assert.equals(new BigInteger([1]), UInt160.from_generic("1")._value);
|
||||
},
|
||||
"Parse rrrrrrrrrrrrrrrrrrrrrhoLvTp export" : function () {
|
||||
buster.assert.equals(amount.consts.address_xns, UInt160.from_json("rrrrrrrrrrrrrrrrrrrrrhoLvTp").to_json());
|
||||
buster.assert.equals(UInt160.ADDRESS_ZERO, UInt160.from_json("rrrrrrrrrrrrrrrrrrrrrhoLvTp").to_json());
|
||||
},
|
||||
"Parse rrrrrrrrrrrrrrrrrrrrBZbvji export" : function () {
|
||||
buster.assert.equals(amount.consts.address_one, UInt160.from_json("rrrrrrrrrrrrrrrrrrrrBZbvji").to_json());
|
||||
buster.assert.equals(UInt160.ADDRESS_ONE, UInt160.from_json("rrrrrrrrrrrrrrrrrrrrBZbvji").to_json());
|
||||
},
|
||||
"Parse mtgox export" : function () {
|
||||
buster.assert.equals(config.accounts["mtgox"].account, UInt160.from_json("mtgox").to_json());
|
||||
|
||||
Reference in New Issue
Block a user