Commit graph

1574 commits

Author SHA1 Message Date
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