Browse Source

all classes working with soop and test passing

patch-2
Matias Alejo Garcia 11 years ago
parent
commit
c0c325dabd
  1. 15
      Address.js
  2. 27
      Block.js
  3. 7
      Bloom.js
  4. 35
      Connection.js
  5. 7
      Opcode.js
  6. 13
      Peer.js
  7. 29
      PeerManager.js
  8. 13
      PrivateKey.js
  9. 16
      RpcClient.js
  10. 15
      SIN.js
  11. 10
      SINKey.js
  12. 26
      Script.js
  13. 22
      ScriptInterpreter.js
  14. 34
      Transaction.js
  15. 12
      Wallet.js
  16. 11
      WalletKey.js
  17. 2
      test/test.Address.js
  18. 2
      test/test.Block.js
  19. 2
      test/test.Bloom.js
  20. 2
      test/test.Connection.js
  21. 2
      test/test.EncodedData.js
  22. 2
      test/test.Opcode.js
  23. 2
      test/test.Peer.js
  24. 2
      test/test.PeerManager.js
  25. 2
      test/test.PrivateKey.js
  26. 2
      test/test.RpcClient.js
  27. 2
      test/test.SIN.js
  28. 2
      test/test.SINKey.js
  29. 4
      test/test.Script.js
  30. 2
      test/test.ScriptInterpreter.js
  31. 2
      test/test.Transaction.js
  32. 2
      test/test.VersionedData.js
  33. 2
      test/test.Wallet.js
  34. 2
      test/test.WalletKey.js
  35. 4
      test/test.basic.js
  36. 6
      util/BinaryParser.js
  37. 11
      util/EncodedData.js
  38. 14
      util/VersionedData.js

15
Address.js

@ -1,14 +1,13 @@
require('classtool'); 'use strict';
var imports = require('soop').imports();
function ClassSpec(b) { var parent = imports.parent || require('./util/VersionedData');
var superclass = b.superclass || require('./util/VersionedData').class();
function Address() { function Address() {
Address.super(this, arguments); Address.super(this, arguments);
} }
Address.superclass = superclass; Address.parent = parent;
superclass.applyEncodingsTo(Address); parent.applyEncodingsTo(Address);
Address.prototype.validate = function() { Address.prototype.validate = function() {
this.doAsBinary(function() { this.doAsBinary(function() {
@ -17,6 +16,4 @@ function ClassSpec(b) {
}); });
}; };
return Address; module.exports = require('soop')(Address);
}
module.defineClass(ClassSpec);

27
Block.js

@ -1,18 +1,17 @@
require('classtool'); var imports = require('soop').imports();
function spec(b) { var util = imports.util || require('./util/util');
var util = b.util || require('./util/util'); var Debug1 = imports.Debug1 || function() {};
var Debug1 = b.Debug1 || function() {}; var Script = imports.Script || require('./Script');
var Script = b.Script || require('./Script').class(); var Bignum = imports.Bignum || require('bignum');
var Bignum = b.Bignum || require('bignum'); var Binary = imports.Binary || require('binary');
var Binary = b.Binary || require('binary'); var Step = imports.Step || require('step');
var Step = b.Step || require('step'); var buffertools = imports.buffertools || require('buffertools');
var buffertools = b.buffertools || require('buffertools'); var Transaction = imports.Transaction || require('./Transaction');
var Transaction = b.Transaction || require('./Transaction').class();
var TransactionIn = Transaction.In; var TransactionIn = Transaction.In;
var TransactionOut = Transaction.Out; var TransactionOut = Transaction.Out;
var COINBASE_OP = Transaction.COINBASE_OP; var COINBASE_OP = Transaction.COINBASE_OP;
var VerificationError = b.VerificationError || require('./util/error').VerificationError; var VerificationError = imports.VerificationError || require('./util/error').VerificationError;
var BlockRules = { var BlockRules = {
maxTimeOffset: 2 * 60 * 60, // How far block timestamps can be into the future maxTimeOffset: 2 * 60 * 60, // How far block timestamps can be into the future
largestHash: Bignum(2).pow(256) largestHash: Bignum(2).pow(256)
@ -589,6 +588,4 @@ function spec(b) {
return block; return block;
}; };
return Block; module.exports = require('soop')(Block);
};
module.defineClass(spec);

7
Bloom.js

@ -1,6 +1,3 @@
require('classtool');
function ClassSpec(b) {
var MAX_BLOOM_FILTER_SIZE = 36000; // bytes var MAX_BLOOM_FILTER_SIZE = 36000; // bytes
var MAX_HASH_FUNCS = 50; var MAX_HASH_FUNCS = 50;
var LN2SQUARED = 0.4804530139182014246671025263266649717305529515945455; var LN2SQUARED = 0.4804530139182014246671025263266649717305529515945455;
@ -110,7 +107,5 @@ function ClassSpec(b) {
MAX_HASH_FUNCS); MAX_HASH_FUNCS);
}; };
return Bloom;
};
module.defineClass(ClassSpec);
module.exports = require('soop')(Bloom);

