package: use cb-helloblock for integration tests
This commit is contained in:
parent
e6b7f51055
commit
837e0a3564
3 changed files with 17 additions and 21 deletions
|
@ -54,10 +54,11 @@
|
|||
"ecurve": "1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"async": "^0.9.0",
|
||||
"browserify": "^5.12.0",
|
||||
"bs58": "^2.0.0",
|
||||
"cb-helloblock": "^0.4.7",
|
||||
"coveralls": "^2.11.2",
|
||||
"helloblock-js": "^0.2.5",
|
||||
"istanbul": "^0.3.2",
|
||||
"jshint": "^2.5.6",
|
||||
"mocha": "^1.21.4",
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
var assert = require('assert')
|
||||
var bitcoin = require('../../')
|
||||
var helloblock = require('helloblock-js')({
|
||||
network: 'testnet'
|
||||
})
|
||||
var blockchain = new (require('cb-helloblock'))('testnet')
|
||||
|
||||
describe('bitcoinjs-lib (advanced)', function() {
|
||||
it('can sign a Bitcoin message', function() {
|
||||
|
@ -27,10 +25,10 @@ describe('bitcoinjs-lib (advanced)', function() {
|
|||
var key = bitcoin.ECKey.fromWIF("L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy")
|
||||
var address = key.pub.getAddress(bitcoin.networks.testnet).toString()
|
||||
|
||||
helloblock.faucet.withdraw(address, 2e4, function(err) {
|
||||
blockchain.addresses.__faucetWithdraw(address, 2e4, function(err) {
|
||||
if (err) return done(err)
|
||||
|
||||
helloblock.addresses.getUnspents(address, function(err, _, unspents) {
|
||||
blockchain.addresses.unspents(address, function(err, unspents) {
|
||||
if (err) return done(err)
|
||||
|
||||
// filter small unspents
|
||||
|
@ -44,20 +42,19 @@ describe('bitcoinjs-lib (advanced)', function() {
|
|||
var data = new Buffer('cafedeadbeef', 'hex')
|
||||
var dataScript = bitcoin.scripts.nullDataOutput(data)
|
||||
|
||||
tx.addInput(unspent.txHash, unspent.index)
|
||||
tx.addInput(unspent.txId, unspent.vout)
|
||||
tx.addOutput(dataScript, 1000)
|
||||
tx.sign(0, key)
|
||||
|
||||
helloblock.transactions.propagate(tx.build().toHex(), function(err) {
|
||||
blockchain.transactions.propagate(tx.build().toHex(), function(err) {
|
||||
if (err) return done(err)
|
||||
|
||||
// check that the message was propagated
|
||||
helloblock.addresses.getTransactions(address, function(err, res, transactions) {
|
||||
blockchain.addresses.transactions(address, function(err, transactions) {
|
||||
if (err) return done(err)
|
||||
|
||||
var transaction = transactions[0]
|
||||
var output = transaction.outputs[0]
|
||||
var dataScript2 = bitcoin.Script.fromHex(output.scriptPubKey)
|
||||
var transaction = bitcoin.Transaction.fromHex(transactions[0].txHex)
|
||||
var dataScript2 = transaction.outs[0].script
|
||||
var data2 = dataScript2.chunks[1]
|
||||
|
||||
assert.deepEqual(dataScript, dataScript2)
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
var assert = require('assert')
|
||||
var bitcoin = require('../../')
|
||||
var helloblock = require('helloblock-js')({
|
||||
network: 'testnet'
|
||||
})
|
||||
var blockchain = new (require('cb-helloblock'))('testnet')
|
||||
|
||||
describe('bitcoinjs-lib (multisig)', function() {
|
||||
it('can create a 2-of-3 multisig P2SH address', function() {
|
||||
|
@ -33,11 +31,11 @@ describe('bitcoinjs-lib (multisig)', function() {
|
|||
var address = bitcoin.Address.fromOutputScript(scriptPubKey, bitcoin.networks.testnet).toString()
|
||||
|
||||
// Attempt to send funds to the source address
|
||||
helloblock.faucet.withdraw(address, 2e4, function(err) {
|
||||
blockchain.addresses.__faucetWithdraw(address, 2e4, function(err) {
|
||||
if (err) return done(err)
|
||||
|
||||
// get latest unspents from the address
|
||||
helloblock.addresses.getUnspents(address, function(err, _, unspents) {
|
||||
blockchain.addresses.unspents(address, function(err, unspents) {
|
||||
if (err) return done(err)
|
||||
|
||||
// filter small unspents
|
||||
|
@ -50,7 +48,7 @@ describe('bitcoinjs-lib (multisig)', function() {
|
|||
var targetAddress = bitcoin.ECKey.makeRandom().pub.getAddress(bitcoin.networks.testnet).toString()
|
||||
|
||||
var txb = new bitcoin.TransactionBuilder()
|
||||
txb.addInput(unspent.txHash, unspent.index)
|
||||
txb.addInput(unspent.txId, unspent.vout)
|
||||
txb.addOutput(targetAddress, 1e4)
|
||||
|
||||
// sign w/ each private key
|
||||
|
@ -59,14 +57,14 @@ describe('bitcoinjs-lib (multisig)', function() {
|
|||
})
|
||||
|
||||
// broadcast our transaction
|
||||
helloblock.transactions.propagate(txb.build().toHex(), function(err) {
|
||||
blockchain.transactions.propagate(txb.build().toHex(), function(err) {
|
||||
if (err) return done(err)
|
||||
|
||||
// check that the funds (1e4 Satoshis) indeed arrived at the intended address
|
||||
helloblock.addresses.get(targetAddress, function(err, res, addrInfo) {
|
||||
blockchain.addresses.summary(targetAddress, function(err, result) {
|
||||
if (err) return done(err)
|
||||
|
||||
assert.equal(addrInfo.balance, 1e4)
|
||||
assert.equal(result.balance, 1e4)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue