Skip to content

Commit 82f9a71

Browse files
starknet_os_flow_tests: add all uncovered regression test
1 parent f1ef1c4 commit 82f9a71

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};
@@ -84,6 +86,7 @@ use starknet_committer::block_committer::input::{
8486
use starknet_committer::patricia_merkle_tree::types::CompiledClassHash;
8587
use starknet_core::crypto::ecdsa_sign;
8688
use starknet_crypto::{get_public_key, Signature};
89+
use starknet_os::hints::enum_definition::AllHints;
8790
use starknet_os::hints::hint_implementation::deprecated_compiled_class::class_hash::compute_deprecated_class_hash;
8891
use starknet_os::hints::vars::Const;
8992
use starknet_os::io::os_output::MessageToL2;
@@ -117,6 +120,27 @@ use crate::utils::{
117120
update_expected_storage_updates_for_block_hash_contract,
118121
};
119122

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

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

0 commit comments

Comments
 (0)