Commit graph

984 commits

Author SHA1 Message Date
Wladimir J. van der Laan eedc461882 Merge doc/unit-tests.md into src/test/README.md
Refer to the right file in the top-level README.md.

Having only one file with test documentation saves some confusion about
where things are documented.
2016-11-02 18:19:43 +01:00
Wladimir J. van der Laan f8723d2318
Merge #8753: Locked memory manager
444c673 bench: Add benchmark for lockedpool allocation/deallocation (Wladimir J. van der Laan)
6567999 rpc: Add `getmemoryinfo` call (Wladimir J. van der Laan)
4536148 support: Add LockedPool (Wladimir J. van der Laan)
f4d1fc2 wallet: Get rid of LockObject and UnlockObject calls in key.h (Wladimir J. van der Laan)
999e4c9 wallet: Change CCrypter to use vectors with secure allocator (Wladimir J. van der Laan)
2016-11-02 11:16:29 +01:00
Wladimir J. van der Laan 6c5cd9d022 test: Add format-dependent comparison to bctest
This splits the output comparison for `bitcoin-tx` into two steps:

- First, check for data mismatch, parsing the data as json or hex
  depending on the extension of the output file

- Then, check if the literal string matches

For either of these cases give a different error.

This prevents wild goose chases when e.g. a trailing space doesn't match
exactly, and makes sure that both test output and examples are valid
data of the purported format.
2016-10-28 14:20:59 +02:00
Wladimir J. van der Laan 4536148b15 support: Add LockedPool
Add a pool for locked memory chunks, replacing LockedPageManager.

This is something I've been wanting to do for a long time. The current
approach of locking objects where they happen to be on the stack or heap
in-place causes a lot of mlock/munlock system call overhead, slowing
down any handling of keys.

Also locked memory is a limited resource on many operating systems (and
using a lot of it bogs down the system), so the previous approach of
locking every page that may contain any key information (but also other
information) is wasteful.
2016-10-27 13:17:25 +02:00
Pieter Wuille 4100499db4 Return shared_ptr<CTransaction> from mempool removes 2016-10-21 19:22:43 -07:00
Pieter Wuille 51f278329d Make removed and conflicted arguments optional to remove 2016-10-21 19:22:43 -07:00
Wladimir J. van der Laan 475d68252e
Merge #8927: Add script tests for FindAndDelete in pre-segwit and segwit scripts
acf853d Add script tests for FindAndDelete in pre-segwit and segwit scripts (Johnson Lau)
2016-10-19 17:41:34 +02:00
Wladimir J. van der Laan 5d2c8e524e
Merge #7948: RPC: augment getblockchaininfo bip9_softforks data
fc14609 RPC: augment getblockchaininfo bip9_softforks data (mruddy)
2016-10-19 16:41:59 +02:00
mruddy fc146095d2 RPC: augment getblockchaininfo bip9_softforks data 2016-10-19 09:08:39 -04:00
Jonas Schnelli 69d1c25768
[RPC] Give RPC commands more information about the RPC request 2016-10-19 14:42:08 +02:00
Wladimir J. van der Laan 05998da5a7
Merge #8865: Decouple peer-processing-logic from block-connection-logic
a9aec5c Use BlockChecked signal to send reject messages from mapBlockSource (Matt Corallo)
7565e03 Remove SyncWithWallets wrapper function (Matt Corallo)
12ee1fe Always call UpdatedBlockTip, even if blocks were only disconnected (Matt Corallo)
f5efa28 Remove CConnman parameter from ProcessNewBlock/ActivateBestChain (Matt Corallo)
fef1010 Use CValidationInterface from chain logic to notify peer logic (Matt Corallo)
aefcb7b Move net-processing logic definitions together in main.h (Matt Corallo)
0278fb5 Remove duplicate nBlocksEstimate cmp (we already checked IsIBD()) (Matt Corallo)
87e7d72 Make validationinterface.UpdatedBlockTip more verbose (Matt Corallo)
2016-10-18 22:48:51 +02:00
Wladimir J. van der Laan 744d2652dd
Merge #8223: [c++11] Use std::unique_ptr for block creation.
9fce062 [c++11] Use std::unique_ptr for block creation. (Daniel Kraft)
2016-10-18 21:16:08 +02:00
Wladimir J. van der Laan cdfb7755a6
Merge #8914: Kill insecure_random and associated global state
5eaaa83 Kill insecure_random and associated global state (Wladimir J. van der Laan)
2016-10-18 15:44:57 +02:00
Wladimir J. van der Laan 5eaaa83ac1 Kill insecure_random and associated global state
There are only a few uses of `insecure_random` outside the tests.
This PR replaces uses of insecure_random (and its accompanying global
state) in the core code with an FastRandomContext that is automatically
seeded on creation.

