Skip to content

Commit 2ab1b55

Browse files
starknet_os_flow_tests: add all uncovered regression test
1 parent 8ea9e41 commit 2ab1b55

File tree

1 file changed

+46
-1
lines changed
  • crates/starknet_os_flow_tests/src

1 file changed

+46
-1
lines changed

crates/starknet_os_flow_tests/src/tests.rs

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::collections::{HashMap, HashSet};
2+
use std::fs;
23
use std::sync::{Arc, LazyLock};
34

45
use assert_matches::assert_matches;
@@ -12,7 +13,8 @@ use blockifier_test_utils::cairo_versions::{CairoVersion, RunnableCairo1};
1213
use blockifier_test_utils::calldata::create_calldata;
1314
use blockifier_test_utils::contracts::FeatureContract;
1415
use cairo_vm::types::builtin_name::BuiltinName;
15-
use expect_test::expect;
16+
use expect_test::{expect, Expect};
17+
use itertools::Itertools;
1618
use rstest::rstest;
1719
use starknet_api::abi::abi_utils::{get_storage_var_address, selector_from_name};
1820
use starknet_api::block::{BlockInfo, BlockNumber, BlockTimestamp, GasPrice};
@@ -83,6 +85,7 @@ use starknet_committer::block_committer::input::{
8385
use starknet_committer::patricia_merkle_tree::types::CompiledClassHash;
8486
use starknet_core::crypto::ecdsa_sign;
8587
use starknet_crypto::{get_public_key, Signature};
88+
use starknet_os::hints::enum_definition::AllHints;
8689
use starknet_os::hints::hint_implementation::deprecated_compiled_class::class_hash::compute_deprecated_class_hash;
8790
use starknet_os::hints::vars::Const;
8891
use starknet_os::io::os_output::MessageToL2;
@@ -116,6 +119,27 @@ use crate::utils::{
116119
update_expected_storage_updates_for_block_hash_contract,
117120
};
118121

122+
const UNCOVERED_HINTS: Expect = expect![[r#"
123+
[
124+
"AggregatorHint(DisableDaPageCreation)",
125+
"AggregatorHint(GetAggregatorOutput)",
126+
"AggregatorHint(GetChainIdFromInput)",
127+
"AggregatorHint(GetFeeTokenAddressFromInput)",
128+
"AggregatorHint(GetFullOutputFromInput)",
129+
"AggregatorHint(GetOsOuputForInnerBlocks)",
130+
"AggregatorHint(GetPublicKeysFromAggregatorInput)",
131+
"AggregatorHint(GetUseKzgDaFromInput)",
132+
"AggregatorHint(WriteDaSegment)",
133+
"DeprecatedSyscallHint(DelegateCall)",
134+
"DeprecatedSyscallHint(DelegateL1Handler)",
135+
"DeprecatedSyscallHint(Deploy)",
136+
"OsHint(GetClassHashAndCompiledClassFact)",
137+
"OsHint(InitializeAliasCounter)",
138+
"OsHint(LoadBottom)",
139+
"StatelessHint(SetApToSegmentHashPoseidon)",
140+
]
141+
"#]];
142+
119143
pub(crate) static NON_TRIVIAL_RESOURCE_BOUNDS: LazyLock<ValidResourceBounds> =
120144
LazyLock::new(|| {
121145
ValidResourceBounds::AllResources(AllResourceBounds {
@@ -155,6 +179,27 @@ fn division(#[case] length: usize, #[case] n_parts: usize, #[case] expected_leng
155179
assert_eq!(actual_lengths, expected_lengths);
156180
}
157181

182+
/// Tests that the set of uncovered hints is up to date.
183+
#[rstest]
184+
fn test_coverage_regression() {
185+
// Iterate over all JSON files in the coverage directory.
186+
let covered_hints = fs::read_dir("resources/hint_coverage")
187+
.unwrap()
188+
.map(|entry| entry.unwrap())
189+
.flat_map(|entry| {
190+
serde_json::from_str::<Vec<AllHints>>(&fs::read_to_string(entry.path()).unwrap())
191+
.unwrap()
192+
})
193+
.unique()
194+
.collect::<Vec<_>>();
195+
let uncovered_hints = AllHints::all_iter()
196+
.filter(|hint| !covered_hints.contains(hint))
197+
.map(|hint| format!("{hint:?}"))
198+
.sorted()
199+
.collect::<Vec<_>>();
200+
UNCOVERED_HINTS.assert_debug_eq(&uncovered_hints);
201+
}
202+
158203
/// Scenario of declaring and deploying the test contract.
159204
#[rstest]
160205
#[tokio::test]

0 commit comments

Comments
 (0)