aboutsummaryrefslogtreecommitdiff
path: root/src/test/transaction_tests.cpp
AgeCommit message (Collapse)Author
2021-05-10refactor: Remove useless extern keywordMarcoFalke
2021-04-19Merge bitcoin/bitcoin#21280: test: bug fix in transaction_testsMarcoFalke
b109bde46a8730afbc09c107b802a2c321293f4b [test] check that mapFlagNames is up to date (glozow) 5d3ced72f9b5f36db1a76bd8bc918d11b87dfd72 [test] remove unnecessary OP_1s from invalid tests (glozow) 5aee73d1759bcc0d1e951776942e616843934af1 [test] minor improvements / followups (glozow) 8a365df5586b36d1772c78069f9d93c56a81df6f [test] fix bug in ExcludeIndividualFlags (glozow) 8cac2923f57ac33848ff41b74c3be520b75936df [test] remove invalid test from tx_valid.json (glozow) Pull request description: This is a followup to #19698. - There was a bug in the `ExcludeIndividualFlags` function which is fixed here. - Fixing this bug also showed that there is a test that's supposed to fail (already existing in tx_invalid.json) in tx_valid.json, so I removed it. Other than that, the tests should all pass. - Also implements a few suggestions I received offline: removing the `OP_1`s from the invalid tests (similar to https://github.com/bitcoin/bitcoin/commit/19db590d044efe7d474a16720e5b56e7b55db54c), comments, and style. - A few other small fixes, like adding asserts, putting all the flags in `mapFlagNames`, better error messages ACKs for top commit: jnewbery: utACK b109bde46a8730afbc09c107b802a2c321293f4b Tree-SHA512: 7233a8c0f1ae1172fac8000ea6e05384ecf79074c39948d118464868505c7f02f17e96503c81bd05c07adb2087648a5d93d9899e16fdefa6b7efcb51319444a9
2021-04-07[test] check that mapFlagNames is up to dateglozow
There is no way to iterate through all script verification flags, and it's not guaranteed that every power of 2 is used. Just make sure that all flags in STANDARD_SCRIPT_VERIFY_FLAGS are present in mapFlagNames; this covers all consensus and policy flags. If mapFlagNames has more flags than STANDARD_SCRIPT_VERIFY_FLAGS, that's okay. Nonexistent flags will be caught by the compiler.
2021-04-07[test] minor improvements / followupsglozow
Add missing script verify flags to mapFlagNames. iterate through mapFlagNames values instead of bits. BOOST_CHECK_MESSAGE better reports which test failed exactly, whereas BOOST_ERROR was just incrementing the error counter.
2021-04-07[test] fix bug in ExcludeIndividualFlagsglozow
PR #19168 introduced this function but it always returns an empty vector.
2021-03-15Make all SignatureChecker explicit about missing dataPieter Wuille
Remove the implicit MissingDataBehavior::ASSERT_FAIL in the *TransationSignatureChecker constructors, and instead specify it explicit in all call sites: * Test code uses ASSERT_FAIL * Validation uses ASSERT_FAIL (through CachingTransactionSignatureChecker) (including signet) * libconsensus uses FAIL, matching the existing behavior of the non-amount API (and the extended required data for taproot validation is not available yet) * Signing code uses FAIL
2021-02-24test: Replace accidentally placed bit-OR with logical-ORHennadii Stepanov
2021-02-02Verify that all validation flags are backward compatiblegzhao408
See #10699, i.e. adding a flag should always reduce the number of acceptable scripts. Co-authored-by: Johnson Lau <jl2012@xbt.hk>
2021-02-02[test] check verification flags are minimal/maximalgzhao408
Co-authored-by: Johnson Lau <jl2012@xbt.hk>
2021-02-02[test] Check for invalid flag combinationsgzhao408
2021-02-02[refactor] use CheckTxScripts, TrimFlags, FillFlagsgzhao408
Co-authored-by: Johnson Lau <jl2012@xbt.hk>
2021-02-02[test] add BADTX setting for invalid txns that fail CheckTransactiongzhao408
Co-authored-by: Johnson Lau <jl2012@xbt.hk>
2021-02-02Apply maximal validation flags to tx_valid testsgzhao408
- Apply all validation flags by default - Invert the meaning of verifyFlags as flags being excluded Co-authored-by: Johnson Lau <jl2012@xbt.hk>
2021-01-26Merge bitcoin-core/gui#183: Add include for std::bind.MarcoFalke
2a39ccf1334ef3c48c6f9969a0fc916b9e10aae1 Add include for std::bind. (sinetek) Pull request description: Hi, this patch adds in <functional> because the GUI code makes use of std::bind. That's all. ACKs for top commit: jonasschnelli: utACK 2a39ccf1334ef3c48c6f9969a0fc916b9e10aae1 Tree-SHA512: fb5ac07d9cd5d006182b52857b289a9926362a2f1bfa4f7f1c78a088670e2ccf39ca28214781df82e8de3909fa3e69685fe1124a7e3ead758575839f5f2277a9
2021-01-25Merge #18710: Add local thread pool to CCheckQueueWladimir J. van der Laan
bb6fcc75d1ec94b733d1477c816351c50be5faf9 refactor: Drop boost::thread stuff in CCheckQueue (Hennadii Stepanov) 6784ac471bb32b6bb8e2de60986f123eb4990706 bench: Use CCheckQueue local thread pool (Hennadii Stepanov) dba30695fc42f45828db008e7e5b81cb2b5d8551 test: Use CCheckQueue local thread pool (Hennadii Stepanov) 01511776acb0c7ec216dc9c8112531067763f1cb Add local thread pool to CCheckQueue (Hennadii Stepanov) 0ef938685b5c079a6f5a98daf0e3865d718d817b refactor: Use member initializers in CCheckQueue (Hennadii Stepanov) Pull request description: This PR: - gets rid of `boost::thread_group` in the `CCheckQueue` class - allows thread safety annotation usage in the `CCheckQueue` class - is alternative to #14464 (https://github.com/bitcoin/bitcoin/pull/18710#issuecomment-616618525, https://github.com/bitcoin/bitcoin/pull/18710#issuecomment-617291612) Also, with this PR (I hope) it could be easier to resurrect a bunch of brilliant ideas from #9938. Related: #17307 ACKs for top commit: laanwj: Code review ACK bb6fcc75d1ec94b733d1477c816351c50be5faf9 LarryRuane: ACK bb6fcc75d1ec94b733d1477c816351c50be5faf9 jonatack: Code review ACK bb6fcc75d1ec94b733d1477c816351c50be5faf9 and verified rebase to master builds cleanly with unit/functional tests green Tree-SHA512: fddeb720d5a391b48bb4c6fa58ed34ccc3f57862fdb8e641745c021841c8340e35c5126338271446cbd98f40bd5484f27926aa6c3e76fa478ba1efafe72e73c1
2021-01-13Add include for std::bind.sinetek
2020-12-24test: Set correct nValue for multi-op-return policy checkMarcoFalke
2020-10-30Only relay Taproot spends if next block has it activePieter Wuille
2020-10-12tests: add generic qa-asset-based script verification unit testPieter Wuille
This adds a unit test that does generic script verification tests, with positive/negative witnesses/scriptsigs, under various flags. The test data is large (several MB) so it's stored in the qa-assets repo.
2020-09-24test: Use CCheckQueue local thread poolHennadii Stepanov
2020-08-15Merge #16841: Replace GetScriptForWitness with GetScriptForDestinationfanquake
7966aa424a8b78983f73742cbdb3d11eccaf9f3a Add variables for repeated scripts (MeshCollider) fec8336ad97dc717ea123f84ecfc10d9ee4a11db Remove GetScriptForWitness function (MeshCollider) b887060d06290abf4983a487f8da6b0986b058ab Replace usage of GetScriptForWitness with GetScriptForDestination (MeshCollider) Pull request description: As per this TODO in the code: > TODO: replace calls to GetScriptForWitness with GetScriptForDestination using the various witness-specific CTxDestination subtypes. The commit "Add additional check for P2SH before adding extra wrapper" also adds an additional check that the scriptPubKey is a P2SH before auto-wrapping the witness script. We shouldn't wrap the witness script if not. Note: #16251 is even better than this check, please review that. ACKs for top commit: instagibbs: ACK https://github.com/bitcoin/bitcoin/pull/16841/commits/7966aa424a8b78983f73742cbdb3d11eccaf9f3a jonatack: Code review re-ACK 7966aa4 per `git range-diff b4d0366 ed266f7 7966aa4` achow101: re-ACK 7966aa424a8b78983f73742cbdb3d11eccaf9f3a only changes since last is rebase. Tree-SHA512: 3449e0e83bd842acc7c94544a85367da97ac20d859eefc1a618caef0c98204398c266fe8fb9600b78326df5175402e1ae4a132eb766e2c4485e7cda6a2a95c43
2020-08-14Add variables for repeated scriptsMeshCollider
2020-08-14Replace usage of GetScriptForWitness with GetScriptForDestinationMeshCollider
2020-07-15Do not turn OP_1NEGATE in scriptSig into 0x0181 in signing codePieter Wuille
Co-authored-by: Samuel Dobson <dobsonsa68@gmail.com>
2020-06-21scripted-diff: TxoutType C++11 scoped enum classMarcoFalke
-BEGIN VERIFY SCRIPT- # General rename helper: $1 -> $2 rename_global() { sed -i "s/\<$1\>/$2/g" $(git grep -l "$1"); } # Helper to rename TxoutType $1 rename_value() { sed -i "s/ TX_$1,/ $1,/g" src/script/standard.h; # First strip the prefix in the definition (header) rename_global TX_$1 "TxoutType::$1"; # Then replace globally } # Change the type globally to bring it in line with the style-guide # (clsses are UpperCamelCase) rename_global 'enum txnouttype' 'enum class TxoutType' rename_global 'txnouttype' 'TxoutType' # Now rename each enum value rename_value 'NONSTANDARD' rename_value 'PUBKEY' rename_value 'PUBKEYHASH' rename_value 'SCRIPTHASH' rename_value 'MULTISIG' rename_value 'NULL_DATA' rename_value 'WITNESS_V0_KEYHASH' rename_value 'WITNESS_V0_SCRIPTHASH' rename_value 'WITNESS_UNKNOWN' -END VERIFY SCRIPT-
2020-05-03Remove CCoinsViewCache::GetValueIn(...)practicalswift
2020-04-16scripted-diff: Bump copyright headersMarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
2020-04-16scripted-diff: Sort test includesMarcoFalke
-BEGIN VERIFY SCRIPT- # Mark all lines with #includes sed -i --regexp-extended -e 's/(#include <.*>)/\1 /g' $(git grep -l '#include' ./src/bench/ ./src/test ./src/wallet/test/) # Sort all marked lines git diff -U0 | ./contrib/devtools/clang-format-diff.py -p1 -i -v -END VERIFY SCRIPT-
2020-03-24Merge #17720: test: add unit test for non-standard "scriptsig-not-pushonly" txsMarcoFalke
5aab011805ceb12801644170700b1a62e0bf4a5d test: add unit test for non-standard "scriptsig-not-pushonly" txs (Sebastian Falbesoner) Pull request description: Approaches another missing unit test of issue #17394: Checks that the function `IsStandardTx()` returns rejection reason "scriptsig-not-pushonly" if any one of the input's scriptSig consists of any other ops than just PUSHs. ACKs for top commit: MarcoFalke: ACK 5aab011805ceb12801644170700b1a62e0bf4a5d 🍟 practicalswift: ACK 5aab011805ceb12801644170700b1a62e0bf4a5d -- patch looks correct Tree-SHA512: fbe25bcf57e5f0c8d2397eb67e61fe8d9145ba83032789adb2b67d6fcbcd87e6427e9d965e8cd7bbaaea482e39ec2f110f71ef2de079c7d1fba2712848caa9ba
2020-02-29Merge #18173: refactor: test/bench: deduplicate SetupDummyInputs()MarcoFalke
7bf4ce4f644bb7dac9b63172c656b5d599eedea3 refactor: test/bench: dedup SetupDummyInputs() (Sebastian Falbesoner) Pull request description: The only difference between `SetupDummyInputs()` in `test/transaction_tests.cpp` and the one in `bench/ccoins_caching.cpp` was the nValue amounts of the outputs, so we allow to pass those in an extra (fixed-size) array parameter. ACKs for top commit: MarcoFalke: re-ACK 7bf4ce4f64, only change is schuffling includes 🚶 Empact: ACK https://github.com/bitcoin/bitcoin/pull/18173/commits/7bf4ce4f644bb7dac9b63172c656b5d599eedea3 Tree-SHA512: e13643b2470f6b6ab429da0c0a8eebd4cb41e2ff2e421ef36f85fa4847bf4ea8aab88d59a01e94cac4c4eb85edb561463f02215b174c50b573ac6bbcc2bf98a3
2020-02-28test: add unit test for non-standard "scriptsig-not-pushonly" txsSebastian Falbesoner
The function IsStandardTx() returns rejection reason "scriptsig-not-pushonly" if the transaction has at least one input for which the scriptSig consists of any other ops than just PUSHs.
2020-02-28refactor: test/bench: dedup SetupDummyInputs()Sebastian Falbesoner
The only difference between SetupDummyInputs() in test/transaction_tests.cpp and the one in bench/ccoins_caching.cpp was the nValue amounts of the outputs, so we allow to pass those in an extra (fixed-size) array parameter.
2020-02-19test: Tabs to spaces in all testsMarcoFalke
Spaces are used in all of the source code except in these two instances
2020-02-10Merge #17947: test: add unit test for non-standard txs with too large tx sizeWladimir J. van der Laan
4537ba5f21ad8afb705325cd8e15dd43877eb28f test: add unit test for non-standard txs with too large tx size (Sebastian Falbesoner) Pull request description: Approaches another missing unit test of issue #17394: Checks that the function `IsStandardTx()` returns rejection reason `"tx-size"` if the transaction weight is larger than `MAX_STANDARD_TX_WEIGHT` (=400000 vbytes). ACKs for top commit: Empact: Code Review ACK https://github.com/bitcoin/bitcoin/pull/17947/commits/4537ba5f21ad8afb705325cd8e15dd43877eb28f instagibbs: ACK https://github.com/bitcoin/bitcoin/commit/4537ba5f21ad8afb705325cd8e15dd43877eb28f Tree-SHA512: ab32e3e47e0b337253aef3da9b7c97d01f4130d00d5860588dfed02114eec3ba49473acc6419448affd63e883fd827bf308716965606eaddee242c4c5a4eb799
2020-01-30tests: reset fIsBareMultisigStd after bare-multisig testsfanquake
The bug this fixes is two-part. 1.The fIsBareMultisigStd global is being reused by other tests, i.e script_p2sh_tests(set), after being set to false. 2. The order our tests run in doesn't always? seem to be random, which meant that the script_p2sh tests would only fail if they were run in an order where transaction_tests ran first, mutating the fIsBareMultisigStd global. This doesn't seem to happen when running make check, but if you run src/test/test_bitcoin and pass --random=99999, the failure in script_p2sh: test/script_p2sh_tests.cpp:200: error: in "script_p2sh_tests/set": txTo[1].IsStandard will occur (on most systems). The new test was introduced in 1bb5d517aa616c1d5b5801d2ea36a2de5fb61eba.
2020-01-16test: add unit test for non-standard txs with too large tx sizeSebastian Falbesoner
The function IsStandardTx() returns rejection reason "tx-size" if the transaction weight is larger than MAX_STANDARD_TX_WEIGHT (=400000 vbytes).
2019-12-10Merge #17502: test: add unit test for non-standard bare multisig txsMarcoFalke
1bb5d517aa616c1d5b5801d2ea36a2de5fb61eba test: add unit test for non-standard bare multisig txs (Sebastian Falbesoner) Pull request description: Approaches another missing unit test of issue #17394: Checks that the function `IsStandardTx()` returns rejection reason `"bare-multisig"` if any one of the outputs' scriptPubKey has bare multisignature format (i.e. `M <PubKey1> <PubKey2> ... <PubKeyN> N OP_CHECKSIG`, not P2SH!) and the policy flag `fIsBareMultisigStd` is set to false. ACKs for top commit: instagibbs: utACK https://github.com/bitcoin/bitcoin/pull/17502/commits/1bb5d517aa616c1d5b5801d2ea36a2de5fb61eba Tree-SHA512: d7c95e35da16520d6dcd2b4278e2426fedd13f68d1f23c90e85e929774e123fbfcfbccc26df6ad1c0dd61780896fa4b4b3d4e8280c647bb06df2bfcf2ba572fb
2019-11-21test: add unit test for non-standard txs with wrong nVersionDominik Spicher
2019-11-21test: add unit test for non-standard bare multisig txsSebastian Falbesoner
The function IsStandardTx() returns rejection reason "bare-multisig" if the transaction has a bare multisig output and the policy flag fIsBareMultisigStd is false (set by the boolean command-line argument "-permitbaremultisig" -- for the unit test, we simply set the global flag variable directly).
2019-11-14test: add unit test for non-standard txs with too large scriptSigSebastian Falbesoner
The function IsStandardTx() returns rejection reason "scriptsig-size" if any one the inputs' scriptSig is larger than 1650 bytes.
2019-11-06scripted-diff: test: Move setup_common to test libraryMarcoFalke
-BEGIN VERIFY SCRIPT- # Move files for f in $(git ls-files src/test/lib/); do git mv $f src/test/util/; done git mv src/test/setup_common.cpp src/test/util/ git mv src/test/setup_common.h src/test/util/ # Replace Windows paths sed -i -e 's|\\setup_common|\\util\\setup_common|g' $(git grep -l '\\setup_common') sed -i -e 's|src\\test\\lib\\|src\\test\\util\\|g' build_msvc/test_bitcoin/test_bitcoin.vcxproj # Everything else sed -i -e 's|/setup_common|/util/setup_common|g' $(git grep -l 'setup_common') sed -i -e 's|test/lib/|test/util/|g' $(git grep -l 'test/lib/') # Fix include guard sed -i -e 's|BITCOIN_TEST_SETUP_COMMON_H|BITCOIN_TEST_UTIL_SETUP_COMMON_H|g' ./src/test/util/setup_common.h sed -i -e 's|BITCOIN_TEST_LIB_|BITCOIN_TEST_UTIL_|g' $(git grep -l 'BITCOIN_TEST_LIB_') -END VERIFY SCRIPT-
2019-10-30Merge #15921: validation: Tidy up ValidationState interfaceWladimir J. van der Laan
3004d5a12d09d94bfc4dee2a8e8f2291996a4aaf [validation] Remove fMissingInputs from AcceptToMemoryPool() (John Newbery) c428622a5bb1e37b2e6ab2c52791ac05d9271238 [validation] Remove unused first_invalid parameter from ProcessNewBlockHeaders() (John Newbery) 7204c6434b944f6ad51b3c895837729d3aa56eea [validation] Remove useless ret parameter from Invalid() (John Newbery) 1a37de4b3174d19a6d8691ae07e92b32fdfaef11 [validation] Remove error() calls from Invalid() calls (John Newbery) 067981e49246822421a7bcc720491427e1dba8a3 [validation] Tidy Up ValidationResult class (John Newbery) a27a2957ed9afbe5a96caa5f0f4cbec730d27460 [validation] Add CValidationState subclasses (John Newbery) Pull request description: Carries out some remaining tidy-ups remaining after PR 15141: - split ValidationState into TxValidationState and BlockValidationState (commit from ajtowns) - various minor code style tidy-ups to the ValidationState class - remove the useless `ret` parameter from `ValidationState::Invalid()` - remove the now unused `first_invalid` parameter from `ProcessNewBlockHeaders()` - remove the `fMissingInputs` parameter from `AcceptToMemoryPool()`, and deal with missing inputs the same way as other errors by using the `TxValidationState` object. Tip for reviewers (thanks ryanofsky!): The first commit ("[validation] Add CValidationState subclasses" ) is huge and can be easier to start reviewing if you revert the rote, mechanical changes: Substitute the commit hash of commit "[validation] Add CValidationState subclasses" for <CommitHash> in the commands below. ```sh git checkout <CommitHash> git grep -l ValidationState | xargs sed -i 's/BlockValidationState\|TxValidationState/CValidationState/g' git grep -l ValidationResult | xargs sed -i 's/BlockValidationResult\|TxValidationResult/ValidationInvalidReason/g' git grep -l MaybePunish | xargs sed -i 's/MaybePunishNode\(ForBlock\|ForTx\)/MaybePunishNode/g' git diff HEAD^ ``` After that it's possible to easily see the mechanical changes with: ```sh git log -p -n1 -U0 --word-diff-regex=. <CommitHash> ``` ACKs for top commit: laanwj: ACK 3004d5a12d09d94bfc4dee2a8e8f2291996a4aaf amitiuttarwar: code review ACK 3004d5a12d09d94bfc4dee2a8e8f2291996a4aaf. Also built & ran tests locally. fjahr: Code review ACK 3004d5a12d09d94bfc4dee2a8e8f2291996a4aaf . Only nit style change and pure virtual destructor added since my last review. ryanofsky: Code review ACK 3004d5a12d09d94bfc4dee2a8e8f2291996a4aaf. Just whitespace change and pure virtual destructor added since last review. Tree-SHA512: 511de1fb380a18bec1944ea82b513b6192df632ee08bb16344a2df3c40811a88f3872f04df24bc93a41643c96c48f376a04551840fd804a961490d6c702c3d36
2019-10-29[validation] Add CValidationState subclassesJohn Newbery
Split CValidationState into TxValidationState and BlockValidationState to store validation results for transactions and blocks respectively.
2019-10-29test: add reason checks for non-standard txs in test_IsStandardSebastian Falbesoner
2019-07-09Move various SigningProviders to signingprovider.{cpp,h}Andrew Chow
Moves all of the various SigningProviders out of sign.{cpp,h} and keystore.{cpp,h}. As such, keystore.{cpp,h} is also removed. Includes and the Makefile are updated to reflect this. Includes were largely changed using: git grep -l "keystore.h" | xargs sed -i -e 's;keystore.h;script/signingprovider.h;g'
2019-07-09scripted-diff: rename CBasicKeyStore to FillableSigningProviderAndrew Chow
-BEGIN VERIFY SCRIPT- git grep -l "CBasicKeyStore" | xargs sed -i -e 's/CBasicKeyStore/FillableSigningProvider/g' -END VERIFY SCRIPT-
2019-07-09Remove CKeyStore and squash into CBasicKeyStoreAndrew Chow
2019-06-26tests: Reduce compilation time and unneccessary recompiles by removing ↵practicalswift
unused includes in tests
2019-04-29Replace CScriptID and CKeyID in CTxDestination with dedicated typesGregory Sanders
2019-04-11scripted-diff: Bump copyright headers in test, benchMarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./src/bench/ ./contrib/devtools/copyright_header.py update ./src/test/ -END VERIFY SCRIPT-