Commit graph

1360 commits

Author SHA1 Message Date
Pieter Wuille 5cd00bc8cb
Merge pull request #4618
eb0b56b Simplify serialize.h's exception handling (Pieter Wuille)
2014-08-24 02:06:09 +02:00
jtimon 654871d436 replace ComputeMinWork with CheckMinWork 2014-08-23 13:21:51 +02:00
Jeff Garzik fac54dcb71
Merge pull request #4733 2014-08-22 10:35:39 -04:00
Jeff Garzik 9c31174992
Merge pull request #4744 2014-08-20 23:16:21 -04:00
Jeff Garzik 7f836c66bd rpc_tests: use BOOST_CHECK_EQUAL
Upon failure, BOOST_CHECK_EQUAL provides additional diagnostic information,
displaying that data that failed to match.
2014-08-20 22:43:36 -04:00
Jeff Garzik dc271fc025 UniValue tests: use more BOOST_CHECK() 2014-08-20 01:09:21 -04:00
Jeff Garzik e85267be63 UniValue: add unit tests 2014-08-20 00:28:46 -04:00
Jeff Garzik df4d61e681 Add bitcoin-tx tests
Testing: delin, delout, locktime, and basic createrawtransaction-like
functionality.
2014-08-19 23:15:58 -04:00
Jeff Garzik fb14452c6c bitcoin-tx: Accept input via stdin. Add input handling to tests. 2014-08-19 10:29:10 -04:00
Jeff Garzik d789386371 Add "it works" test for bitcoin-tx 2014-08-19 10:28:58 -04:00
Pieter Wuille eb0b56b190 Simplify serialize.h's exception handling
Remove the 'state' and 'exceptmask' from serialize.h's stream implementations,
as well as related methods.

As exceptmask always included 'failbit', and setstate was always called with
bits = failbit, all it did was immediately raise an exception. Get rid of
those variables, and replace the setstate with direct exception throwing
(which also removes some dead code).

As a result, good() is never reached after a failure (there are only 2
calls, one of which is in tests), and can just be replaced by !eof().

