Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consensus: fix chunk::from_bool(bool) (false must be empty). #1525

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading