Add P2SH change address test

This commit is contained in:
Esteban Ordano 2014-12-16 20:33:45 -03:00
parent e396bc5dc6
commit c3ff63f041
1 changed files with 10 additions and 0 deletions

View File

@ -130,6 +130,7 @@ describe('Transaction', function() {
};
var toAddress = 'mrU9pEmAx26HcbKVrABvgL7AwA5fjNFoDc';
var changeAddress = 'mgBCJAsvzgT2qNNeXsoECg2uPKrUsZ76up';
var changeAddressP2SH = '2N7T3TAetJrSCruQ39aNrJvYLhG1LJosujf';
var privateKey = 'cSBnVM4xvxarwGQuAfQFwqDg9k5tErHUHzgWsEfD4zdwUasvqRVY';
it('can calculate simply the output amount', function() {
@ -143,6 +144,15 @@ describe('Transaction', function() {
transaction.outputs[1].script.toString()
.should.equal(Script.fromAddress(changeAddress).toString());
});
it('accepts a P2SH address for change', function() {
var transaction = new Transaction()
.from(simpleUtxoWith100000Satoshis)
.to(toAddress, 50000)
.change(changeAddressP2SH)
.sign(privateKey);
transaction.outputs.length.should.equal(2);
transaction.outputs[1].script.isScriptHashOut().should.equal(true);
});
it('can recalculate the change amount', function() {
var transaction = new Transaction()
.from(simpleUtxoWith100000Satoshis)