35
Connection.js

@ -1,24 +1,23 @@
require('classtool'); var imports = require('soop').imports();
function spec(b) { var config = imports.config || require('./config');
var config = b.config || require('./config'); var log = imports.log || require('./util/log');
var log = b.log || require('./util/log'); var network = imports.network || require('./networks')[config.network];
var network = b.network || require('./networks')[config.network];
var MAX_RECEIVE_BUFFER = 10000000; var MAX_RECEIVE_BUFFER = 10000000;
var PROTOCOL_VERSION = 70000; var PROTOCOL_VERSION = 70000;
var Binary = b.Binary || require('binary'); var Binary = imports.Binary || require('binary');
var Put = b.Put || require('bufferput'); var Put = imports.Put || require('bufferput');
var Buffers = b.Buffers || require('buffers'); var Buffers = imports.Buffers || require('buffers');
require('./Buffers.monkey').patch(Buffers); require('./Buffers.monkey').patch(Buffers);
var noop = function() {};
var Block = require('./Block').class(); var Block = require('./Block');
var Transaction = require('./Transaction').class(); var Transaction = require('./Transaction');
var util = b.util || require('./util/util'); var util = imports.util || require('./util/util');
var Parser = b.Parser || require('./util/BinaryParser').class(); var Parser = imports.Parser || require('./util/BinaryParser');
var buffertools = b.buffertools || require('buffertools'); var buffertools = imports.buffertools || require('buffertools');
var doubleSha256 = b.doubleSha256 || util.twoSha256; var doubleSha256 = imports.doubleSha256 || util.twoSha256;
var nonce = util.generateNonce(); var nonce = util.generateNonce();
var BIP0031_VERSION = 60000; var BIP0031_VERSION = 60000;
@ -53,7 +52,7 @@ function spec(b) {
this.setupHandlers(); this.setupHandlers();
} }
Connection.superclass = b.superclass || require('events').EventEmitter; Connection.parent = imports.parent || require('events').EventEmitter;
Connection.prototype.setupHandlers = function () { Connection.prototype.setupHandlers = function () {
this.socket.addListener('connect', this.handleConnect.bind(this)); this.socket.addListener('connect', this.handleConnect.bind(this));
@ -542,6 +541,4 @@ function spec(b) {
return data; return data;
}; };
return Connection; module.exports = require('soop')(Connection);
};
module.defineClass(spec);

7
Opcode.js

@ -1,6 +1,5 @@
require('classtool'); var imports = require('soop').imports();
function spec(b) {
function Opcode(num) { function Opcode(num) {
this.code = num; this.code = num;
}; };
@ -156,6 +155,4 @@ function spec(b) {
} }
} }
return Opcode; module.exports = require('soop')(Opcode);
};
module.defineClass(spec);

13
Peer.js