This is meant to be used for inner loops. The FastRandomContext
can be in the outer scope, or the class itself, then rand32() is used
inside the loop. Useful e.g. for pushing addresses in CNode or the fee
rounding, or randomization for coin selection.

As a context is created per purpose, thus it gets rid of
cross-thread unprotected shared usage of a single set of globals, this
should also get rid of the potential race conditions.

- I'd say TxMempool::check is not called enough to warrant using a special
  fast random context, this is switched to GetRand() (open for
  discussion...)

- The use of `insecure_rand` in ConnectThroughProxy has been replaced by
  an atomic integer counter. The only goal here is to have a different
  credentials pair for each connection to go on a different Tor circuit,
  it does not need to be random nor unpredictable.

- To avoid having a FastRandomContext on every CNode, the context is
  passed into PushAddress as appropriate.

There remains an insecure_random for test usage in `test_random.h`.
2016-10-17 13:08:35 +02:00
Johnson Lau 9260085377 test segwit uncompressed key fixes 2016-10-17 00:34:37 +08:00
Johnson Lau 4c0c25a604 Require compressed keys in segwit as policy and disable signing with uncompressed keys for segwit scripts 2016-10-16 23:53:35 +08:00
Johnson Lau acf853df91 Add script tests for FindAndDelete in pre-segwit and segwit scripts 2016-10-16 00:30:50 +08:00
Wladimir J. van der Laan e2b8c394d6
Merge #8817: update bitcoin-tx to output witness data
4408558 Update bitcoin-tx to output witness data. (jonnynewbs)
2016-10-13 18:56:43 +02:00
Pieter Wuille 6429cfa8a7
Merge #8393: Support for compact blocks together with segwit
27acfc1 [qa] Update p2p-compactblocks.py for compactblocks v2 (Suhas Daftuar)
422fac6 [qa] Add support for compactblocks v2 to mininode (Suhas Daftuar)
f5b9b8f [qa] Fix bug in mininode witness deserialization (Suhas Daftuar)
6aa28ab Use cmpctblock type 2 for segwit-enabled transfer (Pieter Wuille)
be7555f Fix overly-prescriptive p2p-segwit test for new fetch logic (Matt Corallo)
06128da Make GetFetchFlags always request witness objects from witness peers (Matt Corallo)
2016-10-10 13:16:40 +02:00
jnewbery 621441a7a7 add verbose mode to bitcoin-util-test.py 2016-10-05 09:16:08 -04:00
jonnynewbs 4408558843 Update bitcoin-tx to output witness data. 2016-10-05 09:00:34 -04:00
Matt Corallo f5efa28393 Remove CConnman parameter from ProcessNewBlock/ActivateBestChain 2016-10-04 13:51:32 -04:00
Pieter Wuille 6aa28abf53 Use cmpctblock type 2 for segwit-enabled transfer
Contains version negotiation logic by Matt Corallo and bugfixes by
Suhas Daftuar.
2016-10-04 19:10:41 +02:00
Wladimir J. van der Laan ef0801bd13
Merge #8830: [test] Add option to run bitcoin-util-test.py manually
b82f493 Add option to run bitcoin-util-test.py manually (jnewbery)
2016-09-30 17:03:21 +02:00
jnewbery da94697708 bitcoin-util-test.py should fail if the output file is empty 2016-09-29 10:16:56 -04:00
jnewbery b82f493938 Add option to run bitcoin-util-test.py manually 2016-09-29 08:54:56 -04:00
MarcoFalke 8ca69a2a88
Merge #8829: Add bitcoin-tx JSON tests
54e5d7c Add bitcoin-tx JSON tests (jnewbery)
2016-09-29 10:50:05 +02:00
jnewbery 54e5d7c1b8 Add bitcoin-tx JSON tests 2016-09-28 13:38:42 -04:00
Johnson Lau e41bd449ab Add policy: null signature for failed CHECK(MULTI)SIG 2016-09-27 23:40:59 +08:00
Wladimir J. van der Laan 5a4f6d72e6
Merge #8526: Make non-minimal OP_IF/NOTIF argument non-standard for P2WSH
c72c5b1 Make non-minimal OP_IF/NOTIF argument non-standard for P2WSH (Johnson Lau)
2016-09-27 17:10:15 +02:00
Pavel Janík 4731cab8fb Do not shadow variables 2016-09-27 09:25:15 +02:00
Johnson Lau c72c5b1e3b Make non-minimal OP_IF/NOTIF argument non-standard for P2WSH 2016-09-23 13:07:38 +08:00
MarcoFalke 3333bd2d15 [test] Remove redundant print in addrman_tests 2016-09-22 12:50:39 +02:00
Pieter Wuille d9ff591d42 Move static global randomizer seeds into CConnman 2016-09-19 15:53:47 +02:00
Cory Fields f60b9059e4 net: Pass best block known height into CConnman
CConnman then passes the current best height into CNode at creation time.

