Skip to content

Commit

Permalink
Consensus: fix chunk::from_bool(bool) (false must be empty).
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Aug 20, 2024
1 parent f6721b4 commit 78feda1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion include/bitcoin/system/impl/machine/number.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ is_overflow(int64_t value) NOEXCEPT

inline data_chunk chunk::from_bool(bool vary) NOEXCEPT
{
return { bc::to_int<uint8_t>(vary) };
static const data_chunk true_{ 1 };
static const data_chunk false_{};
return vary ? true_ : false_;
}

inline data_chunk chunk::from_integer(int64_t vary) NOEXCEPT
Expand Down
3 changes: 2 additions & 1 deletion test/chain/script.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ const script_test_list valid_context_free_scripts
{ "nop", "nop10 1", "" },
{ "[42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242]", "[2.42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242] equal", "basic push signedness check" },
{ "[1.42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242]", "[2.42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242] equal", "basic pushdata1 signedness check" },
{ "0x00", "size 0 equal", "basic op_0 execution" }
{ "0x00", "size 0 equal", "basic op_0 execution" },
{ "", "0 1 equal size 0 equal", "boolean encoding" }
}};

// These are always invalid.
Expand Down

0 comments on commit 78feda1

Please sign in to comment.