aboutsummaryrefslogtreecommitdiff
path: root/src/test
AgeCommit message (Collapse)Author
2017-06-22scripted-diff: Remove BOOST_REVERSE_FOREACHJorge Timón
-BEGIN VERIFY SCRIPT- sed -i 's/BOOST_REVERSE_FOREACH(\(.*\), \(.*\))/for (\1 : reverse_iterate(\2))/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ; -END VERIFY SCRIPT-
2017-06-22Introduce src/reverse_iterator.hpp and include it...Jorge Timón
...where it will be needed Taken from https://gist.github.com/arvidsson/7231973 with small modifications to fit the bitcoin core project
2017-06-14net: do not allow resolving to an internal addressCory Fields
In order to prevent mixups, our internal range is never allowed as a resolve result. This means that no user-provided string will ever be confused with an internal address.
2017-06-14net: add an internal subnet for representing unresolved hostnamesCory Fields
We currently do two resolves for dns seeds: one for the results, and one to serve in addrman as the source for those addresses. There's no requirement that the source hostname resolves to the stored identifier, only that the mapping is unique. So rather than incurring the second lookup, combine a private subnet with a hash of the hostname. The resulting v6 ip is guaranteed not to be publicy routable, and has only a negligible chance of colliding with a user's internal network (which would be of no consequence anyway).
2017-06-14Merge #10377: Use rdrand as entropy source on supported platformsWladimir J. van der Laan
cb24c85 Use rdrand as entropy source on supported platforms (Pieter Wuille) Tree-SHA512: c42eaa01a14e6bc097c70b6bf8540d61854c2f76cb32be69c2a3c411a126f7b4bf4a4486e4493c4cc367cc689319abde0d4adb799d29a54fd3e81767ce0766fc
2017-06-13Merge #10502: scripted-diff: Remove BOOST_FOREACH, Q_FOREACH and PAIRTYPEPieter Wuille
1238f13cf scripted-diff: Remove PAIRTYPE (Jorge Timón) 18dc3c396 scripted-diff: Remove Q_FOREACH (Jorge Timón) 7c00c2672 scripted-diff: Fully remove BOOST_FOREACH (Jorge Timón) a5410ac5e Small preparations for Q_FOREACH, PAIRTYPE and #include <boost/foreach.hpp> removal (Jorge Timón) Tree-SHA512: d3ab4a173366402e7dcef31608977b757d4aa07abbbad2ee1bcbcfa311e994a4552f24e5a55272cb22c2dcf89a4b0495e02e9d9aceae4b08c0bab668f20e324c
2017-06-13Use rdrand as entropy source on supported platformsPieter Wuille
2017-06-13Merge #10553: Simplify "bool x = y ? true : false". Remove unused function ↵Wladimir J. van der Laan
and trailing semicolon. 67ca816 Simplify "bool x = y ? true : false" to "bool x = y" (practicalswift) 9f841a6 [tests] Remove accidental trailing semicolon (practicalswift) 30c2d9d [tests] Remove unused function InsecureRandBytes(size_t len) (practicalswift) Tree-SHA512: ae62c255c88133cad12084b6011c105bb96b729c8103330350683d9c20020c5d7617693795df4dff6cc305f2405cb2e4e2ece182d6e6d7c3c8db82aa2f882c41
2017-06-12Merge #10550: Don't return stale data from CCoinsViewCache::Cursor()Wladimir J. van der Laan
3ff1fa8 Use override keyword on CCoinsView overrides (Russell Yanofsky) 24e44c3 Don't return stale data from CCoinsViewCache::Cursor() (Russell Yanofsky) Tree-SHA512: 08699dae0925ffb9c018f02612ac6b7eaf73ec331e2f4f934f1fe25a2ce120735fa38596926e924897c203f7470e99f0a99cf70d2ce31ff428b105e16583a861
2017-06-11Simplify "bool x = y ? true : false" to "bool x = y"practicalswift
2017-06-11Merge #10546: Remove 33 unused Boost includesWladimir J. van der Laan
49de096 Remove unused Boost includes (practicalswift) Tree-SHA512: ff2dad94f9eeb1dc50fcffd0e94e1686be04e4e5bc45f58ae955d630c15cd25bb8f5583d0aa1f2f263b5a723be79747ef3c6e6b417c7be7787c0abc8d1874019
2017-06-09Merge #10521: Limit variable scopePieter Wuille
90593ed92 Limit variable scope (practicalswift) Tree-SHA512: 4719e303688a31aefbe1d239e86b21dd3c2045524e08bd628c6ba0c6c2a97de14d04305b9beafe0b1dcde7229793e6663168953f192e88ed409be5c30fd2a9a9
2017-06-09Remove unused Boost includespracticalswift
2017-06-08Merge #10545: Use list initialization (C++11) for maps/vectors instead of ↵Wladimir J. van der Laan
boost::assign::map_list_of/list_of 3fb81a8 Use list initialization (C++11) for maps/vectors instead of boost::assign::map_list_of/list_of (practicalswift) Tree-SHA512: 63a9ac9ec5799472943dce1cd92a4b14e7f1fe12758a5fc4b1efceaf2c85a4ba71dad5ccc50813527f18b192e7714c076e2478ecd6ca0d452b24e88416f872f7
2017-06-08Use override keyword on CCoinsView overridesRussell Yanofsky
2017-06-08Merge #10481: Decodehextx scripts sanity checkWladimir J. van der Laan
ac4e438 Sanity check transaction scripts in DecodeHexTx (Andrew Chow) 5b75c47 Add a valid opcode sanity check to CScript (Andrew Chow) Tree-SHA512: a516e95c274c9d131123150c798cae8bed75925e8a4d59469967dd7f1d49f7f8161e26afb61024b821bd8dcdffdfd0d19b8dcad20b39b1106820326d8d56904d
2017-06-08Merge #10547: [tests] Use FastRandomContext instead of ↵Wladimir J. van der Laan
boost::random::{mt19937,uniform_int_distribution} 227ae9b [tests] Use FastRandomContext instead of boost::random::{mt19937,uniform_int_distribution} (practicalswift) Tree-SHA512: 1bde6c8b9498051fa2eae4913eb1f5411adea8dea1511c0df859aea57a2a7db6f5839945ddf2eccdddfa322bceacad35a5d875742db7d15e40dbea83185307bb
2017-06-08[tests] Remove unused function InsecureRandBytes(size_t len)practicalswift
2017-06-08Merge #10524: [tests] Remove printf(...)Wladimir J. van der Laan
0abc588 [tests] Remove printf(...) (practicalswift) Tree-SHA512: a56fa1edce050f5a44a53842223fc99e4e8ade413047e04f2064faeb5c4a418864a94471853d5c26a20608d1dcc18b9226d7fe15172f79a66cc5cf6e1443f7e9
2017-06-07Merge #10321: Use FastRandomContext for all testsPieter Wuille
e94584858 scripted-diff: Use new naming style for insecure_rand* functions (Pieter Wuille) 2fcd9cc86 scripted-diff: Use randbits/bool instead of randrange where possible (Pieter Wuille) 2ada67852 Use randbits instead of ad-hoc emulation in prevector tests (Pieter Wuille) 5f0b04eed Replace rand() & ((1 << N) - 1) with randbits(N) (Pieter Wuille) 3ecabae36 Replace more rand() % NUM by randranges (Pieter Wuille) efee1db21 scripted-diff: use insecure_rand256/randrange more (Pieter Wuille) 1119927df Add various insecure_rand wrappers for tests (Pieter Wuille) 124d13a58 Merge test_random.h into test_bitcoin.h (Pieter Wuille) 90620d66c scripted-diff: Rename cuckoo tests' local rand context (Pieter Wuille) 37e864eb9 Add FastRandomContext::rand256() and ::randbytes() (Pieter Wuille) Tree-SHA512: d09705a3ec718ae792f7d66a75401903ba7b9c9d3fc36669d6e3b9242f0194738106be26baefc8a8e3fa6df7c9a35978c71c0c430278a028b331df23a3ea3070
2017-06-07Add a valid opcode sanity check to CScriptAndrew Chow
Added a function in CScript that checks if the script contains valid opcodes. Add a test for that function
2017-06-07scripted-diff: Use new naming style for insecure_rand* functionsPieter Wuille
-BEGIN VERIFY SCRIPT- sed -i 's/\<insecure_randbits(/InsecureRandBits(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp sed -i 's/\<insecure_randbool(/InsecureRandBool(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp sed -i 's/\<insecure_randrange(/InsecureRandRange(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp sed -i 's/\<insecure_randbytes(/InsecureRandBytes(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp sed -i 's/\<insecure_rand256(/InsecureRand256(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp sed -i 's/\<insecure_rand(/InsecureRand32(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp sed -i 's/\<seed_insecure_rand(/SeedInsecureRand(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp -END VERIFY SCRIPT-
2017-06-07[tests] Remove printf(...)practicalswift
2017-06-07[tests] Use FastRandomContext instead of ↵practicalswift
boost::random::{mt19937,uniform_int_distribution}
2017-06-07scripted-diff: Use randbits/bool instead of randrange where possiblePieter Wuille
-BEGIN VERIFY SCRIPT- sed -i 's/insecure_randbits(1)/insecure_randbool()/g' src/test/*_tests.cpp sed -i 's/insecure_randrange(2)/insecure_randbool()/g' src/test/*_tests.cpp sed -i 's/insecure_randrange(4)/insecure_randbits(2)/g' src/test/*_tests.cpp sed -i 's/insecure_randrange(32)/insecure_randbits(5)/g' src/test/*_tests.cpp sed -i 's/insecure_randrange(256)/insecure_randbits(8)/g' src/test/*_tests.cpp -END VERIFY SCRIPT-
2017-06-07Use randbits instead of ad-hoc emulation in prevector testsPieter Wuille
2017-06-07Replace rand() & ((1 << N) - 1) with randbits(N)Pieter Wuille
2017-06-07Replace more rand() % NUM by randrangesPieter Wuille
2017-06-07Cache full script execution results in addition to signaturesMatt Corallo
This adds a new CuckooCache in validation, caching whether all of a transaction's scripts were valid with a given set of script flags. Unlike previous attempts at caching an entire transaction's validity, which have nearly universally introduced consensus failures, this only caches the validity of a transaction's scriptSigs. As these are pure functions of the transaction and data it commits to, this should be much safer. This is somewhat duplicative with the sigcache, as entries in the new cache will also have several entries in the sigcache. However, the sigcache is kept both as ATMP relies on it and because it prevents malleability-based DoS attacks on the new higher-level cache. Instead, the -sigcachesize option is re-used - cutting the sigcache size in half and using the newly freed memory for the script execution cache. Transactions which match the script execution cache never even have entries in the script check thread's workqueue created. Note that the cache is indexed only on the script execution flags and the transaction's witness hash. While this is sufficient to make the CScriptCheck() calls pure functions, this introduces dependancies on the mempool calculating things such as the PrecomputedTransactionData object, filling the CCoinsViewCache, etc in the exact same way as ConnectBlock. I belive this is a reasonable assumption, but should be noted carefully. In a rather naive benchmark (reindex-chainstate up to block 284k with cuckoocache always returning true for contains(), -assumevalid=0 and a very large dbcache), this connected blocks ~1.7x faster.
2017-06-06Use list initialization (C++11) for maps/vectors instead of ↵practicalswift
boost::assign::map_list_of/list_of
2017-06-06Merge #9909: tests: Add FindEarliestAtLeast test for edge casesWladimir J. van der Laan
cf66f04 Add FindEarliestAtLeast test for edge cases (Russell Yanofsky) Tree-SHA512: bed2e9b2eefe0014414f1be8f0ba236b1dcc6744a670ffa546100c62817dd06a117cc62cdff80c4988d2b374cae9a57f2bb135fc582ffb51ca2d34ab07bb3fe0
2017-06-05scripted-diff: use insecure_rand256/randrange morePieter Wuille
-BEGIN VERIFY SCRIPT- sed -i "s/\<GetRandHash(/insecure_rand256(/" src/test/*_tests.cpp sed -i "s/\<GetRand(/insecure_randrange(/" src/test/*_tests.cpp src/test/test_bitcoin.cpp sed -i 's/\<insecure_rand() % \([0-9]\+\)/insecure_randrange(\1)/g' src/test/*_tests.cpp -END VERIFY SCRIPT-
2017-06-05Add various insecure_rand wrappers for testsPieter Wuille
2017-06-05Merge test_random.h into test_bitcoin.hPieter Wuille
2017-06-05scripted-diff: Rename cuckoo tests' local rand contextPieter Wuille
-BEGIN VERIFY SCRIPT- sed -i 's/insecure_rand/local_rand_ctx/g' src/test/cuckoocache_tests.cpp -END VERIFY SCRIPT-
2017-06-05Add FastRandomContext::rand256() and ::randbytes()Pieter Wuille
FastRandomContext now provides all functionality that the real Rand* functions provide.
2017-06-05scripted-diff: Fully remove BOOST_FOREACHJorge Timón
-BEGIN VERIFY SCRIPT- sed -i 's/BOOST_FOREACH *(\(.*\),/for (\1 :/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; -END VERIFY SCRIPT-
2017-06-05Merge #10514: Bugfix: missing == 0 after randrangeWladimir J. van der Laan
9aa215b Bugfixes: missing == 0 after randrange (Pieter Wuille) Tree-SHA512: 160657ac09553f23ad7a3966c753a30ba938ce6f7ccfd34a4ef0d05d73d712362f7eef97e44a96e37a181b8347caa9d8e1584cc4485f69674ab2de3d8a247373
2017-06-05rpc: Add listen address to incoming connections in `getpeerinfo`Wladimir J. van der Laan
This adds the listening address on which incoming connections were received to the CNode and CNodeStats structures. The address is reported in `getpeerinfo`. This can be useful for distinguishing connections received on different listening ports (e.g. when using a different listening port for Tor hidden service connections) or different networks.
2017-06-05Limit variable scopepracticalswift
2017-06-02Bugfixes: missing == 0 after randrangePieter Wuille
2017-06-01scripted-diff: various renames for per-utxo consistencyPieter Wuille
Thanks to John Newberry for pointing these out. -BEGIN VERIFY SCRIPT- sed -i 's/\<GetCoins\>/GetCoin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<HaveCoins\>/HaveCoin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<HaveCoinsInCache\>/HaveCoinInCache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<IsPruned\>/IsSpent/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<FetchCoins\>/FetchCoin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<CoinsEntry\>/CoinEntry/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<vHashTxnToUncache\>/coins_to_uncache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<vHashTxToUncache\>/coins_to_uncache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<fHadTxInCache\>/had_coin_in_cache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<coinbaseids\>/coinbase_coins/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<disconnectedids\>/disconnected_coins/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<duplicateids\>/duplicate_coins/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<oldcoins\>/old_coin/g' src/test/coins_tests.cpp sed -i 's/\<origcoins\>/orig_coin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h -END VERIFY SCRIPT-
2017-06-01Rename CCoinsCacheEntry::coins to coinPieter Wuille
2017-06-01Extend coins_testsPieter Wuille
2017-06-01Switch CCoinsView and chainstate db from per-txid to per-txoutPieter Wuille
This patch makes several related changes: * Changes the CCoinsView virtual methods (GetCoins, HaveCoins, ...) to be COutPoint/Coin-based rather than txid/CCoins-based. * Changes the chainstate db to a new incompatible format that is also COutPoint/Coin based. * Implements reconstruction code for hash_serialized_2. * Adapts the coins_tests unit tests (thanks to Russell Yanofsky). A side effect of the new CCoinsView model is that we can no longer use the (unreliable) test for transaction outputs in the UTXO set to determine whether we already have a particular transaction.
2017-06-01Switch tests from ModifyCoins to AddCoin/SpendCoinPieter Wuille
2017-06-01Switch CScriptCheck to use Coin instead of CCoinsPieter Wuille
2017-06-01Only pass things committed to by tx's witness hash to CScriptCheckMatt Corallo
This clarifies a bit more the ways in which the new script execution cache could break consensus in the future if additional data from the CCoins object were to be used as a part of script execution. After this change, any such consensus breaks should be very visible to reviewers, hopefully ensuring no such changes can be made.
2017-06-01Switch from per-tx to per-txout CCoinsViewCache methods in some placesPieter Wuille
2017-06-01Optimization: Coin&& to ApplyTxInUndoPieter Wuille
This avoids a prevector copy in ApplyTxInUndo.