Commit graph

288 commits

Author SHA1 Message Date
Pieter Wuille 4d480c8a3f Exception instead of assigning 0 in case of wrong vector length 2014-05-09 16:39:48 +02:00
Wladimir J. van der Laan e443ed2462
Fix transaction tests
Conflict between low-s (6fd7ef2) and test updates in d3a33fc.
2014-05-09 16:35:30 +02:00
Wladimir J. van der Laan 72f754cf51
Merge pull request #3637
6fd7ef2 Also switch the (unused) verification code to low-s instead of even-s. (Pieter Wuille)
2014-05-09 16:24:57 +02:00
Wladimir J. van der Laan 54f102248b
Merge pull request #3843
787ee0c Check redeemScript size does not exceed 520 byte limit (Peter Todd)
4d79098 Increase IsStandard() scriptSig length (Peter Todd)
f80cffa Do not trigger a DoS ban if SCRIPT_VERIFY_NULLDUMMY fails (Peter Todd)
6380180 Add rejection of non-null CHECKMULTISIG dummy values (Peter Todd)
29c1749 Let tx (in)valid tests use any SCRIPT_VERIFY flag (Peter Todd)
68f7d1d Create (MANDATORY|STANDARD)_SCRIPT_VERIFY_FLAGS constants (Peter Todd)
2014-05-09 16:09:20 +02:00
Wladimir J. van der Laan 1c0319bb2b
Merge pull request #3965
b1fdd54 script: Add test for CScriptNum (Cory Fields)
90320d6 script: add additional script tests (Cory Fields)
05e3ecf script: remove bignum dependency (Cory Fields)
4f497cd script: switch outside users to CScriptNum (Cory Fields)
27bff74 script: switch to CScriptNum usage for scripts (Cory Fields)
48d8eb1 script: add CScriptNum class (Cory Fields)
2014-05-09 16:03:07 +02:00
Gavin Andresen aaab675a78 Merge pull request #3860 from petertodd/test-checkmulti-n-m-zero
Test CHECKMULTISIG with m == 0 and/or n == 0
2014-05-09 10:00:16 -04:00
Peter Todd 6380180821 Add rejection of non-null CHECKMULTISIG dummy values
This is a source of transaction mutability as the dummy value was
previously not checked and could be modified to something other than the
usual OP_0 value.
2014-05-08 00:55:01 -04:00
Peter Todd 29c17498a5 Let tx (in)valid tests use any SCRIPT_VERIFY flag
Previously only P2SH could be set.
2014-05-05 05:59:59 -04:00
Wladimir J. van der Laan 1ab62973d3
Merge pull request #4074
d3081fa Removed LevelDB changes (super3)
2014-05-02 20:36:26 +02:00
super3 d3081fa231 Removed LevelDB changes
Syntax Highlighting
2014-05-01 12:10:06 -04:00
Wladimir J. van der Laan ed67100565 Add required locks in tests
Unit tests with DEBUG_LOCKORDER were running into assertions.
2014-04-23 08:05:05 +02:00
Cory Fields b1fdd5475d script: Add test for CScriptNum
Because this class replaces some usages of CBigNum, tests have been added to
verify that they function the same way. The only difference in their usage is
the handling of out-of-range numbers.

While operands are constrained to [-0x7FFFFFFF,0x7FFFFFFF], the results may
overflow. The overflowing result is technically unbounded, but in practice
it can be no bigger than the result of an operation on two operands. This
implementation limits them to the size of an int64.

CBigNum was unaware of this constraint, so it allowed for unbounded results,
which were then checked before use. CScriptNum asserts if an arithmetic
operation will overflow an int64_t, since scripts are not able to reach those
numbers anyway. Additionally, CScriptNum will throw an exception when
constructed from a vector containing more than 4 bytes This mimics the previous
CastToBigNum behavior.
2014-04-22 00:43:31 -04:00
Cory Fields 90320d6777 script: add additional script tests 2014-04-22 00:32:30 -04:00
Gavin Andresen 8556b0298d Merge pull request #3842 from ditto-b/master
Fix for GetBlockValue() after block 13,440,000
2014-04-02 21:31:17 -04:00
ditto-b 5cfd3a70a6 Edit subsidy_limit_test to account for BIP42
Because no one wants 4 gold mines being discovered every mibillenium.
2014-04-02 18:00:08 -05:00
Manuel Araoz 81bfb5aebf add checks for deserialization errors 2014-03-31 15:07:46 -03:00
Manuel Araoz 232aa9e034 Add code generating data/sighash.json test data 2014-03-31 12:39:32 -03:00
Manuel Araoz 43cb41859e Add sighash tests from data file 2014-03-31 11:19:19 -03:00
Wladimir J. van der Laan 95f0af5cb1
Merge pull request #3951
3cb1edb Update moved and dead links (Luke Dashjr)
2014-03-26 10:44:47 +01:00
Wladimir J. van der Laan e3f5d4338d
Fix test build after d138598
Building the tests was giving some vague error message about a doubly-defined
symbol.

