Commit graph

171 commits

Author SHA1 Message Date
Dave Collins
8e6abdb125 Make several of the reg tests more consistent.
This commit modifies various regression tests to make them more consistent
with other tests throughout the code base.

Also, it allows of all the tests to run in parallel.
2015-01-29 14:41:18 -06:00
David Hill
f513518b4f Discourage NOPs reserved for soft-fork upgrades
NOP1 through NOP10 are reserved for future soft-fork upgrades.  When
such an upgrade occurs, the NOP argument will then require verification.
Rejecting transactions that contain these NOPs into the mempool will
discourage those transactions from being mined elsewhere and ensure
btcd will never mine such transactions.  This prevents now
invalid scripts (according to the majority of hashing power) even if the
client has not yet upgraded.

Non-executed upgradable NOPs are still allowed as they will still be
valid post-upgrade.

Mimics Bitcoin Core commit 03914234b3c9c35d66b51d580fe727a0707394ca
2015-01-29 11:36:03 -05:00
Dave Collins
af5cbe4b4f Update script builder for BIP0062 and enforce limits.
BIP0062 defines specific rules and canonical encodings for data pushes.

The existing script builder code already conformed to all but one of the
canonical data push rules that was added after it was originally
implemented (adding a single byte of 0x81 must be converted to
OP_1NEGATE).  This commit implements that case and expands the existing
tests to explicitly cover all cases mentioned in BIP0062.

In addition, as a part of this change, the AddData function has been
modified so that any attempt to push more than the maximum script element
size bytes (520) in one push or any pushes the would cause the script to
exceed the maximum script bytes allowed by the script engine (10000) will
result in the final call to the Script function to only return the script
up to the point of the first error along with the error. This change
should have little effect on existing callers since they are almost
positively not creating scripts which violate these rules as they could
never be executed, however it does mean they need to check the new error
return.

Since the regression tests intentionally need to be able to exceed that
limit, a new function named AddFullData has been added which does not
enforce the limits, but still provides canonical encoding of the pushed
data.

Note that this commit does not affect consensus rules nor modify the
script engine.

Also, the tests have been marked so they can run in parallel.
2015-01-28 23:30:35 -06:00
Dave Collins
251d0fc6c4 Update btcscript import paths to new location. 2015-01-16 19:41:02 -06:00
Dave Collins
eb02adfada Update btcec import paths to new location. 2015-01-16 18:05:06 -06:00
Dave Collins
f513a56a62 Update btcnet import paths to new location. 2015-01-16 17:29:53 -06:00
Dave Collins
5c52f67b4f Update btcwire import paths to new location. 2015-01-16 15:18:22 -06:00
Dave Collins
6efda349da Update btclog import paths to new location. 2015-01-16 11:18:14 -06:00
Dave Collins
6dcc6e5e66 Update fastsha256 import paths to new location. 2015-01-16 09:17:15 -06:00
Dave Collins
c112c004cf Update log test for upstream seelog changes. 2015-01-16 09:15:43 -06:00
Dave Collins
c4f1ed69d2 Update btcutil import paths to new location. 2015-01-15 10:42:26 -06:00
Dave Collins
8e1973d865 Correct a couple of typos spotted while reviewing. 2014-12-20 01:55:27 -06:00
Guilherme Salgado
2f902a5880 Rename signTxOutput to RawTxInSignature 2014-12-20 01:51:54 -06:00
David Hill
45e7fe103f Sync TX tests with Bitcoin Core. 2014-12-19 15:20:48 -05:00
Josh Rickmar
bca3d5ba7b Switch to new subrepo import paths. 2014-12-11 10:31:17 -05:00
David Hill
def35f2cd4 Sync Bitcoin Core tests. 2014-12-08 17:34:03 -05:00
Jonathan Gillham
a61c0f06cf Removed unnecessary signTxOutputCustomReader. 2014-10-13 13:47:44 +01:00
Jimmy Song
d5cc72dc27 use btcec structs instead of ecdsa structs 2014-10-12 23:47:09 -05:00
Dave Collins
ce0a334329 Comment ScriptInfo struct according to standards.
Found by golint.
2014-10-12 19:39:01 -05:00
Dave Collins
c0c3d860d6 Convert all StackErrX to ErrStackX.
This commit changes all stack errors from the form of StackErrX to
ErrStackX which is the expected form for standard Go code.
2014-10-12 17:24:00 -05:00
Jonathan Gillham
37ad7042b6 Made hashType typed as SigHashType. 2014-10-11 20:55:28 +01:00
Jonathan Gillham
9f47e9369c Fixed SignTxOutput doc spelling error. 2014-10-10 20:17:20 -05:00
kac-
b89cabfb29 comment:script.go: ScriptDB->KeyDB 2014-10-05 10:19:29 +02:00
Jonathan Gillham
edb006c11c Changed TxIn.PreviousOutpoint to TxIn.PreviousOutPoint after btcwire API change. 2014-10-01 13:57:27 +01:00
David Hill
2803ea17c2 Remove the use of go-spew. 2014-08-29 16:06:17 -04:00
Jonathan Gillham
516db23576 Replaced privkey in entire codebase. 2014-08-25 21:14:19 +01:00
Jonathan Gillham
da080e1598 Changed privkey to privKey for consistency. 2014-08-25 21:09:23 +01:00
Dave Collins
95cd1b97fa Make the OP_FALSE constant untyped.
This makes it consistent with the rest of the opcode constants.
2014-08-13 00:32:16 -05:00
Michalis Kargakis
6ae916bd37 More tests
Tests for IsPushOnlyScript, HasCanonicalPushes, and CalcMultiSigStats
2014-08-08 14:53:55 +03:00
Michalis Kargakis
55ad967b4d Complete SetLogWriter testing 2014-08-03 23:30:37 +03:00
David Hill
ef0ca7dff5 sync bitcoind script tests 2014-08-01 13:40:56 -04:00
Michalis Kargakis
24c3873956 Add log testing
8/10 of SetLogWriter tested
2014-07-31 23:42:09 +03:00
Dave Collins
95167204d9 Add ExtractPkScriptAddrs examples. 2014-07-08 14:59:57 -05:00
Dave Collins
631c7850ec Correct example link in README.md. 2014-07-08 14:43:50 -05:00
Dave Collins
abafe9678b Use testable example and update doc.go README.md.
This commit adds an example test file so it integrates nicely with Go's
example tooling.

