The use of fixtures allows for more behavioural driven tests and simpler
addition of more test cases in future.
However, as ECPubKey is just a wrapper around other strenuously tested
modules, the test data is currently limited to testing a subset of the
total wrapper.
This should probably be done better by using mocked out modules instead.
After a long IRC discussion, it was decided that the use of direct
filepaths instead of the module is a more pure form of testing ,
although it may provide less overall coverage than the mixed integration
style imports used previously.
This will need to be remedied by further integration testing in
/test/integration.
It is favoured to compose the scriptSig manually using
Script.createP2SHScriptSig and Script.createMultisigScriptSig.
Added a test to verify that createMultisigScriptSig throws when not
enough signatures a provided and the redeemScript is given.
A Transaction (and its subsequent scripts) do not carry any network
specific information in the Bitcoin protocol.
Therefore they can not (without further context) produce the network
specific constants for the generation of the base58 Addresses.
As TransactionOut.address is used heavily throughout Wallet and other
areas of the library, this could not be entirely removed without a large
number of changes.
For now, TransactionOut.address is only defined in the case of
Tx.addOutput being used directly:
Transaction.addOutput(address, value)
The introduction of these two functions allow for the all the network
related code to be eventually removed from Transaction and Script.
Previously the result for non-standard transactions was undefined
behaviour. This change mandates that an exception is thrown if a
non-standard transaction is input.
Extracts the two Script types out of Script.createOutputScript, and puts
them both under test.
Also renames Script.createMultiSigOutputScript to adhere to the same
convention.
Script.fromHex previously existed, but was not under any kind of test.
This commit adds tests (despite being a little circular in nature) to
check that the output is as expected.
These functions are not under test, and are unnecessary bloat due to a
confusing API.
Script.from*(asmStr) were two functions that attempted to parse ASM
codes and produce a script from this.
While useful, an parser can be introduced later under a single function
and under test... removed.
Although Script.extractPublicKeys implementation is likely to be correct,
it is not absolute in that what it returns is even strictly a set of
public keys.
It is a useful function, but can be done in a better way later,
probably checking against the Script templates instead.
Transaction.signWithKeys has some inherent undocumented behaviour, and it is not
clear when you would use it over just Transaction.addOutput and
Transaction.sign individually. Nor does it mimic anything in the
bitcoind API... removed.
To keep this change minimal, both TxIn/TxOut still use the parameter
object for initialization. TxOut accepts only the types it uses
internally, and not hex or byte arrays for scripts.
The clone is unnecessary as a TransactionOut is never mutated after its
creation.
This resulted in TransactionOut.scriptPubKey no longer being needed,
and was removed. To access the scriptPubKey as a byte buffer, a user
can simply use:
TransactionOut.script.toBuffer()
Unfortunately, this leaves TransactionOut in a sorry state of test.
Something that needs to be fixed.