From a33bcd3654640ec7aa1cbf13fc9cd8b1be0d757d Mon Sep 17 00:00:00 2001 From: Chris Hyunhum Cho Date: Thu, 26 Sep 2024 10:05:44 +0900 Subject: [PATCH] test: ensure push_int check i32::MIN of overflow error --- bitcoin/src/blockdata/script/tests.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bitcoin/src/blockdata/script/tests.rs b/bitcoin/src/blockdata/script/tests.rs index a92c1caea4..480769c419 100644 --- a/bitcoin/src/blockdata/script/tests.rs +++ b/bitcoin/src/blockdata/script/tests.rs @@ -916,3 +916,9 @@ fn instruction_script_num_parse() { Some(Ok(Instruction::PushBytes(PushBytes::empty()))), ); } + +#[test] +fn script_push_int_overflow() { + // Only errors if `data == i32::MIN` (CScriptNum cannot have value -2^31). + assert_eq!(Builder::new().push_int(i32::MIN), Err(Error::NumericOverflow)); +}