fail(), clear(n) and exceptions() are just never called. Delete them.
2014-08-09 01:43:23 +02:00
jtimon f5745fa52a Declare SignatureHash() in script.h 2014-08-01 17:45:09 +02:00
Wladimir J. van der Laan b7bba43a14
Merge pull request #4560
d2d9dc0 script tests: add tests for CHECKMULTISIG limits (Otto Allmendinger)
89101c6 script test: test case for 5-byte bools (Otto Allmendinger)
4cac5db script tests: value with trailing 0x00 is true (Otto Allmendinger)
833ff16 script tests: values that overflow to 0 are true (Otto Allmendinger)
0072d98 script tests: BOOLAND, BOOLOR decode to integer (Otto Allmendinger)
ed02282 additional test for OP_SIZE in script_valid.json (Otto Allmendinger)
2014-07-31 09:42:00 +02:00
Wladimir J. van der Laan 2870014f3a
Merge pull request #4568
9c34731 CBloomFilter::clear() method (Tom Harding)
2014-07-31 09:25:20 +02:00
Jeff Garzik b2aeaa7939 Move ParseScript() helper, becoming accessible outside src/test/ 2014-07-29 11:13:27 -04:00
Tom Harding 9c347313f7 CBloomFilter::clear() method 2014-07-21 11:50:07 -07:00
Wladimir J. van der Laan 8f3f94a470 Revert "CBloomFilter::clear() method"
This reverts commit 8fbf03995d.
2014-07-21 07:46:34 +02:00
Otto Allmendinger d2d9dc063f script tests: add tests for CHECKMULTISIG limits 2014-07-18 17:55:06 +02:00
Otto Allmendinger 89101c6e78 script test: test case for 5-byte bools 2014-07-18 15:41:45 +02:00
Otto Allmendinger 4cac5dbf83 script tests: value with trailing 0x00 is true 2014-07-18 12:55:46 +02:00
Otto Allmendinger 833ff161bc script tests: values that overflow to 0 are true 2014-07-18 11:02:28 +02:00
Otto Allmendinger 0072d98849 script tests: BOOLAND, BOOLOR decode to integer
unlike other boolean checks, arguments >5 bytes invalidate the script
2014-07-18 10:53:09 +02:00
Otto Allmendinger ed02282bba additional test for OP_SIZE in script_valid.json 2014-07-18 10:29:49 +02:00
Philip Kaufmann 6354935c48 move rand functions from util to new random.h/.cpp 2014-07-09 09:42:19 +02:00
Luke Dashjr 2227725fcb test/bloom_tests: Use UL suffix for unsigned long number to ensure compatibility 2014-07-07 15:42:59 +00:00
Wladimir J. van der Laan f748ff730b
Merge pull request #4045
a3e192a replaced MINE_ with ISMINE_ (JaSK)
53a2148 fixed bug where validateaddress doesn't display information (JaSK)
f28707a fixed bug in ListReceived() (JaSK)
519dd1c Added MINE_ALL = (spendable|watchonly) (JaSK)
23b0506 Fixed some stuff in TransactionDesc (JaSK)
80dda36 removed default argument values for ismine filter (JaSK)
d5087d1 Use script matching rather than destination matching for watch-only. (Pieter Wuille)
0fa2f88 added includedWatchonly argument to listreceivedbyaddress/...account (JaSK)
f87ba3d added includeWatchonly argument to 'gettransaction' because it affects balance calculation (JaSK)
a5c6c5d fixed tiny glitch and improved readability like laanwj suggested (JaSK)
d7d5d23 Added argument to listtransactions and listsinceblock to include watchonly addresses (JaSK)
952877e Showing 'involvesWatchonly' property for transactions returned by 'listtransactions' and 'listsinceblock'. It is only appended when the transaction involves a watchonly address. (JaSK)
83f3543 Added argument to listaccounts to include watchonly addresses (JaSK)
d4640d7 Added argument to getbalance to include watchonly addresses and fixed errors in balance calculation. (JaSK)
d2692f6 Watchonly transactions are marked in transaction history (JaSK)
ffd40da Watchonly balances are shown separately in gui. (JaSK)
2935b21 qt: Hide unspendable outputs in coin control (Wladimir J. van der Laan)
c898846 Add support for watch-only addresses (Pieter Wuille)
2014-07-07 16:06:28 +02:00
Wladimir J. van der Laan 5e1b7a23b0
Merge pull request #4470
f4b00be Add CChain::GetLocator() unit test (Pieter Wuille)
3c85d2e Fix CChain::GetLocator (Pieter Wuille)
2014-07-07 10:28:09 +02:00
Wladimir J. van der Laan 73ac7abd08 Move ui_interface to bitcoin_server.a
There is no need for it in the utility libraries or tools.
Put it in init.cpp, and in the tests separately (as they can't link init).
2014-07-07 09:58:56 +02:00
Pieter Wuille f4b00beae5 Add CChain::GetLocator() unit test 2014-07-06 14:40:31 +02:00
Pieter Wuille c8988460a2 Add support for watch-only addresses
Changes:
* Add Add/Have WatchOnly methods to CKeyStore, and implementations
  in CBasicKeyStore.
* Add similar methods to CWallet, and support entries for it in
  CWalletDB.
* Make IsMine in script/wallet return a new enum 'isminetype',
  rather than a boolean. This allows distinguishing between
  spendable and unspendable coins.
* Add a field fSpendable to COutput (GetAvailableCoins' return type).
* Mark watchonly coins in listunspent as 'watchonly': true.
* Add 'watchonly' to validateaddress, suppressing script/pubkey/...
  in this case.

Based on a patch by Eric Lombrozo.

Conflicts:
	src/qt/walletmodel.cpp
	src/rpcserver.cpp
	src/wallet.cpp
2014-07-02 15:48:37 +02:00
Wladimir J. van der Laan 3faf1f8294
test: Fix warning about integer signedness in P2SH tests 2014-06-30 16:37:59 +02:00
Gavin Andresen 8ceb28afc3 Merge pull request #3883 from dgenr8/first_double_spend
Relay and alert user to double spends
2014-06-30 08:35:12 -04:00
Pieter Wuille 236982c2b6 Add skiplist unit tests 2014-06-29 21:51:55 +02:00
Tom Harding 8fbf03995d CBloomFilter::clear() method 2014-06-27 07:54:21 -07:00
Gavin Andresen 6259937388 Merge pull request #4365 from gavinandresen/relax_isstandard
Relax IsStandard rules for pay-to-script-hash transactions
2014-06-27 10:53:24 -04:00
Gavin Andresen a90689ff98
Remove timing-based signature cache unit test
Two changes:

First removes a unit test that fails in my development environment
(OSX, compiled -g3 with clang).

sipa says that's not terribly surprising; the CMutableTransaction change
makes signing a little more expensive but verification quicker. The unit
test timed sign+verify-uncached versus verify-cached-five-times.

He also says the test will be invalid when libsec256kp1 is integrated
(because validation is super-optimized over signing).

core.h change fixes a compiler warning (clang -Wall : CMutableTransaction defined
as struct, declared as class in script.h).
2014-06-25 14:57:21 -04:00
Wladimir J. van der Laan 84ce18ca93 Remove unnecessary dependencies for bitcoin-cli
This commit removes all the unnecessary dependencies (key, core,
netbase, sync, ...) from bitcoin-cli.

To do this it shards the chain parameters into BaseParams, which
contains just the RPC port and data directory (as used by utils and
bitcoin-cli) and Params, with the rest.
2014-06-25 10:31:35 +02:00
jtimon df852d2bcc Refactor proof of work related functions out of main 2014-06-23 23:10:24 +02:00
Gavin Andresen 7f3b4e9569
Relax IsStandard rules for pay-to-script-hash transactions
Relax the AreInputsStandard() tests for P2SH transactions --
allow any Script in a P2SH transaction to be relayed/mined,
as long as it has 15 or fewer signature operations.

Rationale: https://gist.github.com/gavinandresen/88be40c141bc67acb247

I don't have an easy way to test this, but the code changes are
straightforward and I've updated the AreInputsStandard unit tests.
2014-06-23 15:09:52 -04:00
Pieter Wuille d38da59bf6 Code simplifications after CTransaction::GetHash() caching 2014-06-22 00:06:17 +02:00
Pieter Wuille 4949004d68 Add CMutableTransaction and make CTransaction immutable.
In addition, introduce a cached hash inside CTransaction, to prevent
recalculating it over and over again.
2014-06-21 22:59:03 +02:00
Pieter Wuille a0495bb68c Add <Hasher>::OUTPUT_SIZE 2014-06-21 19:47:43 +02:00
Pieter Wuille 3820e01eb9 Extend and move all crypto tests to crypto_tests.cpp 2014-06-21 19:47:43 +02:00
Pieter Wuille 13b5dfef64 Move crypto implementations to src/crypto/ 2014-06-21 19:47:42 +02:00
Pieter Wuille 1cc344ce42 Add built-in SHA-1 implementation. 2014-06-21 19:47:39 +02:00
Pieter Wuille 85aab2a088 Switch miner.cpp to use sha2 instead of OpenSSL. 2014-06-21 19:47:39 +02:00
Pieter Wuille 977cdadea8 Add a built-in SHA256/SHA512 implementation.
This also moves the HMAC-SHA512 implementation to sha2.cpp.
2014-06-21 19:47:39 +02:00
Wladimir J. van der Laan 97789d374c util: Add function FormatParagraph to format paragraph to fixed-width
This is to be used for the `-version` and `-help` messages.
2014-06-11 14:27:09 +02:00
Cory Fields 8b09ef7b63 build: add stub makefiles for easier subdir builds 2014-06-05 16:05:43 -04:00
Cory Fields be4e9aeb14 build: delete old Makefile.am's 2014-06-05 16:05:42 -04:00
Wladimir J. van der Laan 73b072252b
Merge pull request #3837
75ebced added many rpc wallet tests (Alon Muroch)
2014-06-02 18:00:37 +02:00
Wladimir J. van der Laan ead1f65256
Merge pull request #4268
223a6f7 Fix stray uppercase A in tx_valid.json. (Andreas Schildbach)
2014-06-02 10:54:20 +02:00
Andreas Schildbach 223a6f7800 Fix stray uppercase A in tx_valid.json. 2014-06-01 15:25:21 +02:00
Wladimir J. van der Laan bdc7f1a101
Merge pull request #3861
9ec0306 Add CODESEPARATOR/FindAndDelete() tests (Peter Todd)
2014-05-27 09:41:00 +02:00
Wladimir J. van der Laan 3e8ac6af9a
Replace non-threadsafe gmtime and setlocale
Make DateTimeStrFormat use boost::posix_time.

Also re-enable the util_DateTimeStrFormat tests, as they are no
longer platform specific.
2014-05-23 15:23:11 +02:00
Federico Bond f25e3adf7d Fix build in OS X 10.9 2014-05-13 01:39:42 -03:00
Wladimir J. van der Laan c3ad56f4e0
Merge pull request #4138
783b182 Remove dummy PRIszX macros for formatting (Wladimir J. van der Laan)
2014-05-12 14:01:48 +02:00
Wladimir J. van der Laan 68d5fb3cb3
Merge pull request #4165
f6b7c64 Move base58.h implementation code to base58.cpp (Pieter Wuille)
2014-05-12 13:52:03 +02:00
Peter Todd 9ec030622f
Add CODESEPARATOR/FindAndDelete() tests 2014-05-12 06:51:41 -04:00
Wladimir J. van der Laan 2653e00b12
Merge pull request #4160
7cd0af7 Move bignum.h to test/ (Pieter Wuille)
ccc84e0 Reduce bignum.h now it is only needed for scriptnum_tests (Pieter Wuille)
2014-05-10 15:32:18 +02:00
Pieter Wuille f6b7c644c9 Move base58.h implementation code to base58.cpp 2014-05-10 00:42:31 +02:00
Pieter Wuille 7cd0af7cc2 Move bignum.h to test/ 2014-05-09 17:56:16 +02:00
Pieter Wuille ccc84e0963 Reduce bignum.h now it is only needed for scriptnum_tests 2014-05-09 17:38:44 +02:00
Wladimir J. van der Laan 605d5b5558
Merge pull request #4102
21bf3d2 Add tests for BoostAsioToCNetAddr (Wladimir J. van der Laan)
fdbd707 Remove unused function WildcardMatch (Wladimir J. van der Laan)
ee21912 rpc: Use netmasks instead of wildcards for IP address matching (Wladimir J. van der Laan)
e16be73 net: Add CSubNet class for subnet matching (Wladimir J. van der Laan)
d864275 Use new function parseint32 in SplitHostPort (Wladimir J. van der Laan)
0d4ea1c util: add parseint32 function with strict error reporting (Wladimir J. van der Laan)
2014-05-09 17:26:42 +02:00
Wladimir J. van der Laan 21bf3d257b Add tests for BoostAsioToCNetAddr 2014-05-09 16:45:57 +02:00
Wladimir J. van der Laan fdbd7075ca Remove unused function WildcardMatch
No longer necessary after implementing netmask-based matching.
Also remove a longer-unused function `skipspaces`.
2014-05-09 16:45:57 +02:00
Wladimir J. van der Laan e16be73753 net: Add CSubNet class for subnet matching 2014-05-09 16:45:57 +02:00
Wladimir J. van der Laan 0d4ea1cf8a util: add parseint32 function with strict error reporting
None of the current integer parsing functions in util
check whether the result is valid and fits in the range
of the type. This is required for less sloppy error reporting.
2014-05-09 16:45:56 +02:00
Pieter Wuille df9eb5e14f Move {Get,Set}Compact from bignum to uint256 2014-05-09 16:44:59 +02:00
Pieter Wuille a7031507e6 Add multiplication and division to uint160/uint256 2014-05-09 16:39:48 +02:00
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
Wladimir J. van der Laan 783b182c8f Remove dummy PRIszX macros for formatting
Size specifiers are no longer needed now that we use typesafe tinyformat
for string formatting, instead of the system's sprintf.

No functional changes.

This continues the work in #3735.
2014-05-06 15:29:16 +02: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
Alon Muroch 75ebced499 added many rpc wallet tests
deleted the empty no throw test in rpc_wallet_tests line 65

fixed some comments

starting verify tests

finished verify message tests

changed some comments
2014-04-01 16:08:53 +02: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
Thomas Holenstein daa6b20e29 Unittests for uint256.h
Unit tests for uint256.h. The file uint160_tests.cpp is no longer
needed. The ad-hoc tests which were in uint256.h are also no longer
needed. The new tests achieve 100% coverage.
2013-12-25 11:07:21 +01:00
Wladimir J. van der Laan f498d43ee2
Merge pull request #3416
9e9056c Remove -logtodebugger (Wladimir J. van der Laan)
2013-12-20 15:03:41 +01:00
Thomas Holenstein df840de5da
Make bitcoin compile without wallet if "db_cxx.h" is not present
Moved includes of "db.h" into #ifdef ENABLE_WALLET blocks or remove
them.
2013-12-19 10:46:41 +01:00
Kangmo 0205abd83d Improve unit test code not to compare with explanatory messages for each platform.
Instead, use have an exception object to check if the string returned by what() on the raised exception matches the string returned by what() on the expected exception instance.
This way, we do not need to list all different possible explanatory strings for different platforms in the test code, and make it simple. (The idea is by Cory Fields.)
2013-12-16 09:26:04 +09:00
Kangmo bccd5324ab Fix unit test error on OSX 10.9 using Apple LLVM v5.0.
Before the fix, there were 6 errors such as :
serialize_tests.cpp:77: error in "noncanonical": incorrect exception std::ios_base::failure is caught

It turns out that ex.what() returns following string instead of "non-canonical ReadCompactSize()"
"non-canonical ReadCompactSize(): unspecified iostream_category error"

After the fix, unit test passed.

The test ran using Apple LLVM v5.0 on OSX 10.9 and the unit test error happened because of different error messages by different compilers.

g++ --version on my development environment.

```
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
```
2013-12-15 23:25:41 +09:00
Wladimir J. van der Laan 9e9056cd1a Remove -logtodebugger
`-logtodebugger` is a strange, obscure, WIN32-only (mostly MSVC) thing.
Let's clean up the options a bit get rid of it.

test_bitcoin was using fLogToDebugger as a way to prevent logging to
debug.log. For this, add a boolean (not exposed as option) fLogToDebugLog that
defaults to true and is disabled in the tests.
2013-12-15 10:12:38 +01:00
Tamas Blummer 3e01c00f42 Add tests for correct and incorrect order of signatures for a multisig
(P2SH)
2013-12-11 00:03:50 +01:00
Gavin Andresen d47bbbd261 Merge pull request #3368 from laanwj/2013_11_disable_wallet_mining
Allow mining RPCs with --disable-wallet
2013-12-09 19:36:39 -08:00
Wladimir J. van der Laan fbc7a96d03 Re-enable miner tests in --disable-wallet mode
Use a fixed script instead of a CReserveKey from the wallet.
This does not affect the functionality or result of the tests as they never
check the state of the wallet in the first place.
2013-12-09 09:25:10 +01:00
Pieter Wuille b2864d2fb3 Add main-specific node state 2013-12-08 14:51:37 +01:00
Wladimir J. van der Laan 5094f8d46f Split off rpc_wallet_tests
Split wallet tests from other RPC tests.
Now no #ifdef ENABLE_WALLET are needed anymore in either file.
2013-12-04 12:46:14 +01:00
Wladimir J. van der Laan 4f9e993bc9 Add --disable-wallet option to build system
Make it possible to build Bitcoin without wallet
(and thus without BDB) so that it only functions as node.
2013-12-04 12:46:13 +01:00
Wladimir J. van der Laan 48ba56cdfd Delimit code with #ifdef ENABLE_WALLET
Delimit all code that uses the wallet functions
in implementation files that conditionally use the wallet.
2013-12-04 12:46:13 +01:00
Gavin Andresen cf74e8cb5e Merge pull request #3320 from laanwj/2013_11_cli_split
bitcoin-cli: remove unneeded dependencies (only minor code movement)
2013-12-03 03:47:44 -08:00
Wladimir J. van der Laan 0b47fe6bdc bitcoin-cli: remove unneeded dependencies (only code movement)
Remove unnecessary dependencies for bitcoin-cli
(leveldb, berkelydb, wallet, RPC server)

Build system changes:
- split libbitcoin.a into libbitcoin_common.a, libbitcoin_server.a and
  libbitcoin_cli.a

Code changes (movement only):
- split up HelpMessage into HelpMessage in init.cpp and HelpMessageCli
  in rpcclient.cpp
- move uiInterface from init.cpp to util.cpp
2013-12-03 09:07:13 +01:00
Gavin Andresen 49dc3a0f1a Make unit tests succeed with -DDEBUG_LOCKORDER 2013-12-02 13:11:21 +10:00
Gavin Andresen 4d707d5120 Add verbose boolean to getrawmempool
Also changes mempool to store CTxMemPoolEntries
to keep track of when they enter/exit the pool.
2013-11-30 15:42:10 +10:00
Wladimir J. van der Laan fb78cc2378 Split up bitcoinrpc (code movement only)
Split bitcoinrpc up into

- rpcserver: bitcoind RPC server
- rpcclient: bitcoin-cli RPC client
- rpcprotocol: shared common HTTP/JSON-RPC protocol code

One step towards making bitcoin-cli independent from the rest
of the code, and thus a smaller executable that doesn't have to
be linked against leveldb.

This commit only does code movement, there are no functional changes.
2013-11-27 06:00:29 +01:00
Mike Hearn 6a4c196dd6 Drop fees by 10x due to the persistently higher exchange rate.
The last fee drop was by 5x (from 50k satoshis to 10k satoshis)
in the 0.8.2 release which was about 6 months ago.

The current fee is (assuming a $500 exchange rate) about 5 dollar
cents. The new fee after this patch is 0.5 cents.

Miners who prefer the higher fees are obviously still able to
use the command line flags to override this setting. Miners who
choose to create smaller blocks will select the highest-fee paying
transactions anyway.

This would hopefully be the last manual adjustment ever required
before floating fees become normal.
2013-11-26 15:56:28 +04:00
Wladimir J. van der Laan c82788efff tests: add testcases for strprintf 2013-11-13 17:02:27 +01:00
Luke Dashjr eb12a14da7 configure: Simplify common AM_CPPFLAGS and AM_LDFLAGS to a Makefile.common 2013-11-11 09:57:28 +01:00
Gavin Andresen feaec80cb0 Test alerts high at high PROTOCOL_VERSIONs
I regenerated the alert test data; now alerts are tested
against a protocol version way above the current protocol
version.

So we won't have to regenerate them every time we bump
PROTOCOL_VERSION in the future.
2013-11-11 10:31:08 +10:00
Brandon Dahler 51ed9ec971 Cleanup code using forward declarations.
Use misc methods of avoiding unnecesary header includes.
Replace int typedefs with int##_t from stdint.h.
Replace PRI64[xdu] with PRI[xdu]64 from inttypes.h.
Normalize QT_VERSION ifs where possible.
Resolve some indirect dependencies as direct ones.
Remove extern declarations from .cpp files.
2013-11-10 09:36:28 -06:00
Wladimir J. van der Laan 995cb284cf Merge pull request #3223 from TheBlueMatt/master
Test changes
2013-11-08 09:48:30 -08:00
Matt Corallo eacc6f4a26 Add a few more basic script/tx test-cases. 2013-11-08 12:34:12 -05:00
Wladimir J. van der Laan bac72640ee Merge pull request #3076 from lano1106/uint256_util
Make util phexdigit array reusable
2013-11-04 05:55:37 -08:00
Gavin Andresen 837369806a Merge pull request #3128
0056095 Show short scriptPubKeys correctly (Peter Todd)
22de68d Relay OP_RETURN TxOut as standard transaction type (Peter Todd)

Signed-off-by: Gavin Andresen <gavinandresen@gmail.com>
2013-11-01 12:13:38 +10:00
Gavin Andresen d5d1425657 Bug fix: CDataStream::GetAndClear() when nReadPos > 0
Changed CDataStream::GetAndClear() to use the most obvious
get get and clear instead of a tricky swap().

Added a unit test for CDataStream insert/erase/GetAndClear.

Note: GetAndClear() is not performance critical, it is used only
by the send-a-message-to-the-network code. Bug was not noticed
before now because the send-a-message code never erased from the
stream.
2013-10-29 11:20:14 +10:00
Olivier Langlois f171ec0c7d Make util phexdigit array reusable
class template base_uint had its own private lookup table.
This is saving 256 bytes per instantiation.

The result is not spectacular as bitcoin-qt has only shrinked of
about 1Kb but it is still valid improvement.

Also, I have replaced a for loop with a memset() call.

Made CBigNum::SetHex() use the new HexDigit() function.

Signed-off-by: Olivier Langlois <olivier@olivierlanglois.net>
2013-10-27 23:04:52 -04:00
Peter Todd 22de68dffc
Relay OP_RETURN TxOut as standard transaction type
Also fix decoderawtransaction to not show reqSigs or addresses for
nulldata txouts. (Previous version also left reqSigs uninitialized
mistakenly)
2013-10-24 04:32:35 -04:00
Wladimir J. van der Laan 840905a8fd Add test for monetary value parsing
Just-in-case sanity test for JSON spirit and AmountFromValue.
Also update rpc_format_monetary_values test to use ValueFromAmount,
so that ValueFromAmount is also tested.
2013-10-23 13:37:51 +02:00
Wladimir J. van der Laan 4538130790 Add test for monetary value formatting
Tests for issue #3126.
This problem pops up after upgrading json-spirit.
2013-10-23 09:42:48 +02:00
Jeff Garzik 0db9a805bd Revert "Switch to using raw_utf8"
This reverts commit 2ecb7555a9.
2013-10-22 05:43:38 -04:00
Gavin Andresen 125bdead3e Merge pull request #2740 from constantined/constantined
UTF-8 support for JSON-RPC
2013-10-22 01:20:02 -07:00
Gavin Andresen be484db274 Merge pull request #2738 from jgarzik/op_return
Relay OP_RETURN data TxOut as standard transaction type.
2013-10-21 22:47:24 -07:00
Gavin Andresen f90b690a0d Merge pull request #2884 from gavinandresen/canonicalsizes2
Reject non-canonically-encoded CompactSize
2013-10-19 23:03:04 -07:00
Gavin Andresen 5a8a4be289 Merge pull request #2645 from sipa/inlinesighash
Inline signature serializer
2013-10-16 17:53:31 -07:00
Pieter Wuille 4c6d41b8b6 Refactor/encapsulate chain globals into a CChain class 2013-10-11 23:25:50 +02:00
Jeff Garzik a79342479f Relay OP_RETURN data TxOut as standard transaction type 2013-10-02 11:49:43 -04:00
Pieter Wuille 6865127551 Merge pull request #3015 from theuni/win32-version-info
Win32 version info
2013-09-29 06:49:23 -07:00
Pieter Wuille f5857e5cb5 Inline signature serializer
Instead of building a full copy of a CTransaction being signed, and
then modifying bits and pieces until its fits the form necessary
for computing the signature hash, use a wrapper serializer that
only serializes the necessary bits on-the-fly.

This makes it easier to see which data is actually being hash,
reduces load on the heap, and also marginally improves performances
(around 3-4us/sigcheck here). The performance improvements are much
larger for large transactions, though.

The old implementation of SignatureHash is moved to a unit tests,
to test whether the old and new algorithm result in the same value
for randomly-constructed transactions.
2013-09-28 18:37:00 +02:00
Pieter Wuille 1657ed2ab4 Fix minor unit test memory leaks 2013-09-19 00:01:46 +02:00
Cory Fields 7a3df1cd94 autotools: fix the Makefile.include to be safely included anywhere.
This way we can reuse rules rather than duplicating them.
2013-09-18 17:12:39 -04:00
Cory Fields 152e51c7af included-tests: generate binary data from test files for inclusion into test binaries
This change moves test data into the binaries rather than reading them from
the disk at runtime.

Advantages:
- Tests become distributable
- Cross-compile friendly. Build on one machine and execute in an arbitrary
  location on another.
- Easier testing for backports. Users can verify that tests pass without having
  to track down corresponding test data.
- More trustworthy test results and easier quality assurance as tests make
  fewer assumptions about their environment.
- Tests could theoretically run at client/daemon startup and exit on failure.

Disadvantages:
- Required 'hexdump' build-dependency. This is a standard bsd tool that should
  be usable everywhere. It is likely already installed on all build-machines.
- Tests can no longer be fudged after build by altering test-data.
2013-09-16 12:53:11 -04:00
Luke Dashjr 1e9d3b1392 Bugfix: Since test_bitcoin is being built and run inside src/test/, try using relative directories from that point 2013-09-10 23:04:56 +00:00
Cory Fields b4d8d03b86 autotools: use an absolute path to test data 2013-09-10 18:23:22 -04:00
Cory Fields 35b8af9226 autotools: switch to autotools buildsystem 2013-09-05 21:31:03 -04:00
Jeff Garzik bb7d0fc12f Merge pull request #2928 from jgarzik/cnb-txout
CreateNewBlock / getblocktemplate cleaning
2013-08-25 18:49:25 -07:00
Peter Todd 214d45b6b9
Document and test OP_RESERVED weirdness
Seems it was forgotten about when IsPushOnly() and the unittests were
written. A particular oddity is that OP_RESERVED doesn't count towards
the >201 opcode limit unlike every other named opcode.
2013-08-25 12:37:07 -04:00
Jeff Garzik 7e17018995 CreateNewBlock() now takes scriptPubKey argument,
rather than a key.

CreateNewBlockWithKey() helper is added to restore existing functionality,
making this an equivalent-transformation change.
2013-08-24 00:33:46 -04:00
Peter Todd 4eecdcacaf
Add MurmurHash3() unit test
Useful as a source of test vectors to anyone re-implementing bloom
filters.
2013-08-20 07:30:39 -04:00
Gavin Andresen 3f20f82209 Merge pull request #2880 from gavinandresen/test_numequal
More unit tests for OP_NUMEQUAL
2013-08-15 18:53:49 -07:00
Gavin Andresen a0bb001431 Merge pull request #2886 from gavinandresen/rpctiming
Make RPC password resistant to timing attacks
2013-08-15 18:53:26 -07:00
Gregory Maxwell 47491a90b6 Merge pull request #2131 from sipa/evens
Only create signatures with even S, and verification mode to check.
2013-08-15 18:42:28 -07:00
Gavin Andresen 13d3b1c144 Merge pull request #2829 from sipa/bip32
BIP 32 derivation + test vectors
2013-08-15 16:40:03 -07:00
Pieter Wuille a81cd96805 Only create signatures with even S, and verification mode to check.
To fix a minor malleability found by Sergio Lerner (reported here:
https://bitcointalk.org/index.php?topic=8392.msg1245898#msg1245898)

The problem is that if (R,S) is a valid ECDSA signature for a given
message and public key, (R,-S) is also valid. Modulo N (the order
of the secp256k1 curve), this means that both (R,S) and (R,N-S) are
valid. Given that N is odd, S and N-S have a different lowest bit.
We solve the problem by forcing signatures to have an even S value,
excluding one of the alternatives.

This commit just changes the signing code to always produce even S
values, and adds a verification mode to check it. This code is not
enabled anywhere yet. Existing tests in key_tests.cpp verify that
the produced signatures are still valid.
2013-08-16 00:17:50 +02:00
Gavin Andresen 8dc206a1e2 Reject non-canonically-encoded sizes
The length of vectors, maps, sets, etc are serialized using
Write/ReadCompactSize -- which, unfortunately, do not use a
unique encoding.

So deserializing and then re-serializing a transaction (for example)
can give you different bits than you started with. That doesn't
cause any problems that we are aware of, but it is exactly the type
of subtle mismatch that can lead to exploits.

With this pull, reading a non-canonical CompactSize throws an
exception, which means nodes will ignore 'tx' or 'block' or
other messages that are not properly encoded.

Please check my logic... but this change is safe with respect to
causing a network split. Old clients that receive
non-canonically-encoded transactions or blocks deserialize
them into CTransaction/CBlock structures in memory, and then
re-serialize them before relaying them to peers.

And please check my logic with respect to causing a blockchain
split: there are no CompactSize fields in the block header, so
the block hash is always canonical. The merkle root in the block
header is computed on a vector<CTransaction>, so
any non-canonical encoding of the transactions in 'tx' or 'block'
messages is erased as they are read into memory by old clients,
and does not affect the block hash. And, as noted above, old
clients re-serialize (with canonical encoding) 'tx' and 'block'
messages before relaying to peers.
2013-08-09 10:01:35 +10:00
Gavin Andresen 42656ea2e5 Make RPC password resistant to timing attacks
Fixes issue#2838; this is a tweaked version of pull#2845 that
should not leak the length of the password and is more generic,
in case we run into other situations where we need
timing-attack-resistant comparisons.
2013-08-08 19:58:57 +10:00
Gavin Andresen ddd0e2f616 Merge pull request #2871 from gavinandresen/simplify_maporphan
Simplify storage of orphan transactions, fix CVE-2013-4627
2013-08-06 17:11:48 -07:00
Gavin Andresen bdd34642dc More unit tests for NUMEQUAL 2013-08-06 16:06:07 +10:00
Gavin Andresen ae759b3788 Merge pull request #2849 from petertodd/if-else-else
Add unittests for multiple ELSEs in a row
2013-08-05 01:53:57 -07:00
Gavin Andresen 159bc48193 Simplify storage of orphan transactions
Orphan transactions were stored as a CDataStream pointer;
this changes the mapOrphanTransactions data structures to
store orphans as a CTransaction.

This also fixes CVE-2013-4627 by always re-serializing
transactions before relaying them.
2013-08-02 16:10:25 +10:00
Jeff Garzik d247a5d130 Move internal miner/block creation to separate miner.cpp module.
Public functions referenced elsewhere are added to miner.h.
2013-07-31 09:43:35 -04:00
Peter Todd aff83e9c02 Add unittests for multiple ELSEs in a row
IF ELSE ELSE ENDIF is a valid construct; execution or non-execution
inverts on each ELSE encountered.
2013-07-23 05:12:38 -04:00
constantined 2ecb7555a9 Switch to using raw_utf8 2013-07-23 04:51:29 +03:00
Pieter Wuille a59db19ee3 BIP32 test vectors 2013-07-15 01:07:19 +02:00
Jeff Garzik d598872726 Merge pull request #2743 from jgarzik/reject-reason
Log reason for non-standard transaction rejection
2013-07-10 08:50:49 -07:00
Gregory Maxwell e5c4dfdfc0 Make the rand tests determinstic. (fixes #2714)
This avoids spurious errors with the old tests but still tests
 enough that if the rng is replaced with a totally broken one
 it should still fail.
2013-07-07 09:54:47 -07:00
Eric Lombrozo 38991ffa8a Pulled CheckBlock out of CBlock. 2013-06-23 19:59:35 -07:00
Pieter Wuille 12dff9801f Add HMAC-SHA512 to hash 2013-06-24 00:56:45 +02:00
Jeff Garzik 980bfe6ef8 Log reason for non-standard transaction rejection 2013-06-23 02:05:25 -04:00
Mike Hearn 0e4b317555 Introduce a CChainParameters singleton class and regtest mode.
The new class is accessed via the Params() method and holds
most things that vary between main, test and regtest networks.
The regtest mode has two purposes, one is to run the
bitcoind/bitcoinj comparison tool which compares two separate
implementations of the Bitcoin protocol looking for divergence.

The other is that when run, you get a local node which can mine
a single block instantly, which is highly convenient for testing
apps during development as there's no need to wait 10 minutes for
a block on the testnet.
2013-06-19 16:28:52 +02:00
Eric Lombrozo 05df3fc68d Removed AcceptToMemoryPool method from CTransaction. This method belongs to the mempool instance.
Removed AreInputsStandard from CTransaction, made it a regular function in main.
Moved CTransaction::GetOutputFor to CCoinsViewCache.

Moved GetLegacySigOpCount and GetP2SHSigOpCount out of CTransaction into regular functions in main.

Moved GetValueIn and HaveInputs from CTransaction into CCoinsViewCache.

Moved AllowFree, ClientCheckInputs, CheckInputs, UpdateCoins, and CheckTransaction out of CTransaction and into main.

Moved IsStandard and IsFinal out of CTransaction and put them in main as IsStandardTx and IsFinalTx. Moved GetValueOut out of CTransaction into main. Moved CTxIn, CTxOut, and CTransaction into core.

Added minimum fee parameter to CTxOut::IsDust() temporarily until CTransaction is moved to core.h so that CTxOut needn't know about CTransaction.
2013-06-05 23:15:20 -07:00
Wladimir J. van der Laan cd945c3bc9 Merge pull request #2727 from TheBlueMatt/master
One more data-driven test-case
2013-06-03 09:14:58 -07:00
Matt Corallo 14c12b094b Add new data-driven test-case. 2013-06-02 20:51:01 +02:00
Philip Kaufmann 3260b4c090 remove GetBoolArg() fDefault parameter defaulting to false
- explicitly set the default of all GetBoolArg() calls
- rework getarg_test.cpp and util_tests.cpp to cover this change
- some indentation fixes
- move macdockiconhandler.h include in bitcoin.cpp to the "our headers"
  section
2013-06-01 12:53:57 +02:00
Jeff Garzik e2f42142a0 Merge pull request #2600 from sipa/keyrefactor
Refactor key.cpp/.h
2013-05-30 07:55:25 -07:00
Jeff Garzik 9d01dd7658 Merge pull request #2104 from al42and/listreceivedbyaddress_txids
listreceivedbyaddress now provides tx ids (issue #1149)
2013-05-30 07:42:01 -07:00
Jeff Garzik af93273799 Merge pull request #2657 from gmaxwell/its_after_may15_forever
It's after 2013-05-15 forever now, so remove the code for the May 15 fork
2013-05-30 07:35:44 -07:00
Pieter Wuille dfa23b94c2 CSecret/CKey -> CKey/CPubKey split/refactor 2013-05-30 05:20:21 +02:00
Matt Corallo e175c16f5b Add a few data-driven tests for SIGHASH_ANYONECANPAY 2013-05-21 18:16:43 +02:00
Gregory Maxwell a824121eb8 It's after 2013-05-15 forever now, so remove the code for the May 15 fork. 2013-05-16 13:34:01 -07:00
Gavin Andresen 8de9bb53af Define dust transaction outputs, and make them non-standard 2013-05-03 10:52:09 -04:00
Gavin Andresen b8e1dc2e53 Remove flaky util thread unit tests 2013-05-03 10:45:00 -04:00
Gavin Andresen 21eb5adadb Port Thread* methods to boost::thread_group 2013-04-03 19:57:13 -04:00
Gavin Andresen 72f14d26ec LoopForever and ThreadTrace helpers 2013-04-03 19:57:13 -04:00
Gavin Andresen 87b9931bed Fix signed/unsigned comparison warnings 2013-04-03 14:04:21 -04:00
Gavin Andresen e5f163a041 -alertnotify=<cmd>
Runs a shell command when an AppliesToMe() alert is received.
%s in the <cmd> string is replaced with the alert.strStatusBar
message.
2013-03-19 15:16:30 -04:00
Gavin Andresen 1472308d67 Some unit tests for CAlert 2013-03-19 11:35:04 -04:00
Gavin Andresen d3e8c6a9d3 Update unit test to match rule enforcement starts 21 March 2013-03-17 22:01:59 -04:00
Gavin Andresen 8c222dca4f CheckBlock rule until 15-May for 10,000 BDB lock compatibility 2013-03-17 21:52:47 -04:00
Peter Todd 091f184190 Test canonical prunable txout format explicitly 2013-03-01 02:41:28 -05:00
Peter Todd 6131d1d9df Add coverage for all invalid ops
0xba thru 0xff
2013-03-01 02:24:08 -05:00
Gregory Maxwell 907a2aa4c7 Internal RNG for approximateBestSubset to prevent degenerate behavior.
This fixes test_bitcoin failures on openbsd reported by dhill on IRC.

  On some systems rand() is a simple LCG over 2^31 and so it produces
an even-odd sequence.  ApproximateBestSubset was only using the least
significant bit and so every run of the iterative solver would be the
same for some inputs, resulting in some pretty dumb decisions.

Using something other than the least significant bit would paper over
the issue but who knows what other way a system's rand() might get us
here.  Instead we use an internal RNG with a period of something like
2^60 which is well behaved.  This also makes it possible to make the
selection deterministic for the tests, if we wanted to implement that.
2013-02-18 14:13:39 -08:00
Pieter Wuille 386037615a Make sure the genesis block is present after reindex 2013-02-01 23:29:59 +01:00
Pieter Wuille ef3988ca36 CValidationState framework 2013-01-30 03:56:44 +01:00
Gavin Andresen 0e31ae9818 Merge pull request #2060 from sipa/parallel
Parallel script verification
2013-01-17 16:58:58 -08:00
Matt Corallo e1a4f3778c Add nFlags to CBloomFilter to make filter updating optional. 2013-01-16 14:34:06 -05:00
Matt Corallo 21aaf255ff Use CPartialMerkleTree for CMerkleBlock transactions. 2013-01-16 14:34:06 -05:00
Pieter Wuille 4bedfa9223 Add CPartialMerkleTree
This adds a compact representation for a subset of a merkle tree's
nodes.
2013-01-16 14:34:06 -05:00
Matt Corallo b1f99bed6f Add a nTweak to bloom filters to tweak the seed. 2013-01-16 12:48:02 -05:00
Matt Corallo 2878c67cb5 Add test cases for CMerkleBlock and CBloomFilter. 2013-01-16 12:48:02 -05:00
Pieter Wuille 45a1ec51b1 Merge pull request #2115 from forrestv/getblocktemplate_allfees
Provide fee data for all txs in RPC getblocktemplate response
2013-01-10 13:09:51 -08:00
Pieter Wuille f9cae832e6 Parallelize script verification
* During block verification (when parallelism is requested), script
  check actions are stored instead of being executed immediately.
* After every processed transactions, its signature actions are
  pushed to a CScriptCheckQueue, which maintains a queue and some
  synchronization mechanism.
* Two or more threads (if enabled) start processing elements from
  this queue,
* When the block connection code is finished processing transactions,
  it joins the worker pool until the queue is empty.

As cs_main is held the entire time, and all verification must be
finished before the block continues processing, this does not reach
the best possible performance. It is a less drastic change than
some more advanced mechanisms (like doing verification out-of-band
entirely, and rolling back blocks when a failure is detected).

The -par=N flag controls the number of threads (1-16). 0 means auto,
and is the default.
2013-01-08 02:00:59 +01:00
Jeff Garzik ea9788517b test/util_tests.cpp: one more DateTimeStrFormat 'T' removal 2013-01-01 19:48:28 -05:00
Forrest Voight 03cac0bb8e changed CreateNewBlock to return a CBlockTemplate object, which includes per-tx fee and sigop count data 2012-12-19 16:12:58 -05:00
Andrey 1a20469428 Updated help and tests for getreceivedby(account|address) 2012-12-16 23:10:32 +04:00
Pieter Wuille 33766c9557 Merge pull request #2096 from 94m3k1n9/fix-time-formats
Change timestamps to use ISO8601 formatting
2012-12-13 14:39:57 -08:00
Gavin Andresen d339da70e5 Merge pull request #1825 from roques/bignum2
Bignum2
2012-12-12 09:23:16 -08:00
Richard Schwab 303b0009dc Change timestamps to use ISO8601 formatting 2012-12-12 16:32:22 +01:00
Pieter Wuille 487db8a2b1 Make test_bitcoin run in a temp datadir 2012-11-29 22:09:16 +01:00
Pieter Wuille 99d0d0f356 Introduce script verification flags
These flags select features to be enabled/disabled during script
evaluation/checking, instead of several booleans passed along.
Currently these flags are defined:
* SCRIPT_VERIFY_P2SH: enable BIP16-style subscript evaluation
* SCRIPT_VERIFY_STRICTENC: enforce strict adherence to pubkey/sig encoding standards.
2012-11-15 23:00:16 +01:00
Pieter Wuille c7075c4b65 Fix tests after cache tweaks 2012-11-10 00:09:57 +01:00
Pieter Wuille 7fea484674 Add -reindex, to perform in-place reindexing of block chain files
Flushes the blktree/ and coins/ databases, and reindexes the
block chain files, as if their contents was loaded via -loadblock.

Based on earlier work by Jeff Garzik.
2012-11-09 01:06:32 +01:00
Gavin Andresen 03346a61b1 Add redeemScript to listunspent output and signrawtransaction input
signrawtransaction was unable to sign pay-to-script-hash inputs
when given the list of private keys to use. With this commit
you can provide the p2sh redemption script in the list of
inputs.
2012-10-29 13:34:35 -04:00
Gavin Andresen 2d43f88e1f Tests for raw transactions argument checking 2012-10-29 13:34:35 -04:00
Gavin Andresen c4d884e20e No need for test fixture now that multisig is enabled on main network. 2012-10-29 13:34:35 -04:00
Philip Kaufmann 729b180686 change blockchain -> block chain (spelling)
- Wiki says "block chain" is correct ;)
- remove some unneeded spaces I found in the source, while fixing the spelling
2012-10-21 21:32:25 +02:00
Pieter Wuille 4ca60bba5c Remove BDB block database support 2012-10-20 23:08:57 +02:00
Pieter Wuille e1bfbab802 Add LevelDB MemEnv support
Support LevelDB memory-backed environments, and use them in unit tests.
2012-10-20 23:08:57 +02:00
Pieter Wuille d979e6e36a Use singleton block tree database instance 2012-10-20 23:08:57 +02:00
Pieter Wuille 13c51f20f6 Direct CCoins references
To prevent excessive copying of CCoins in and out of the CCoinsView
implementations, introduce a GetCoins() function in CCoinsViewCache
with returns a direct reference. The block validation and connection
logic is updated to require caching CCoinsViews, and exploits the
GetCoins() function heavily.
2012-10-20 23:08:57 +02:00
Pieter Wuille 450cbb0944 Ultraprune
This switches bitcoin's transaction/block verification logic to use a
"coin database", which contains all unredeemed transaction output scripts,
amounts and heights.

The name ultraprune comes from the fact that instead of a full transaction
index, we only (need to) keep an index with unspent outputs. For now, the
blocks themselves are kept as usual, although they are only necessary for
serving, rescanning and reorganizing.

The basic datastructures are CCoins (representing the coins of a single
transaction), and CCoinsView (representing a state of the coins database).
There are several implementations for CCoinsView. A dummy, one backed by
the coins database (coins.dat), one backed by the memory pool, and one
that adds a cache on top of it. FetchInputs, ConnectInputs, ConnectBlock,
DisconnectBlock, ... now operate on a generic CCoinsView.

The block switching logic now builds a single cached CCoinsView with
changes to be committed to the database before any changes are made.
This means no uncommitted changes are ever read from the database, and
should ease the transition to another database layer which does not
support transactions (but does support atomic writes), like LevelDB.

For the getrawtransaction() RPC call, access to a txid-to-disk index
would be preferable. As this index is not necessary or even useful
for any other part of the implementation, it is not provided. Instead,
getrawtransaction() uses the coin database to find the block height,
and then scans that block to find the requested transaction. This is
slow, but should suffice for debug purposes.
2012-10-20 23:08:57 +02:00
Pieter Wuille 0fa593d0fb Compact serialization for amounts
Special serializer/deserializer for amount values. It is optimized for
values which have few non-zero digits in decimal representation. Most
amounts currently in the txout set take only 1 or 2 bytes to
represent.
2012-10-20 23:08:56 +02:00
Pieter Wuille 4d6144f97f Compact serialization for variable-length integers
Variable-length integers: bytes are a MSB base-128 encoding of the number.
The high bit in each byte signifies whether another digit follows. To make
the encoding is one-to-one, one is subtracted from all but the last digit.
Thus, the byte sequence a[] with length len, where all but the last byte
has bit 128 set, encodes the number:

  (a[len-1] & 0x7F) + sum(i=1..len-1, 128^i*((a[len-i-1] & 0x7F)+1))

Properties:
* Very small (0-127: 1 byte, 128-16511: 2 bytes, 16512-2113663: 3 bytes)
* Every integer has exactly one encoding
* Encoding does not depend on size of original integer type
2012-10-20 23:08:56 +02:00
Jeff Garzik dee0ee2ac9 Merge pull request #1742 from sipa/canonical
Check for canonical public keys and signatures
2012-10-20 10:56:04 -07:00
Wladimir J. van der Laan d6b13283d1 data-driven base58 CBitcoinAddress/CBitcoinSecret tests
Arbitrary numbers of test vectors can be generated using the script
`gen_base58_test_vectors.py`.
2012-10-01 04:57:26 +02:00
Pieter Wuille 58bc86e37f Check for canonical public keys and signatures
Only enabled inside tests for now.
2012-09-21 01:24:25 +02:00
Gavin Andresen 6cbae37667 Merge branch 'testdata' of git://github.com/TheBlueMatt/bitcoin 2012-09-18 19:22:40 -04:00
Gavin Andresen a0971337d0 Merge branch 'refactor_times' of git://github.com/luke-jr/bitcoin 2012-09-18 10:59:31 -04:00
Christian von Roques 6f0cecfc47 tests for SetCompact and GetCompact of CBigNum 2012-09-15 19:08:50 +02:00
Luke Dashjr da7b8c1260 Bugfix: Initialize CWallet::nOrderPosNext on an empty wallet, and save it in db 2012-09-08 04:55:36 +00:00
xanatos af8c050bff Wrong address added to collection in test
The wrong address is added to the collection. As was written a second copy of address1 was added (and so address2 was useless).
2012-09-07 16:04:39 +03:00
Matt Corallo 65786afb05 Add various tests for CTransaction::CheckTransaction() 2012-09-05 22:33:59 -04:00
Matt Corallo 1fcebc16c5 check tx.CheckTransaction for data-driven tx tests.
(and change so that only one case has to fail to make a tx_invalid
test correct)
2012-09-05 22:33:59 -04:00
Pieter Wuille af1c6b93b7 Merge pull request #1699 from laanwj/2012_08_securealloc
Handle locked pages more robustly (Fixes issue #1462)
2012-08-24 04:38:57 -07:00
Luke Dashjr 9c7722b7c5 Store a fixed order of transactions (and accounting) in the wallet
For backward compatibility, new accounting data is stored after a \0 in the comment string.
This way, old versions and third-party software should load and store them, but all actual use (listtransactions, for example) ignores it.
2012-08-23 18:18:20 +00:00
Wladimir J. van der Laan e95568b78d Handle locked pages more robustly (Fixes issue #1462)
Memory locks do not stack, that is, pages which have been locked several times by calls to mlock()
will be unlocked by a single call to munlock(). This can result in keying material ending up in swap when
those functions are used naively. In this commit a class "LockedPageManager" is added
that simulates stacking memory locks by keeping a counter per page.
2012-08-23 06:55:35 +02:00
Gavin Andresen f39ab4c8d0 Merge branch 'testdata' of git://github.com/TheBlueMatt/bitcoin 2012-08-21 13:58:24 -04:00
Pieter Wuille 143acc7672 Merge pull request #1687 from gavinandresen/quietunit
Suppress output when running unit tests.
2012-08-21 07:07:51 -07:00
Matt Corallo fc4743faa8 Add data-driven transaction tests. 2012-08-20 12:12:41 -04:00
Matt Corallo 336a0abbbb Add a few test cases to data-driven script tests. 2012-08-20 12:12:41 -04:00
Gavin Andresen 4d51be1cf3 Suppress output when running unit tests.
This does two things:
1) Now does not output to debug.log if -printtodebugger flag is passed
2) Unit tests set -printtodebugger so only test results are output to stdout

Note that -printtodebugger only actually prints to the debugger on Windows.
2012-08-20 11:33:20 -04:00
Gavin Andresen 3fcec0d4a0 Set block.nVersion to fix miner unit test 2012-08-20 10:46:07 -04:00
Matt Corallo 8555a3e3cc Remove useless non-cross-platform tests. 2012-08-17 12:40:09 -04:00
Philip Kaufmann efdcf94174 fix further spelling errors / remove a tab in the source 2012-08-02 10:09:29 +02:00
Luke Dashjr 3c726dd3c0 Bugfix: Use standard BTC unit in comments 2012-08-01 17:49:57 +00:00
Luke Dashjr 814efd6f1f Bugfix: Fix a variety of misspellings 2012-08-01 17:49:51 +00:00
Luke Dashjr 639b61d78e Tests for CreateNewBlock 2012-07-12 16:35:34 +00:00
Luke Dashjr 148e107da6 Run BDB disk-less for test_bitcoin 2012-07-11 04:26:44 +00:00
Gavin Andresen a2709fad7f Implement raw transaction RPC calls
Implement listunspent / getrawtransaction / createrawtransaction /
signrawtransaction, to support creation and
signing-on-multiple-device multisignature transactions.
2012-07-05 12:50:09 -04:00
fanquake 7790f391ab Fix a couple more typos 2012-06-30 17:05:28 +08:00
Gavin Andresen 1b71f82e38 Merge branch 'patch-3' of https://github.com/xanatos/bitcoin 2012-06-28 15:24:35 -04:00
Gavin Andresen 1282c8653e Checkpoint at block 185333 (and remove a couple of intermediate checkpoints) 2012-06-25 09:26:14 -04:00
Pieter Wuille 70f7f00385 Node support for Tor hidden services
This commit adds support for .onion addresses (mapped into the IPv6
by using OnionCat's range and encoding), and the ability to connect
to them via a SOCKS5 proxy.
2012-06-23 01:11:32 +02:00
Pieter Wuille e0be8da392 Unit tests for base32 encode/decode 2012-06-22 17:19:28 +02:00
xanatos d89f06c1ae Small fix to rpc_tests 2012-06-22 10:02:43 +03:00
xanatos fdfdb5cd7d = instead of == in multisig_tests.cpp 2012-06-21 21:37:49 +03:00
Pieter Wuille 4c6b210af0 Fix netbase tests
* Do not rely on "a.b.c" being interpreted as "a.0.b.c"
* Parse numeric addresses for address families for which no device is configured
2012-06-19 02:22:09 +02:00
Gavin Andresen c5532e188e Merge pull request #1399 from sipa/ipparse
Improve parsing of IPv6 addresses
2012-06-18 11:39:16 -07:00
Gavin Andresen 550c73f4c8 Merge branch 'signbugs' of https://github.com/wizeman/bitcoin
Resolved minor conflict in main.cpp
2012-06-18 10:48:40 -04:00
Pieter Wuille c4971e24f9 Add netbase tests 2012-06-14 17:43:10 +02:00
Wladimir J. van der Laan 641cfb1456 Fix build of testcases after commit 0f10b21719 2012-06-14 09:41:11 +02:00
Ricardo M. Correia 31ac53fbdc Move NOINLINE definition to test where it's used. 2012-06-07 20:22:18 +02:00
Chris Moore 831f59ce8b Fix coin selection to only include change when it's necessary. 2012-06-04 16:49:10 +00:00
Chris Moore 4ce190a015 Test that the coin selection code is suitably random, and add tests re. sub-cent change. 2012-06-04 16:36:43 +00:00
Chris Moore 9b0369c773 Refactor SelectCoinsMinConf() and add unit tests.
AvailableCoins() makes a vector of available outputs which is then passed to SelectCoinsMinConf().  This allows unit tests to test the coin selection algorithm without having the whole blockchain available.
2012-06-04 16:36:34 +00:00
Ricardo M. Correia 10b45b4c2e Use C++-style numeric limits instead of C-style. 2012-05-31 20:33:22 +02:00
Ricardo M. Correia 78e851f94f Fix noinline definition so that it works for more compilers. 2012-05-31 20:33:14 +02:00
Pieter Wuille a52c7a1b65 Merge pull request #1357 from sipa/keyid
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
2012-05-26 10:17:27 -07:00
Gavin Andresen 4e6e3293ff Remove newlines from JSON strings
Newlines in JSON strings are against the JSON spec,
so remove them from the script*.json unit tests to
make python's jsonrpc happy (json::spirit didn't care).
2012-05-25 13:58:44 -04:00
Gavin Andresen 787f5e9949 Unit tests for transaction size limits 2012-05-25 11:37:34 -04:00
Gavin Andresen 6b8a17119e Lots more Script unit test cases. 2012-05-24 17:32:09 -04:00
Pieter Wuille 1025440184 Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
This introduces internal types:
* CKeyID: reference (hash160) of a key
* CScriptID: reference (hash160) of a script
* CTxDestination: a boost::variant of the former two

CBitcoinAddress is retrofitted to be a Base58 encoding of a
CTxDestination. This allows all internal code to only use the
internal types, and only have RPC and GUI depend on the base58 code.

Furthermore, the header dependencies are a lot saner now. base58.h is
at the top (right below rpc and gui) instead of at the bottom. For the
rest: wallet -> script -> keystore -> key. Only keystore still requires
a forward declaration of CScript. Solving that would require splitting
script into two layers.
2012-05-24 20:26:19 +02:00
Pieter Wuille fd61d6f506 Encapsulate public keys in CPubKey 2012-05-24 19:58:12 +02:00
Gavin Andresen f04017f702 More CScript unit tests. 2012-05-24 13:29:08 -04:00
Jeff Garzik b92095f18c DoS_tests: fix signed/unsigned comparison warnings
test/DoS_tests.cpp: In member function ‘void DoS_tests::DoS_mapOrphans::test_method()’:
test/DoS_tests.cpp:200:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
test/DoS_tests.cpp:208:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
test/DoS_tests.cpp: In member function ‘void DoS_tests::DoS_checkSig::test_method()’:
test/DoS_tests.cpp:260:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
test/DoS_tests.cpp:267:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
test/DoS_tests.cpp:280:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
test/DoS_tests.cpp:307:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
2012-05-24 12:18:50 -04:00
Gavin Andresen d0e4051cd8 Merge branch 'optimize' 2012-05-22 11:13:00 -04:00
Wladimir J. van der Laan 239c11d0dd Make testcases build, prevent windows symbol collision 2012-05-20 10:44:50 +02:00
Philip Kaufmann ff0ee876bb change strings to Bitcoin (uppercase), where it is used as a noun and update strings to use "Qt" (and not qt or QT) / update initialisation of notificator to use qApp->applicationName() instead of a static string 2012-05-18 23:13:58 +02:00
Gavin Andresen 62922c8ab0 Cache signature verifications
Create a maximum-10MB signature verification result cache.
This should almost double the number of transactions that
can be processed on a given CPU, because before this change
ECDSA signatures were verified when transactions were added
to the memory pool and then again when they appeared in
a block.
2012-05-18 10:41:18 -04:00
Gavin Andresen 77b99cf7ad Optimize orphan transaction handling
Changes suggested by Sergio Demian Lerner to
help prevent potential DoS attacks.
2012-05-18 10:13:21 -04:00
Gavin Andresen f718aedd9f Refactor: GetRandHash() method for util 2012-05-17 16:33:27 -04:00
Ricardo M. Correia 62e0453ce0 Add test case for CBigNum::setint64().
One of the test cases currently aborts when using gcc's flag -ftrapv, due to
negating an INT64_MIN int64 variable, which is an undefined operation.

This will be fixed in a subsequent commit.
2012-05-14 21:26:01 +02:00
Pieter Wuille f621326c24 Clean up warnings
* Use -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameters
* Remove xCXXFLAGS usage in makefile.unix
* Fix several recent and older sign-compare warnings
2012-05-09 03:48:30 +02:00
Pieter Wuille 39857190de Support for multiple local addresses 2012-05-04 16:12:23 +02:00
Gavin Andresen 9e71a5cd23 Define TEST_DATA_DIR so unit tests can be run from any current working directory 2012-04-26 11:20:44 -04:00
Jeff Garzik 7bd9c3a3cf SigOp and orphan-tx constants and counts are always unsigned.
Fixes several sign-comparison warnings.
2012-04-23 14:14:03 -04:00
Pieter Wuille 457661f640 Merge pull request #1124 from sipa/rpcobj3
extension of #1103: encapsulate mapCommands in CRPCTable
2012-04-21 16:49:32 -07:00
Pieter Wuille 7dbe393629 Merge pull request #1131 from laanwj/2012_04_hexstr
Integrate @JoelKatz's optimized ToHex (#562) into current HexStr function
2012-04-21 16:47:02 -07:00
Gavin Andresen 8449a8788a Data-drive script evaluation unit tests. 2012-04-21 19:35:39 -04:00
Wladimir J. van der Laan 88dc2d6c6a Integrate @JoelKatz's optimized ToHex (#562) into current HexStr function 2012-04-21 20:37:50 +02:00
Pieter Wuille e46704dd90 Expose CRPCTable via bitcoinrpc.h for testing 2012-04-21 01:37:34 +02:00
Pieter Wuille 0a83c0fcef Fix tests after recent refactors 2012-04-17 20:37:47 +02:00
Chris Moore b3a6e613fc CBitcoinSecret::SetString() now calls IsValid() to make sure it was passed something with the correct version. 2012-04-12 13:13:08 -07:00
Pieter Wuille f8dcd5ca6f Use scoped locks instead of CRITICAL_BLOCK 2012-04-09 01:59:46 +02:00
Gavin Andresen 142e604184 DoS fix for mapOrphanTransactions 2012-02-29 11:46:46 -05:00
Pieter Wuille c4341fa6ab Add mruset and use it for setInventoryKnown 2012-02-27 21:04:32 +01:00
Pieter Wuille 0d56f11ada Fix tests after 38067c18 2012-02-20 18:32:33 +01:00
Gavin Andresen 3ad9f8a70f New GetArg features: allow --, and booleans can be -foo or -nofoo 2012-02-07 09:14:31 -05:00
Gavin Andresen 3ae0735553 Unit tests for the GetArg() methods 2012-02-07 09:14:31 -05:00
Gavin Andresen 0b452dff5e Merge branch 'standardScriptSigs' of github.com:gavinandresen/bitcoin-git 2012-02-07 09:04:56 -05:00
Gavin Andresen 137d0685a4 Simplify counting of P2SH sigops to match BIP 16 (thanks to Matt Corallo for prompting this).
This also removes an un-needed sigops-per-byte check when accepting transactions to the memory pool (un-needed assuming only standard transactions are being accepted). And it only counts P2SH sigops after the switchover date.
2012-01-20 17:07:40 -05:00
Gavin Andresen 39f0d96860 Make transactions with extra data in their scriptSig's non-standard. 2012-01-19 13:30:54 -05:00
Gavin Andresen 8d7849b6db Refactored ConnectInputs, so valid-transaction-checks are done before ECDSA-verifying signatures. 2012-01-13 10:22:24 -05:00
Gavin Andresen 922e8e2929 Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16). 2012-01-13 10:22:23 -05:00
Pieter Wuille b3974ec9d4 Unit tests for EC key routines
This tests:
* creation of keys from base58-encoded strings
* extracting public keys and addresses
* compressed public keys
* compact signatures and key recovery
2012-01-09 15:18:19 +01:00
Pieter Wuille 67a42f929b Network stack refactor
This introduces CNetAddr and CService, respectively wrapping an
(IPv6) IP address and an IP+port combination. This functionality used
to be part of CAddress, which also contains network flags and
connection attempt information. These extra fields are however not
always necessary.

These classes, along with logic for creating connections and doing
name lookups, are moved to netbase.{h,cpp}, which does not depend on
headers.h.

Furthermore, CNetAddr is mostly IPv6-ready, though IPv6
functionality is not yet enabled for the application itself.
2012-01-06 18:55:37 +01:00
coderrr 6ec76ca09e make sure IsMine only returns true when we own all keys 2012-01-03 06:24:52 +07:00
Gavin Andresen 6d6d392b22 Fixed OP_EVAL recursion unit test, checks for both infinite and exactly-3-deep recursion 2011-12-27 16:41:56 -05:00
Gavin Andresen 2e17ac83c6 Fix broken ExtractAddress (refactored, made callers check for addresses in keystore if they care) 2011-12-22 15:57:31 -05:00
Wladimir J. van der Laan bde280b9a4 Revert "Use standard C99 (and Qt) types for 64-bit integers"
This reverts commit 21d9f36781.
2011-12-21 22:33:19 +01:00
Luke Dashjr 21d9f36781 Use standard C99 (and Qt) types for 64-bit integers 2011-12-20 16:52:59 -05:00
Gavin Andresen 2a45a494b0 Use block times for 'hard' OP_EVAL switchover, and refactored EvalScript
so it takes a flag for how to interpret OP_EVAL.
Also increased IsStandard size of scriptSigs to 500 bytes, so
a 3-of-3 multisig transaction IsStandard.
2011-12-19 13:24:48 -05:00
Gavin Andresen a0871afb2b Interpret OP_EVAL as OP_NOP until Feb 1, 2012 2011-12-19 13:24:48 -05:00
Gavin Andresen e679ec969c OP_EVAL implementation
OP_EVAL is a new opcode that evaluates an item on the stack as a script.
It enables a new type of bitcoin address that needs an arbitrarily
complex script to redeem.
2011-12-19 12:40:19 -05:00
Gavin Andresen cc40ba2151 Global fixture to send output to console instead of debug.log 2011-12-19 12:40:19 -05:00
Gavin Andresen bf798734db Support 3 new multisignature IsStandard transactions
Initial support for (a and b), (a or b), and 2-of-3 escrow
transactions (where a, b, and c are keys).
2011-12-19 12:40:19 -05:00
Gavin Andresen 1466b8b78a Rework unit tests so test_bitcoin.cpp does not #include them all 2011-12-19 12:39:47 -05:00
Gavin Andresen 10fd7f6689 Orphan block fill-up-memory attack prevention 2011-12-01 13:53:38 -05:00
Gavin Andresen eb5fff9e16 Moved checkpoints out of main, to prep for using them to help prevent DoS attacks 2011-12-01 12:18:50 -05:00
Clark Gaebel f873b84d6e Added simple critical section test cases. 2011-11-02 18:10:41 -04:00
Gavin Andresen 9e5322d23a Fix miner_test unit test bug 2011-10-05 14:33:49 -04:00
Gavin Andresen b898c8fce6 Merge branch 'no-cryptopp' of https://github.com/tcatm/bitcoin 2011-10-05 10:38:10 -04:00
Gavin Andresen 3504801778 Declare integer constant LL 2011-10-03 13:10:31 -04:00
Wladimir J. van der Laan 2f7f2a5fca remove possibility of 63 bit overflow in ParseMoney
- also, add unit tests for various functions in util.cpp/util.h
2011-10-01 17:29:46 +02:00
Nils Schneider 6ccff2cbde remove cryptopp dependency, add simple unittest for SHA256Transform() 2011-09-30 20:00:22 +02:00
Gavin Andresen f4769e44a3 Merge pull request #524 from sipa/signandverif
Sign and verify message with bitcoin address
2011-09-30 05:04:26 -07:00
Wladimir J. van der Laan 002a4dcad0 Merge branch 'master' of https://github.com/bitcoin/bitcoin
Conflicts:
	.gitignore (used upstream version)
	bitcoin-qt.pro
2011-09-28 21:52:32 +02:00
Wladimir J. van der Laan a8b95ce6ed use median filter for peer-reported reported number of blocks
- fixes problem that one misconfigured or malicious node can mess up progress bar
- implementation in src/util.h
- testcase in src/test/util_tests.cpp
2011-09-28 21:35:58 +02:00
Pieter Wuille e93bf37e86 Test case for base64 encode/decode 2011-09-27 19:48:10 +02:00
Gavin Andresen 15f3ad4dbd Framework for banning mis-behaving peers 2011-09-21 12:49:53 -04:00
Gavin Andresen 829e21733b CHECKMULTISIG unit tests. 2011-08-26 18:43:58 -04:00
Matt Corallo 2c3691d53d Cleanup test suite output to be more useful. 2011-08-08 14:31:08 -04:00
Matt Corallo 3c8cecda1f Add file for transaction tests. 2011-08-08 14:31:08 -04:00
Vegard Nossum a8330e0049 Add a file for script tests 2011-08-08 14:31:08 -04:00
Vegard Nossum e707d29dd6 Fix testing setup
There were some problems with the existing testing setup:

 - Makefile rules for test-file compilation used CFLAGS instead of
   CXXFLAGS in makefile.unix
2011-08-08 14:31:08 -04:00
Gavin Andresen 8baf865c94 Boost unit-testing framework.
make -f makefile.{unix,osx,mingw} test_bitcoin
to compile dumb, do-almost-nothing placeholder unit tests.
2011-06-27 14:12:48 -04:00