File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ use ethers::{
77 types:: Address ,
88 utils:: keccak256,
99} ;
10- use eyre:: Result ;
10+ use eyre:: { Result , WrapErr } ;
1111use foundry_cli:: { handler, prompt, stdin, utils} ;
1212use foundry_common:: {
1313 abi:: { format_tokens, get_event} ,
@@ -174,7 +174,7 @@ async fn main() -> Result<()> {
174174 println ! ( "{}" , pretty_calldata( & calldata, offline) . await ?) ;
175175 }
176176 Subcommands :: Sig { sig, optimize } => {
177- let sig = stdin:: unwrap_line ( sig) ?;
177+ let sig = stdin:: unwrap_line ( sig) . wrap_err ( "Failed to read signature" ) ?;
178178 if optimize. is_none ( ) {
179179 println ! ( "{}" , SimpleCast :: get_selector( & sig, None ) ?. 0 ) ;
180180 } else {
Original file line number Diff line number Diff line change @@ -886,6 +886,7 @@ pub fn parse_slot(s: &str) -> Result<H256> {
886886#[ cfg( test) ]
887887mod tests {
888888 use super :: * ;
889+ use cast:: SimpleCast ;
889890 use ethers:: types:: BlockNumber ;
890891
891892 #[ test]
@@ -908,6 +909,29 @@ mod tests {
908909 } ;
909910 }
910911
912+ // <https://github.com/foundry-rs/book/issues/1019>
913+ #[ test]
914+ fn parse_signature ( ) {
915+ let args: Opts = Opts :: parse_from ( [
916+ "foundry-cli" ,
917+ "sig" ,
918+ "__$_$__$$$$$__$$_$$$_$$__$$___$$(address,address,uint256)" ,
919+ ] ) ;
920+ match args. sub {
921+ Subcommands :: Sig { sig, .. } => {
922+ let sig = sig. unwrap ( ) ;
923+ assert_eq ! (
924+ sig,
925+ "__$_$__$$$$$__$$_$$$_$$__$$___$$(address,address,uint256)" . to_string( )
926+ ) ;
927+
928+ let selector = SimpleCast :: get_selector ( & sig, None ) . unwrap ( ) ;
929+ assert_eq ! ( selector. 0 , "0x23b872dd" . to_string( ) ) ;
930+ }
931+ _ => unreachable ! ( ) ,
932+ } ;
933+ }
934+
911935 #[ test]
912936 fn parse_block_ids ( ) {
913937 struct TestCase {
You can’t perform that action at this time.
0 commit comments