From 4f995fcae1c0dc216d30aaddab5c51c95e13ee3b Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Fri, 13 Jun 2014 16:29:57 +1000 Subject: [PATCH] Transaction: tests should show unboxing of parameters --- test/transaction.js | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/test/transaction.js b/test/transaction.js index 0acf048..bcb3179 100644 --- a/test/transaction.js +++ b/test/transaction.js @@ -95,13 +95,15 @@ describe('Transaction', function() { }) describe('addInput', function() { - it('allows a Transaction object to be passed in', function() { - tx.addInput(prevTx, 0) + it('accepts a transaction hash', function() { + var prevTxHash = prevTx.getId() + + tx.addInput(prevTxHash, 0) verifyTransactionIn() }) - it('allows a Transaction hash to be passed in', function() { - tx.addInput("0cb859105100ebc3344f749c835c7af7d7103ec0d8cbc3d8ccbd5d28c3c36b57", 0) + it('accepts a Transaction object', function() { + tx.addInput(prevTx, 0) verifyTransactionIn() }) @@ -119,29 +121,25 @@ describe('Transaction', function() { }) describe('addOutput', function() { - it('allows an address and a value to be passed in', function() { - tx.addOutput("15mMHKL96tWAUtqF3tbVf99Z8arcmnJrr3", 40000) - verifyTransactionOut() - }) + it('accepts an address string', function() { + var dest = '15mMHKL96tWAUtqF3tbVf99Z8arcmnJrr3' - it('allows an Address object and value to be passed in', function() { - tx.addOutput(Address.fromBase58Check('15mMHKL96tWAUtqF3tbVf99Z8arcmnJrr3'), 40000) + tx.addOutput(dest, 40000) verifyTransactionOut() }) - it('allows a scriptPubKey and a value to be passed in', function() { - tx.addOutput(Address.fromBase58Check('15mMHKL96tWAUtqF3tbVf99Z8arcmnJrr3').toOutputScript(), 40000) + it('accepts an Address', function() { + var dest = Address.fromBase58Check('15mMHKL96tWAUtqF3tbVf99Z8arcmnJrr3') + + tx.addOutput(dest, 40000) verifyTransactionOut() }) - it('supports alternative networks', function() { - var address = Address.fromBase58Check('mkHJaNR7uuwRG1JrmTZsV4MszaTKjCBvCR') - var script = address.toOutputScript() + it('accepts a scriptPubKey', function() { + var dest = Address.fromBase58Check('15mMHKL96tWAUtqF3tbVf99Z8arcmnJrr3').toOutputScript() - tx.addOutput(address, 40000) + tx.addOutput(dest, 40000) verifyTransactionOut() - - assert.deepEqual(tx.outs[0].script, script) }) function verifyTransactionOut() {