@ -1,9 +1,8 @@
require('classtool'); var imports = require('soop').imports();
function spec(b) { var Net = imports.Net || require('net');
var Net = b.Net || require('net'); var Binary = imports.Binary || require('binary');
var Binary = b.Binary || require('binary'); var buffertools = imports.buffertools || require('buffertools');
var buffertools = b.buffertools || require('buffertools');
function Peer(host, port, services) { function Peer(host, port, services) {
if ("string" === typeof host) { if ("string" === typeof host) {
@ -56,6 +55,4 @@ function spec(b) {
return put.buffer(); return put.buffer();
}; };
return Peer; module.exports = require('soop')(Peer);
};
module.defineClass(spec);

29
PeerManager.js

@ -1,15 +1,14 @@
require('classtool');
var imports = require('soop').imports();
function spec(b) { var config = imports.config || require('./config');
var config = b.config || require('./config'); var log = imports.log || require('./util/log');
var log = b.log || require('./util/log'); var network = imports.network || require('./networks')[config.network];
var network = b.network || require('./networks')[config.network]; var Connection = imports.Connection ||
var Connection = b.Connection || require('./Connection').createClass( require('soop').load('./Connection', {config: config, network: network});
{config: config, network: network});
var Peer = b.Peer || require('./Peer').class(); var Peer = imports.Peer || require('./Peer');
var noop = function() {};
GetAdjustedTime = imports.GetAdjustedTime || function () {
GetAdjustedTime = b.GetAdjustedTime || function () {
// TODO: Implement actual adjustment // TODO: Implement actual adjustment
return Math.floor(new Date().getTime() / 1000); return Math.floor(new Date().getTime() / 1000);
}; };
@ -28,8 +27,8 @@ function spec(b) {
this.minConnections = 8; this.minConnections = 8;
this.minKnownPeers = 10; this.minKnownPeers = 10;
}; };
PeerManager.superclass = b.superclass || require('events').EventEmitter;
PeerManager.parent = imports.parent || require('events').EventEmitter;
PeerManager.Connection = Connection; PeerManager.Connection = Connection;
PeerManager.prototype.start = function() { PeerManager.prototype.start = function() {
@ -210,6 +209,4 @@ function spec(b) {
return this.connections.slice(0); return this.connections.slice(0);
}; };
return PeerManager; module.exports = require('soop')(PeerManager);
};
module.defineClass(spec);

13
PrivateKey.js

@ -1,7 +1,6 @@
require('classtool'); var imports = require('soop').imports();
function ClassSpec(b) { var parent = imports.parent || require('./util/VersionedData');
var superclass = b.superclass || require('./util/VersionedData').class();
//compressed is true if public key is compressed; false otherwise //compressed is true if public key is compressed; false otherwise
function PrivateKey(version, buf, compressed) { function PrivateKey(version, buf, compressed) {
@ -10,8 +9,8 @@ function ClassSpec(b) {
this.compressed(compressed); this.compressed(compressed);
}; };
PrivateKey.superclass = superclass; PrivateKey.parent = parent;
superclass.applyEncodingsTo(PrivateKey); parent.applyEncodingsTo(PrivateKey);
PrivateKey.prototype.validate = function() { PrivateKey.prototype.validate = function() {
this.doAsBinary(function() { this.doAsBinary(function() {
@ -62,6 +61,4 @@ function ClassSpec(b) {
} }
}; };
return PrivateKey; module.exports = require('soop')(PrivateKey);
};
module.defineClass(ClassSpec);

16
RpcClient.js

@ -1,12 +1,11 @@
// RpcClient.js // RpcClient.js
// MIT/X11-like license. See LICENSE.txt. // MIT/X11-like license. See LICENSE.txt.
// Copyright 2013 BitPay, Inc. // Copyright 2013 BitPay, Inc.
require('classtool'); //
var imports = require('soop').imports();
function ClassSpec(b) { var http = imports.http || require('http');
var http = b.http || require('http'); var https = imports.https || require('https');
var https = b.https || require('https'); var log = imports.log || require('./util/log');
var log = b.log || require('./util/log');
function RpcClient(opts) { function RpcClient(opts) {
opts = opts || {}; opts = opts || {};
@ -204,7 +203,6 @@ function ClassSpec(b) {
}; };
generateRPCMethods(RpcClient, callspec, rpc); generateRPCMethods(RpcClient, callspec, rpc);
return RpcClient;
}; module.exports = require('soop')(RpcClient);
module.defineClass(ClassSpec);

15
SIN.js

@ -1,8 +1,5 @@
require('classtool'); var imports = require('soop').imports();
var parent = imports.parent || require('./util/VersionedData');
function ClassSpec(b) {
var superclass = b.superclass || require('./util/VersionedData').class();
function SIN(type, payload) { function SIN(type, payload) {
if (typeof type != 'number') { if (typeof type != 'number') {
@ -15,8 +12,8 @@ function ClassSpec(b) {
this.type(type); this.type(type);
this.payload(payload); this.payload(payload);
}; };
SIN.superclass = superclass; SIN.parent = parent;
superclass.applyEncodingsTo(SIN); parent.applyEncodingsTo(SIN);
SIN.SIN_PERSIST_MAINNET = 0x01; // associated with sacrifice TX SIN.SIN_PERSIST_MAINNET = 0x01; // associated with sacrifice TX
SIN.SIN_PERSIST_TESTNET = 0x11; // associated with sacrifice TX SIN.SIN_PERSIST_TESTNET = 0x11; // associated with sacrifice TX
@ -55,6 +52,4 @@ function ClassSpec(b) {
if (this.data.length != 22) throw new Error('invalid data length'); if (this.data.length != 22) throw new Error('invalid data length');
}); });
}; };
return SIN; module.exports = require('soop')(SIN);
};
module.defineClass(ClassSpec);

10
SINKey.js

@ -1,10 +1,7 @@
require('classtool');
function ClassSpec(b) {
var coinUtil = require('./util/util'); var coinUtil = require('./util/util');
var timeUtil = require('./util/time'); var timeUtil = require('./util/time');
var KeyModule = require('./Key'); var KeyModule = require('./Key');
var SIN = require('./SIN').class(); var SIN = require('./SIN');
function SINKey(cfg) { function SINKey(cfg) {
if (typeof cfg != 'object') if (typeof cfg != 'object')
@ -37,7 +34,4 @@ function ClassSpec(b) {
return obj; return obj;
}; };
return SINKey; module.exports = require('soop')(SINKey);
};
module.defineClass(ClassSpec);

26
Script.js

@ -1,20 +1,17 @@
require('classtool'); var imports = require('soop').imports();
var config = imports.config || require('./config');
function spec(b) { var log = imports.log || require('./util/log');
var config = b.config || require('./config'); var Opcode = imports.Opcode || require('./Opcode');
var log = b.log || require('./util/log'); var buffertools = imports.buffertools || require('buffertools');
var Opcode = b.Opcode || require('./Opcode').class();
var buffertools = b.buffertools || require('buffertools');
// Make opcodes available as pseudo-constants // Make opcodes available as pseudo-constants
for (var i in Opcode.map) { for (var i in Opcode.map) {
eval(i + " = " + Opcode.map[i] + ";"); eval(i + ' = ' + Opcode.map[i] + ';');
} }
var util = b.util || require('./util/util'); var util = imports.util || require('./util/util');
var Parser = b.Parser || require('./util/BinaryParser').class(); var Parser = imports.Parser || require('./util/BinaryParser');
var Put = b.Put || require('bufferput'); var Put = imports.Put || require('bufferput');
var TX_UNKNOWN = 0; var TX_UNKNOWN = 0;
var TX_PUBKEY = 1; var TX_PUBKEY = 1;
@ -517,7 +514,4 @@ function spec(b) {
return buf.buffer(); return buf.buffer();
}; };
return Script; module.exports = require('soop')(Script);
};
module.defineClass(spec);

22
ScriptInterpreter.js

@ -1,21 +1,19 @@
require('classtool'); var imports = require('soop').imports();
function spec(b) {
var assert = require('assert'); var assert = require('assert');
var config = b.config || require('./config'); var config = imports.config || require('./config');
var log = b.log || require('./util/log'); var log = imports.log || require('./util/log');
var Opcode = imports.Opcode || require('./Opcode');
var Opcode = b.Opcode || require('./Opcode').class(); var buffertools = imports.buffertools || require('buffertools');
var buffertools = b.buffertools || require('buffertools');
// Make opcodes available as pseudo-constants // Make opcodes available as pseudo-constants
for (var i in Opcode.map) { for (var i in Opcode.map) {
eval(i + " = " + Opcode.map[i] + ";"); eval(i + " = " + Opcode.map[i] + ";");
} }
var bignum = b.bignum || require('bignum'); var bignum = imports.bignum || require('bignum');
var Util = b.Util || require('./util/util'); var Util = imports.Util || require('./util/util');
var Script = require('./Script').class(); var Script = require('./Script');
function ScriptInterpreter() { function ScriptInterpreter() {
this.stack = []; this.stack = [];
@ -1028,6 +1026,4 @@ function spec(b) {
} }
}; };
return ScriptInterpreter; module.exports = require('soop')(ScriptInterpreter);
};
module.defineClass(spec);

34
Transaction.js

@ -1,19 +1,17 @@
require('classtool'); var imports = require('soop').imports();
function spec(b) { var config = imports.config || require('./config');
var config = b.config || require('./config'); var log = imports.log || require('./util/log');
var log = b.log || require('./util/log'); var Address = imports.Address || require('./Address');
var Address = b.Address || require('./Address').class(); var Script = imports.Script || require('./Script');
var Script = b.Script || require('./Script').class(); var ScriptInterpreter = imports.ScriptInterpreter || require('./ScriptInterpreter');
var ScriptInterpreter = b.ScriptInterpreter || require('./ScriptInterpreter').class(); var util = imports.util || require('./util/util');
var util = b.util || require('./util/util'); var bignum = imports.bignum || require('bignum');
var bignum = b.bignum || require('bignum'); var Put = imports.Put || require('bufferput');
var Put = b.Put || require('bufferput'); var Parser = imports.Parser || require('./util/BinaryParser');
var Parser = b.Parser || require('./util/BinaryParser').class(); var Step = imports.Step || require('step');
var Step = b.Step || require('step'); var buffertools = imports.buffertools || require('buffertools');
var buffertools = b.buffertools || require('buffertools'); var error = imports.error || require('./util/error');
var error = b.error || require('./util/error');
var VerificationError = error.VerificationError; var VerificationError = error.VerificationError;
var MissingSourceError = error.MissingSourceError; var MissingSourceError = error.MissingSourceError;
@ -811,6 +809,4 @@ function spec(b) {
} }
}; };
return Transaction; module.exports = require('soop')(Transaction);
};
module.defineClass(spec);

12
Wallet.js

@ -1,12 +1,12 @@
require('classtool'); var imports = require('soop').imports();
var hex = function(hex) {return new Buffer(hex, 'hex');}; var hex = function(hex) {return new Buffer(hex, 'hex');};
function ClassSpec(b) {
var fs = require('fs'); var fs = require('fs');
var EncFile = require('./util/EncFile'); var EncFile = require('./util/EncFile');
var Address = require('./Address').class(); var Address = require('./Address');
var networks = require('./networks'); var networks = require('./networks');
var util = b.util || require('./util/util'); var util = imports.util || require('./util/util');
var ENC_METHOD = 'aes-256-cbc'; var ENC_METHOD = 'aes-256-cbc';
var skeleton = { var skeleton = {
@ -136,7 +136,5 @@ function ClassSpec(b) {
return addrStr; return addrStr;
}; };
return Wallet; module.exports = require('soop')(Wallet);
};
module.defineClass(ClassSpec);

11
WalletKey.js

@ -1,11 +1,10 @@
require('classtool'); var imports = require('soop').imports();
function ClassSpec(b) {
var coinUtil = require('./util/util'); var coinUtil = require('./util/util');
var timeUtil = require('./util/time'); var timeUtil = require('./util/time');
var KeyModule = require('./Key'); var KeyModule = require('./Key');
var PrivateKey = require('./PrivateKey').class(); var PrivateKey = require('./PrivateKey');
var Address = require('./Address').class(); var Address = require('./Address');
function WalletKey(cfg) { function WalletKey(cfg) {
if (!cfg) cfg = {}; if (!cfg) cfg = {};
@ -50,6 +49,4 @@ function ClassSpec(b) {
this.privKey.regenerateSync(); this.privKey.regenerateSync();
}; };
return WalletKey; module.exports = require('soop')(WalletKey);
};
module.defineClass(ClassSpec);

2
test/test.Address.js

@ -13,7 +13,7 @@ describe('Address', function() {
should.exist(AddressModule); should.exist(AddressModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
Address = AddressModule.class(); Address = AddressModule;
should.exist(Address); should.exist(Address);
}); });
it('should be able to create instance', function() { it('should be able to create instance', function() {

2
test/test.Block.js

@ -12,7 +12,7 @@ describe('Block', function() {
should.exist(BlockModule); should.exist(BlockModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
Block = BlockModule.class(); Block = BlockModule;
should.exist(Block); should.exist(Block);
}); });
it('should be able to create instance', function() { it('should be able to create instance', function() {

2
test/test.Bloom.js

@ -13,7 +13,7 @@ describe('Bloom', function() {
should.exist(BloomModule); should.exist(BloomModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
Bloom = BloomModule.class(); Bloom = BloomModule;
should.exist(Bloom); should.exist(Bloom);
}); });
it('should be able to create instance', function() { it('should be able to create instance', function() {

2
test/test.Connection.js

@ -14,7 +14,7 @@ describe('Connection', function() {
should.exist(ConnectionModule); should.exist(ConnectionModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
Connection = ConnectionModule.class(); Connection = ConnectionModule;
should.exist(Connection); should.exist(Connection);
}); });
it('should be able to create instance', function() { it('should be able to create instance', function() {

2
test/test.EncodedData.js

@ -13,7 +13,7 @@ describe('EncodedData', function() {
should.exist(EncodedDataModule); should.exist(EncodedDataModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
EncodedData = EncodedDataModule.class(); EncodedData = EncodedDataModule;
should.exist(EncodedData); should.exist(EncodedData);
}); });
it('should be able to create an instance', function() { it('should be able to create an instance', function() {

2
test/test.Opcode.js

@ -13,7 +13,7 @@ describe('Opcode', function() {
should.exist(OpcodeModule); should.exist(OpcodeModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
Opcode = OpcodeModule.class(); Opcode = OpcodeModule;
should.exist(Opcode); should.exist(Opcode);
}); });
it('should be able to create instance', function() { it('should be able to create instance', function() {

2
test/test.Peer.js

@ -13,7 +13,7 @@ describe('Peer', function() {
should.exist(PeerModule); should.exist(PeerModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
Peer = PeerModule.class(); Peer = PeerModule;
should.exist(Peer); should.exist(Peer);
}); });
it('should be able to create instance', function() { it('should be able to create instance', function() {

2
test/test.PeerManager.js

@ -13,7 +13,7 @@ describe('PeerManager', function() {
should.exist(PeerManagerModule); should.exist(PeerManagerModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
PeerManager = PeerManagerModule.class(); PeerManager = PeerManagerModule;
should.exist(PeerManager); should.exist(PeerManager);
}); });
it('should be able to create instance', function() { it('should be able to create instance', function() {

2
test/test.PrivateKey.js

@ -15,7 +15,7 @@ describe('PrivateKey', function() {
should.exist(PrivateKeyModule); should.exist(PrivateKeyModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
PrivateKey = PrivateKeyModule.class(); PrivateKey = PrivateKeyModule;
should.exist(PrivateKey); should.exist(PrivateKey);
}); });
it('should be able to create instance', function() { it('should be able to create instance', function() {

2
test/test.RpcClient.js

@ -7,7 +7,7 @@ var should = chai.should();
var RpcClientModule = bitcore.RpcClient; var RpcClientModule = bitcore.RpcClient;
var RpcClient; var RpcClient;
RpcClient = RpcClientModule.class(); RpcClient = RpcClientModule;
describe('RpcClient', function() { describe('RpcClient', function() {
it('should initialze the main object', function() { it('should initialze the main object', function() {

2
test/test.SIN.js

@ -13,7 +13,7 @@ describe('SIN', function() {
should.exist(SINModule); should.exist(SINModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
SIN = SINModule.class(); SIN = SINModule;
should.exist(SIN); should.exist(SIN);
}); });
it('should be able to create instance', function() { it('should be able to create instance', function() {

2
test/test.SINKey.js

@ -16,7 +16,7 @@ describe('SINKey', function() {
should.exist(SINKeyModule); should.exist(SINKeyModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
SINKey = SINKeyModule.class(); SINKey = SINKeyModule;
should.exist(SINKey); should.exist(SINKey);
}); });
it('should be able to create instance', function() { it('should be able to create instance', function() {

4
test/test.Script.js

@ -6,7 +6,7 @@ var bitcore = require('../bitcore');
var should = chai.should(); var should = chai.should();
var ScriptModule = bitcore.Script; var ScriptModule = bitcore.Script;
var Address = bitcore.Address.class(); var Address = bitcore.Address;
var networks = bitcore.networks; var networks = bitcore.networks;
var Script; var Script;
@ -15,7 +15,7 @@ describe('Script', function() {
should.exist(ScriptModule); should.exist(ScriptModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
Script = ScriptModule.class(); Script = ScriptModule;
should.exist(Script); should.exist(Script);
}); });
it('should be able to create instance', function() { it('should be able to create instance', function() {

2
test/test.ScriptInterpreter.js

@ -13,7 +13,7 @@ describe('ScriptInterpreter', function() {
should.exist(ScriptInterpreterModule); should.exist(ScriptInterpreterModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
ScriptInterpreter = ScriptInterpreterModule.class(); ScriptInterpreter = ScriptInterpreterModule;
should.exist(ScriptInterpreter); should.exist(ScriptInterpreter);
}); });
it('should be able to create instance', function() { it('should be able to create instance', function() {

2
test/test.Transaction.js

@ -13,7 +13,7 @@ describe('Transaction', function() {
should.exist(TransactionModule); should.exist(TransactionModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
Transaction = TransactionModule.class(); Transaction = TransactionModule;
should.exist(Transaction); should.exist(Transaction);
}); });
it('should be able to create instance', function() { it('should be able to create instance', function() {

2
test/test.VersionedData.js

@ -13,7 +13,7 @@ describe('VersionedData', function() {
should.exist(VersionedDataModule); should.exist(VersionedDataModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
VersionedData = VersionedDataModule.class(); VersionedData = VersionedDataModule;
should.exist(VersionedData); should.exist(VersionedData);
}); });
it('should be able to create an instance', function() { it('should be able to create an instance', function() {

2
test/test.Wallet.js

@ -13,7 +13,7 @@ describe('Wallet', function() {
should.exist(WalletModule); should.exist(WalletModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
Wallet = WalletModule.class(); Wallet = WalletModule;
should.exist(Wallet); should.exist(Wallet);
}); });
it('should be able to create instance', function() { it('should be able to create instance', function() {

2
test/test.WalletKey.js

@ -14,7 +14,7 @@ describe('WalletKey', function() {
should.exist(WalletKeyModule); should.exist(WalletKeyModule);
}); });
it('should be able to create class', function() { it('should be able to create class', function() {
WalletKey = WalletKeyModule.class(); WalletKey = WalletKeyModule;
should.exist(WalletKey); should.exist(WalletKey);
}); });
it('should be able to create instance', function() { it('should be able to create instance', function() {

4
test/test.basic.js

@ -4,8 +4,8 @@ var chai = require('chai');
var bitcore = require('../bitcore'); var bitcore = require('../bitcore');
var should = chai.should(); var should = chai.should();
var Address = bitcore.Address.class(); var Address = bitcore.Address;
var PrivateKey = bitcore.PrivateKey.class(); var PrivateKey = bitcore.PrivateKey;
var networks = bitcore.networks; var networks = bitcore.networks;
var KeyModule = bitcore.KeyModule; var KeyModule = bitcore.KeyModule;

6
util/BinaryParser.js

@ -2,7 +2,7 @@
* Simple synchronous parser based on node-binary. * Simple synchronous parser based on node-binary.
*/ */
function spec(b) { var imports = require('soop').imports();
function Parser(buffer) function Parser(buffer)
{ {
this.subject = buffer; this.subject = buffer;
@ -143,6 +143,4 @@ function spec(b) {
return this.buffer(len); return this.buffer(len);
}; };
return Parser; module.exports = require('soop')(Parser);
};
module.defineClass(spec);

11
util/EncodedData.js

@ -1,7 +1,6 @@
require('classtool'); var imports = require('soop').imports();
var base58 = imports.base58 || require('base58-native').base58Check;
function ClassSpec(b) {
var base58 = b.base58 || require('base58-native').base58Check;
// Constructor. Takes the following forms: // Constructor. Takes the following forms:
// new EncodedData(<base58_address_string>) // new EncodedData(<base58_address_string>)
@ -154,6 +153,6 @@ function ClassSpec(b) {
}; };
EncodedData.applyEncodingsTo(EncodedData); EncodedData.applyEncodingsTo(EncodedData);
return EncodedData;
} module.exports = require('soop')(EncodedData);
module.defineClass(ClassSpec);

14
util/VersionedData.js

@ -1,7 +1,6 @@
require('classtool'); var imports = require('soop').imports();
var base58 = imports.base58 || require('base58-native').base58Check;
function ClassSpec(b) { var superclass = imports.parent || require('./EncodedData');
var superclass = b.superclass || require('./EncodedData').class();
function VersionedData(version, payload) { function VersionedData(version, payload) {
if(typeof version != 'number') { if(typeof version != 'number') {
@ -13,7 +12,8 @@ function ClassSpec(b) {
this.version(version); this.version(version);
this.payload(payload); this.payload(payload);
}; };
VersionedData.superclass = superclass;
VersionedData.parent = superclass || require('./Person');
superclass.applyEncodingsTo(VersionedData); superclass.applyEncodingsTo(VersionedData);
// get or set the version data (the first byte of the address) // get or set the version data (the first byte of the address)
@ -34,6 +34,4 @@ function ClassSpec(b) {
return this.as('binary').slice(1); return this.as('binary').slice(1);
}; };
return VersionedData; module.exports = require('soop')(VersionedData);
};
module.defineClass(ClassSpec);

Loading…
Cancel
Save