diff options
| author | MarcoFalke <[email protected]> | 2020-04-05 04:53:14 +0800 |
|---|---|---|
| committer | MarcoFalke <[email protected]> | 2020-04-05 04:53:19 +0800 |
| commit | 483007749426a1f51ea591eaac383f19fdde9efb (patch) | |
| tree | 5735c1726c325fcc72aced115eb5cbfd553e1dfb /src/test/fuzz/integer.cpp | |
| parent | Merge #18496: test: remove redundant sync_with_ping after add_p2p_connection (diff) | |
| parent | fuzz: Add CScriptNum::getint coverage (diff) | |
| download | discoin-483007749426a1f51ea591eaac383f19fdde9efb.tar.xz discoin-483007749426a1f51ea591eaac383f19fdde9efb.zip | |
Merge #18510: fuzz: Add CScriptNum::getint coverage
faa64af960b64b522bb088e836c9d8cd6254c6c8 fuzz: Add CScriptNum::getint coverage (MarcoFalke)
Pull request description:
Add coverage for
* https://marcofalke.github.io/btc_cov/fuzz.coverage/src/script/script.h.gcov.html#311
* https://marcofalke.github.io/btc_cov/fuzz.coverage/src/script/script.h.gcov.html#511
ACKs for top commit:
practicalswift:
ACK faa64af960b64b522bb088e836c9d8cd6254c6c8 -- more fuzzing coverage is better than less fuzzing coverage :)
Tree-SHA512: 1a66a2edc3740e8c286049f6c27458c59c45b01052e51684eec0e1be63ffcee94b4ba3d41d88ad715ceb3e4754fd997cf03899085982454905e86d0553d58199
Diffstat (limited to 'src/test/fuzz/integer.cpp')
| -rw-r--r-- | src/test/fuzz/integer.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/fuzz/integer.cpp b/src/test/fuzz/integer.cpp index bd2e20030..fff2fabd1 100644 --- a/src/test/fuzz/integer.cpp +++ b/src/test/fuzz/integer.cpp @@ -126,9 +126,21 @@ void test_one_input(const std::vector<uint8_t>& buffer) assert(parsed_money == i64); } } + if (i32 >= 0 && i32 <= 16) { + assert(i32 == CScript::DecodeOP_N(CScript::EncodeOP_N(i32))); + } + const std::chrono::seconds seconds{i64}; assert(count_seconds(seconds) == i64); + const CScriptNum script_num{i64}; + (void)script_num.getint(); + // Avoid negation failure: + // script/script.h:332:35: runtime error: negation of -9223372036854775808 cannot be represented in type 'int64_t' (aka 'long'); cast to an unsigned type to negate this value to itself + if (script_num != CScriptNum{std::numeric_limits<int64_t>::min()}) { + (void)script_num.getvch(); + } + const arith_uint256 au256 = UintToArith256(u256); assert(ArithToUint256(au256) == u256); assert(uint256S(au256.GetHex()) == u256); |