The solution is to define ShutdownRequested in test_bitcoin.cpp as well
so that init.cpp does not get pulled in.
2014-03-25 07:54:53 +01:00
Luke Dashjr 3cb1edbfb6 Update moved and dead links 2014-03-24 20:26:02 +00:00
Wladimir J. van der Laan 3fc6846181 Add licenses for tests and test data
- Add license headers to source files (years based on commit dates)
  in `src/test` as well as `qa`
- Add `README.md` to `src/test/data` specifying MIT license

Fixes #3848
2014-03-18 10:20:55 +01:00
Wladimir J. van der Laan acfe60677c
Merge pull request #3650
2b45345 minor style cleanups (Philip Kaufmann)
2014-03-15 10:24:04 +01:00
Peter Todd d3a33fc869
Test CHECKMULTISIG with m == 0 and n == 0 2014-03-12 21:18:07 -04:00
Peter Todd b41e594773
Fix script test handling of empty scripts
Previously an empty script would evaluate to OP_0
2014-03-12 20:14:01 -04:00
Philip Kaufmann 2b45345aac minor style cleanups 2014-03-11 17:26:05 +01:00
Andreas Schildbach ffd082a6a3 Add script test to prove that OP_0 evaluates as the empty vector, rather than [0]. 2014-03-11 00:59:33 +01:00
Pieter Wuille 6fd7ef2bbf Also switch the (unused) verification code to low-s instead of even-s.
a81cd968 introduced a malleability breaker for signatures
(using an even value for S). In e0e14e43 this was changed to
the lower of two potential values, rather than the even one.
Only the signing code was changed though, the (for now unused)
verification code wasn't adapted.
2014-03-10 20:38:32 +01:00
Wladimir J. van der Laan b76733d8e8
Merge pull request #3514
f59d8f0 Per-peer block download tracking and stalled download detection. (Pieter Wuille)
2014-03-10 13:23:18 +01:00
Wladimir J. van der Laan c7c3262774
Merge pull request #3768
fecba4e Total money limit test (Pieter Wuille)
2014-03-07 08:59:03 +01:00
Pieter Wuille fecba4e269 Total money limit test
Added bounds check by @il--ya.

Updated-by: Wladimir van der Laan <laanwj@gmail.com>
2014-03-05 12:07:58 +01:00
Gavin Andresen ae7e5d7ceb Merge pull request #3737 from jgarzik/op-return-size
script: reduce OP_RETURN standard relay bytes to 40
2014-02-26 13:52:56 -05:00
Jeff Garzik 8175c790eb script: reduce OP_RETURN standard relay bytes to 40
Per mailing list discussion.
2014-02-26 12:58:08 -05:00
Gavin Andresen e3e65d29b7 Merge pull request #3735 from laanwj/2014_02_remove_PRIx64_completely
Remove PRIx64 usage completely
2014-02-26 12:16:03 -05:00
Wladimir J. van der Laan 12f5787d45
Merge pull request #3559
e6c6bc9 Adds additional zero checks for setCompact  These encoded values should all decode to zero (Noel Tiernan)
2014-02-25 16:25:52 +01:00
Wladimir J. van der Laan 3198604293
Merge pull request #3712
a3138ed add test of DecodeBase58 skipping whitespace (Christian von Roques)
2014-02-25 16:24:03 +01:00
Jeff Garzik beabca2be0 Merge pull request #3305 from mikehearn/fee_drop
Drop fees by 10x due to the persistently higher exchange rate.
2014-02-24 14:05:54 -05:00
Wladimir J. van der Laan f48742c2bf Get rid of C99 PRI?64 usage in source files
Amend to d5f1e72. It turns out that BerkelyDB was including inttypes.h
indirectly, so we cannot fix this with just macros.

