wallet.processTx accepts isPending flag and passes it on to output

This commit is contained in:
Wei Lu 2014-06-12 12:56:50 +08:00
parent ad9a73a81b
commit 660c95483d
2 changed files with 13 additions and 2 deletions

View file

@ -302,16 +302,26 @@ describe('Wallet', function() {
verifyOutputAdded(1)
})
describe("when the pending flag is set", function(){
it("sets the pending flag on output", function(){
wallet.addresses = [addresses[0]]
wallet.processTx(tx, true)
verifyOutputAdded(0, true)
})
})
function outputCount(){
return Object.keys(wallet.outputs).length
}
function verifyOutputAdded(index) {
function verifyOutputAdded(index, pending) {
var txOut = tx.outs[index]
var key = tx.getHash() + ":" + index
var output = wallet.outputs[key]
assert.equal(output.receive, key)
assert.equal(output.value, txOut.value)
assert.equal(output.pending, pending)
var txOutAddress = Address.fromScriptPubKey(txOut.script).toString()
assert.equal(output.address, txOutAddress)