This way CConnman/CNode have no dependency on main for height, and the signals
only move in one direction.

This also helps to prevent identity leakage a tiny bit. Before this change, an
attacker could theoretically make 2 connections on different interfaces. They
would connect fully on one, and only establish the initial connection on the
other. Once they receive a new block, they would relay it to your first
connection, and immediately commence the version handshake on the second. Since
the new block height is reflected immediately, they could attempt to learn
whether the two connections were correlated.

This is, of course, incredibly unlikely to work due to the small timings
involved and receipt from other senders. But it doesn't hurt to lock-in
nBestHeight at the time of connection, rather than letting the remote choose
the time.
2016-09-08 12:24:06 -04:00
Cory Fields bd72937dc4 net: move nLocalServices/nRelevantServices to CConnman
These are in-turn passed to CNode at connection time. This allows us to offer
different services to different peers (or test the effects of doing so).
2016-09-08 12:24:06 -04:00
Cory Fields 551e0887db net: move nLastNodeId to CConnman 2016-09-08 12:24:06 -04:00
Cory Fields a0f3d3cdad net: move ban and addrman functions into CConnman 2016-09-08 12:12:57 -04:00
Cory Fields aaf018e3b7 net: handle nodesignals in CConnman 2016-09-08 12:06:24 -04:00
Cory Fields 8d58c4d81f net: Pass CConnman around as needed 2016-09-08 12:04:35 -04:00
Cory Fields cd16f48028 net: Create CConnman to encapsulate p2p connections 2016-09-08 12:04:35 -04:00
MarcoFalke ddc308068d
Merge #8671: Minimal fix to slow prevector tests as stopgap measure
f71d4a3 Minimal fix to slow prevector tests as stopgap measure (Jeremy Rubin)
2016-09-08 11:12:50 +02:00
Jeremy Rubin 426e7bce0e Fix obvious assignment/equality error in test 2016-09-06 16:22:13 -04:00
Jeremy Rubin f71d4a3786 Minimal fix to slow prevector tests as stopgap measure 2016-09-06 16:19:25 -04:00
Wladimir J. van der Laan 381d0ddc8a
Merge #8449: [Trivial] Do not shadow local variable, cleanup
a159f25 Remove redundand (and shadowing) declaration (Pavel Janík)
cce3024 Do not shadow local variable, cleanup (Pavel Janík)
2016-09-02 12:25:59 +02:00
Wladimir J. van der Laan 6f939c9080
Merge #8629: C++11: s/boost::scoped_ptr/std::unique_ptr/
cdd79eb C++11: s/boost::scoped_ptr/std::unique_ptr/ (Jorge Timón)
2016-09-02 09:56:33 +02:00
Jorge Timón cdd79eb70f C++11: s/boost::scoped_ptr/std::unique_ptr/ 2016-09-01 19:05:07 +02:00
Pieter Wuille 19b0f33de0
Merge #8524: Precompute sighashes
35fe039 Rename to PrecomputedTransactionData (Pieter Wuille)
ab48c5e Unit test for sighash caching (Nicolas DORIER)
d2c5d04 Precompute sighashes (Pieter Wuille)
2016-09-01 12:20:43 +02:00
Pieter Wuille 35fe0393f2 Rename to PrecomputedTransactionData 2016-08-26 18:44:10 +02:00
MarcoFalke 95a983d56d
Merge #8578: [test] Remove unused code
fa1cf9e [test] Remove unused code (MarcoFalke)
2016-08-25 11:00:21 +02:00