Skip to content

Commit

Permalink
Alter implementation to rely on attribute's existence
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcticae committed Jan 17, 2024
1 parent b5133cd commit a353fc8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use serde::Serialize;

const FORK_ATTR: &str = "fork";
const FUZZER_ATTR: &str = "fuzzer";

const AVAILABLE_GAS_ATTR: &str = "available_gas";
/// Expectation for a panic case.
#[derive(Debug, Clone, PartialEq, Serialize)]
pub enum ExpectedPanicValue {
Expand Down Expand Up @@ -152,7 +152,11 @@ pub fn forge_try_extract_test_config(
ignored,
}| {
// Older versions will crash if the default is passed through
if available_gas.is_some_and(|gas_amt| gas_amt == u32::MAX as usize){
let available_gas_attr = attrs
.iter()
.find(|attr| attr.id.as_str() == AVAILABLE_GAS_ATTR);

if available_gas_attr.is_none() {
available_gas = None
}

Expand Down
5 changes: 1 addition & 4 deletions extensions/scarb-snforge-test-collector/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ fn forge_test_locations() {
assert_eq!(&json[1]["test_cases"][0]["name"], "tests::tests::test");
assert_eq!(&json[1]["tests_location"], "Tests");

assert_eq!(
&json[0]["test_cases"][0]["available_gas"],
&Value::Null
);
assert_eq!(&json[0]["test_cases"][0]["available_gas"], &Value::Null);
assert_eq!(&json[0]["test_cases"][0]["expected_result"], "Success");
assert_eq!(&json[0]["test_cases"][0]["fork_config"], &Value::Null);
assert_eq!(&json[0]["test_cases"][0]["fuzzer_config"], &Value::Null);
Expand Down

0 comments on commit a353fc8

Please sign in to comment.