This allows the example output to be tested as a part of running the
normal Go tests to help ensure it doesn't get out of date with the code.
It is also nice to have the example in one place rather than repeating it
in doc.go and README.md.

Links and information about the example have been included in README.md in
place of the example.
2014-07-08 14:42:39 -05:00
Dave Collins
3c2ae358b4 Add godoc reference badge to README.md. 2014-07-08 14:13:08 -05:00
Dave Collins
5beafbd2d8 goimports -w . 2014-07-02 19:37:49 -05:00
Dave Collins
79b6e51dff Update tests for recent btcutil.Address API change. 2014-07-02 19:36:41 -05:00
David Hill
7d228846bd sync tx_valid.json test data. 2014-06-13 11:34:47 -04:00
David Hill
e560b6d964 sync bitcoind test data. 2014-05-29 10:56:43 -04:00
David Hill
a591c7ec03 Add new ScriptFlag ScriptStrictMultiSig.
ScriptStrictMultiSig verifies that the stack item used by CHECKMULTISIG
is zero length.
2014-05-29 10:55:35 -04:00
Josh Rickmar
be325b9d9c Update API for btcnet and btcutil changes.
ok @davecgh
2014-05-27 17:42:01 -05:00
David Hill
27e1ad758b Add new function PushedData.
PushedData returns an array of byte slices containing any pushed data
found in the passed script.  This includes OP_0, but not OP_1 - OP_16.

help from and ok @owainga
2014-05-20 12:24:23 -04:00
Owain G. Ainsworth
6e2ba386dd Add an entypoint to sign and verify a transaction input.
This handles merging in of previous scripts, also. Add tests for the important
paths. ok @davecgh
2014-05-07 16:05:55 +01:00
David Hill
76e8fa9766 Reduce OP_RETURN standard relay bytes to 40.
This matches commit 8175c790eb12f0b0ca3197895a6d1d479b340b67 of
the reference software.
2014-05-01 09:42:15 -04:00
David Hill
1240483592 gofmt 2014-04-11 14:54:44 -04:00
Owain G. Ainsworth
03dd134305 adapt for btcec changes. 2014-04-09 19:30:59 +01:00
Dave Collins
4fce6d1476 Sync latest script tests to bitcoind test suite. 2014-04-03 23:18:52 -05:00
Dave Collins
f529a37123 Add tests for doing math on 5-byte ints.
This commit addes a couple of tests to ensure performing math operations
on a 5-byte integer, even if the result is a 4-byte integer, is considered
invalid.
2014-04-03 17:13:44 -05:00
Owain G. Ainsworth
8ec60d4678 Quick and dirty tests harnesses using some bitcoind test data.
Both the script tests (positive and negative) and tx texts (ditto) are
present.  Some of the tx tests in the negative section have been
replaced by a comment line explaining why that test is elided, to add in
diffing. The reasons were always that they test things handled by other
parts of the btcd stack (normally chain). For example MAX_MONEY, number
of outputs, coinbase sizes etc.

Much of the inital test logic from @dajohi using hand transcribed tables
for selected tests. The json parsers, script format parser and a lot of
cleaning up/bugfixing from your truly. @davecgh had some input too.
2014-03-19 01:06:19 +00:00