Trivial commit: apply the following script to all .cpp and .h files:

    # Middle
    sed -i 's/"PRIx64"/x/g' "$1"
    sed -i 's/"PRIu64"/u/g' "$1"
    sed -i 's/"PRId64"/d/g' "$1"
    # Initial
    sed -i 's/PRIx64"/"x/g' "$1"
    sed -i 's/PRIu64"/"u/g' "$1"
    sed -i 's/PRId64"/"d/g' "$1"
    # Trailing
    sed -i 's/"PRIx64/x"/g' "$1"
    sed -i 's/"PRIu64/u"/g' "$1"
    sed -i 's/"PRId64/d"/g' "$1"

After this commit, `git grep` for PRI.64 should turn up nothing except
the defines in util.h.
2014-02-24 09:08:56 +01:00
Christian von Roques a3138ed42b add test of DecodeBase58 skipping whitespace 2014-02-21 01:01:48 +00:00
Pieter Wuille 87fe71e1fc Add HasCanonicalPushes(), and use it in IsStandardTx 2014-02-11 21:11:59 +01:00
Pieter Wuille f59d8f0b64 Per-peer block download tracking and stalled download detection.
Keep track of which block is being requested (and to be requested) from
each peer, and limit the number of blocks in-flight per peer. In addition,
detect stalled downloads, and disconnect if they persist for too long.

This means blocks are never requested twice, and should eliminate duplicate
downloads during synchronization.
2014-02-08 16:52:19 +01:00
Wladimir J. van der Laan 39d4eee96e
Merge pull request #3601
c32a486 Add more data-driven tests. (Matt Corallo)
2014-01-30 11:26:56 +01:00
Matt Corallo c32a486f4b Add more data-driven tests. 2014-01-30 03:53:52 -05:00
Wladimir J. van der Laan ca1913e8f6
Merge pull request #2342
665bdd3 Fix off-by-one errors in use of IsFinalTx() (Peter Todd)
2014-01-27 10:16:54 +01:00
Peter Todd 665bdd3bc9
Fix off-by-one errors in use of IsFinalTx()
Previously CreateNewBlock() didn't take into account the fact that
IsFinalTx() without any arguments tests if the transaction is considered
final in the *current* block, when both those functions really needed to
know if the transaction would be final in the *next* block.

Additionally the UI had a similar misunderstanding.

Also adds some basic tests to check that CreateNewBlock() is in fact
mining nLockTime-using transactions correctly.

Thanks to Wladimir J. van der Laan for rebase.
2014-01-26 21:50:15 -05:00
Gavin Andresen fd67424c82 Unit test fixes for AssertLockHeld / -DDEBUG_LOCKORDER
Unit tests would fail if compiled with -DDEBUG_LOCKORDER (AssertLockHeld()
would fail; AssertLockHeld() relies on the DEBUG_LOCKORDER code to keep
track of locks held).

Fixed by LOCK'ing the wallet mutex in the unit tests that manipulate the
wallet.
2014-01-24 10:47:29 -05:00
Noel Tiernan e6c6bc92f4 Adds additional zero checks for setCompact
These encoded values should all decode to zero

   Positive Numbers
    0x01003456 (1 byte  0x00)
    0x02000056 (2 bytes 0x0000)
    0x03000000 (3 bytes 0x000000)
    0x04000000 (4 bytes 0x000000_00)

   Negative Numbers
    0x00923456 -(0 bytes, so zero)
    0x01803456 -(1 byte  0x00)
    0x02800056 -(2 bytes 0x0000)
    0x03800000 -(3 bytes 0x000000)
    0x04800000 -(4 bytes 0x000000_00)
2014-01-19 13:55:08 +00:00
Philip Kaufmann c037531d69 small headers ordering cleanup
- keep headers in alphabetical order
- fix Makefile.am (2 files in 1 line - leftover)
- remove some spaces etc.
2014-01-11 18:17:09 +01:00
Wladimir J. van der Laan 5a407bd095
makefile.am: split long lines into one file per line
This makes it easier to read diffs.
Cosmetic change to build system only.
2014-01-11 15:23:15 +01:00
Wladimir J. van der Laan eaafa23cbd Add test for GetTime()
Test for mingw/wine issue #3494, where the upper word of time(NULL)
return value gets clobbered.
2014-01-09 11:35:38 +01:00