From e9e9b5118dc625cb27f70f9057764beca4ae48ba Mon Sep 17 00:00:00 2001 From: Hein Dauven Date: Tue, 29 Oct 2024 12:44:35 +0100 Subject: [PATCH] rusk: Add test cases for large feeder_call_gas deser --- rusk/default.config.toml | 2 +- rusk/src/bin/config/http.rs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/rusk/default.config.toml b/rusk/default.config.toml index 8509b77699..71d023a9b0 100644 --- a/rusk/default.config.toml +++ b/rusk/default.config.toml @@ -9,7 +9,7 @@ #key = # The default max cost for feeder calls is the maximum representable. Put in a -# a string wrapped number up to u64 +# a string wrapped number up to u64::MAX #feeder_call_gas = "18446744073709551615" #ws_sub_channel_cap = 16, diff --git a/rusk/src/bin/config/http.rs b/rusk/src/bin/config/http.rs index 31914020e3..7a4daf84f6 100644 --- a/rusk/src/bin/config/http.rs +++ b/rusk/src/bin/config/http.rs @@ -233,4 +233,22 @@ mod tests { let result = toml::from_str::(config_str); assert!(result.is_err()); } + + #[test] + fn deserialize_large_feeder_call_gas() { + // A feeder_call_gas value beyond i64::MAX, but within u64 limits + let config_str = r#"feeder_call_gas = "9999999999999999999""#; + + // Should parse successfully as it is within u64 range and a string + let config: HttpConfig = toml::from_str(config_str) + .expect("parsing large u64 value should succeed"); + assert_eq!(config.feeder_call_gas, 9999999999999999999); + + let config_str = r#"feeder_call_gas = "18446744073709551615""#; // u64::MAX + + // Should also parse successfully + let config: HttpConfig = toml::from_str(config_str) + .expect("parsing u64::MAX should succeed"); + assert_eq!(config.feeder_call_gas, u64::MAX); + } }