Work in progress. I have a problem with the verifyInput() callback calling itself whenever the test assertions throw an exception. I looked at the step and async libraries that are already installed via package.json, but I don't think either of these provide the functionality I need.
This commit is contained in:
parent
7257526de3
commit
5af02e937a
|
@ -505,7 +505,7 @@ Script.stringToBuffer = function(s) {
|
|||
//console.log('hex value');
|
||||
buf.put(new Buffer(word.substring(2, word.length), 'hex'));
|
||||
} else {
|
||||
var opcode = Opcode.map['OP_' + word];
|
||||
var opcode = Opcode.map['OP_' + word] || Opcode.map[word];
|
||||
if (typeof opcode !== 'undefined') {
|
||||
// op code in string form
|
||||
//console.log('opcode');
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
var chai = chai || require('chai');
|
||||
chai.Assertion.includeStack = true;
|
||||
var bitcore = bitcore || require('../bitcore');
|
||||
|
||||
var should = chai.should();
|
||||
|
@ -273,9 +274,10 @@ describe('Transaction', function() {
|
|||
inputs.forEach(function(vin) {
|
||||
var hash = vin[0];
|
||||
var index = vin[1];
|
||||
var scriptPubKey = new Script(new Buffer(vin[2]));
|
||||
debugger;
|
||||
var scriptPubKey = Script.fromHumanReadable(vin[2]);
|
||||
inputScriptPubKeys.push(scriptPubKey);
|
||||
console.log(scriptPubKey.getStringContent());
|
||||
console.log(scriptPubKey.toHumanReadable());
|
||||
console.log('********************************');
|
||||
done();
|
||||
|
||||
|
@ -288,11 +290,26 @@ describe('Transaction', function() {
|
|||
|
||||
var n = 0;
|
||||
inputScriptPubKeys.forEach(function(scriptPubKey) {
|
||||
tx.verifyInput(0, scriptPubKey, function(err, results) {
|
||||
should.not.exist(err);
|
||||
should.exist(results);
|
||||
results.should.equal(true);
|
||||
var err = undefined;
|
||||
var results = undefined;
|
||||
var inputVerified = false;
|
||||
|
||||
tx.verifyInput(n, scriptPubKey, function(e, r) {
|
||||
// Exceptions raised inside this function will be handled
|
||||
// ...by this function, so don't do it.
|
||||
err = e;
|
||||
results = r;
|
||||
inputVerified = true;
|
||||
});
|
||||
|
||||
// TODO(mattfaus): Add a Promise or something that makes this code
|
||||
// execute only after the verifyInput() callback has finished
|
||||
while (!inputVerified) { }
|
||||
|
||||
should.not.exist(err);
|
||||
should.exist(results);
|
||||
results.should.equal(true);
|
||||
|
||||
n += 1;
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue