Jeff Garzik
11 years ago
11 changed files with 185 additions and 15 deletions
@ -1,5 +1,5 @@ |
|||
|
|||
// load modules needed for testing in the browser
|
|||
|
|||
var fs = require('fs'); |
|||
//var fs = require('fs');
|
|||
|
|||
|
@ -1,7 +0,0 @@ |
|||
|
|||
var SINKey = require('./SINKey').class(); |
|||
|
|||
var sk = new SINKey(); |
|||
sk.generate(); |
|||
console.dir(sk.storeObj()); |
|||
|
@ -0,0 +1,43 @@ |
|||
'use strict'; |
|||
|
|||
var chai = require('chai'); |
|||
var bitcore = require('../bitcore'); |
|||
|
|||
var should = chai.should(); |
|||
|
|||
var OpcodeModule = bitcore.Opcode; |
|||
var Opcode; |
|||
|
|||
describe('Opcode', function() { |
|||
it('should initialze the main object', function() { |
|||
should.exist(OpcodeModule); |
|||
}); |
|||
it('should be able to create class', function() { |
|||
Opcode = OpcodeModule.class(); |
|||
should.exist(Opcode); |
|||
}); |
|||
it('should be able to create instance', function() { |
|||
var oc = new Opcode(); |
|||
should.exist(oc); |
|||
}); |
|||
it.skip('should be able to create some constants', function() { |
|||
// TODO: test works in node but not in browser
|
|||
for (var i in Opcode.map) { |
|||
console.log('var '+i + ' = ' + Opcode.map[i] + ';'); |
|||
eval('var '+i + ' = ' + Opcode.map[i] + ';'); |
|||
console.log(eval(i)); |
|||
} |
|||
should.exist(OP_VER); |
|||
should.exist(OP_HASH160); |
|||
should.exist(OP_RETURN); |
|||
should.exist(OP_EQUALVERIFY); |
|||
should.exist(OP_CHECKSIG); |
|||
should.exist(OP_CHECKMULTISIG); |
|||
|
|||
}); |
|||
}); |
|||
|
|||
|
|||
|
|||
|
|||
|
@ -0,0 +1,30 @@ |
|||
'use strict'; |
|||
|
|||
|
|||
|
|||
var chai = require('chai'); |
|||
var bitcore = require('../bitcore'); |
|||
|
|||
var should = chai.should(); |
|||
|
|||
var SINKeyModule = bitcore.SINKey; |
|||
var SINKey; |
|||
|
|||
|
|||
describe('SINKey', function() { |
|||
it('should initialze the main object', function() { |
|||
should.exist(SINKeyModule); |
|||
}); |
|||
it('should be able to create class', function() { |
|||
SINKey = SINKeyModule.class(); |
|||
should.exist(SINKey); |
|||
}); |
|||
it('should be able to create instance', function() { |
|||
var sk = new SINKey(); |
|||
sk.generate(); |
|||
should.exist(sk.created); |
|||
should.exist(sk.privKey.private); |
|||
should.exist(sk.privKey.public); |
|||
should.exist(sk.privKey.compressed); |
|||
}); |
|||
}); |
@ -0,0 +1,40 @@ |
|||
'use strict'; |
|||
|
|||
var chai = require('chai'); |
|||
var bitcore = require('../bitcore'); |
|||
|
|||
var should = chai.should(); |
|||
|
|||
var ScriptModule = bitcore.Script; |
|||
var Address = bitcore.Address.class(); |
|||
var Script; |
|||
|
|||
describe('Script', function() { |
|||
it('should initialze the main object', function() { |
|||
should.exist(ScriptModule); |
|||
}); |
|||
it('should be able to create class', function() { |
|||
Script = ScriptModule.class(); |
|||
should.exist(Script); |
|||
}); |
|||
it('should be able to create instance', function() { |
|||
var s = new Script(); |
|||
should.exist(s); |
|||
}); |
|||
it('should be able to create Script from Address', function() { |
|||
var addr = new Address('1J57QmkaQ6JohJoQyaUJwngJ2vTQ3C6gHi'); |
|||
var script = Script.createPubKeyHashOut(addr.payload()); |
|||
should.exist(script); |
|||
script.isPubkeyHash().should.be.true; |
|||
}); |
|||
it('isP2SH should work', function() { |
|||
var addr = new Address('1J57QmkaQ6JohJoQyaUJwngJ2vTQ3C6gHi'); |
|||
var script = Script.createPubKeyHashOut(addr.payload()); |
|||
script.isP2SH().should.be.false; |
|||
}); |
|||
}); |
|||
|
|||
|
|||
|
|||
|
|||
|
@ -0,0 +1,28 @@ |
|||
'use strict'; |
|||
|
|||
var chai = require('chai'); |
|||
var bitcore = require('../bitcore'); |
|||
|
|||
var should = chai.should(); |
|||
|
|||
var TransactionModule = bitcore.Transaction; |
|||
var Transaction; |
|||
|
|||
describe.skip('Transaction', function() { |
|||
it('should initialze the main object', function() { |
|||
should.exist(TransactionModule); |
|||
}); |
|||
it('should be able to create class', function() { |
|||
Transaction = TransactionModule.class(); |
|||
should.exist(Transaction); |
|||
}); |
|||
it('should be able to create instance', function() { |
|||
var t = new Transaction(); |
|||
should.exist(t); |
|||
}); |
|||
}); |
|||
|
|||
|
|||
|
|||
|
|||
|
@ -0,0 +1,24 @@ |
|||
'use strict'; |
|||
|
|||
var chai = require('chai'); |
|||
var bitcore = require('../bitcore'); |
|||
|
|||
var should = chai.should(); |
|||
|
|||
describe('Miscelaneous stuff', function() { |
|||
it('should initialze the config object', function() { |
|||
should.exist(bitcore.config); |
|||
}); |
|||
it('should initialze the log object', function() { |
|||
should.exist(bitcore.log); |
|||
}); |
|||
it('should initialze the util object', function() { |
|||
should.exist(bitcore.util); |
|||
}); |
|||
|
|||
}); |
|||
|
|||
|
|||
|
|||
|
|||
|
Loading…
Reference in new issue