@@ -1340,3 +1340,45 @@ async fn simulate_should_skip_strict_nonce_check(#[case] nonce: Felt, #[case] sh
13401340 let res = contract. transfer ( & recipient, & amount) . nonce ( nonce) . simulate ( false , false ) . await ;
13411341 assert_eq ! ( res. is_ok( ) , should_ok)
13421342}
1343+
1344+ /// Test that special system contract addresses (0x1 and 0x2) return ClassHash::ZERO
1345+ /// for `get_class_hash_at` calls, as they don't have an associated class.
1346+ ///
1347+ /// See https://docs.starknet.io/architecture-and-concepts/network-architecture/starknet-state/#address_0x1
1348+ #[ tokio:: test]
1349+ async fn special_system_contract_class_hash ( ) {
1350+ let sequencer = TestNode :: new ( ) . await ;
1351+ let provider = sequencer. starknet_rpc_client ( ) ;
1352+
1353+ // Address 0x1 should return ClassHash::ZERO
1354+ let class_hash =
1355+ provider. get_class_hash_at ( BlockIdOrTag :: PreConfirmed , felt ! ( "0x1" ) . into ( ) ) . await . unwrap ( ) ;
1356+ assert_eq ! ( class_hash, Felt :: ZERO , "Address 0x1 should return ClassHash::ZERO" ) ;
1357+
1358+ // Address 0x2 should return ClassHash::ZERO
1359+ let class_hash =
1360+ provider. get_class_hash_at ( BlockIdOrTag :: PreConfirmed , felt ! ( "0x2" ) . into ( ) ) . await . unwrap ( ) ;
1361+ assert_eq ! ( class_hash, Felt :: ZERO , "Address 0x2 should return ClassHash::ZERO" ) ;
1362+ }
1363+
1364+ /// Test that `get_storage_at` works for special system contract addresses (0x1 and 0x2)
1365+ /// without returning ContractNotFound error.
1366+ ///
1367+ /// See https://docs.starknet.io/architecture-and-concepts/network-architecture/starknet-state/#address_0x1
1368+ #[ tokio:: test]
1369+ async fn special_system_contract_storage ( ) {
1370+ let sequencer = TestNode :: new ( ) . await ;
1371+ let provider = sequencer. starknet_rpc_client ( ) ;
1372+
1373+ let storage_key = felt ! ( "0x0" ) ;
1374+
1375+ // Address 0x1 should not return ContractNotFound
1376+ let result =
1377+ provider. get_storage_at ( felt ! ( "0x1" ) . into ( ) , storage_key, BlockIdOrTag :: PreConfirmed ) . await ;
1378+ assert ! ( result. is_ok( ) , "get_storage_at for address 0x1 should not fail" ) ;
1379+
1380+ // Address 0x2 should not return ContractNotFound
1381+ let result =
1382+ provider. get_storage_at ( felt ! ( "0x2" ) . into ( ) , storage_key, BlockIdOrTag :: PreConfirmed ) . await ;
1383+ assert ! ( result. is_ok( ) , "get_storage_at for address 0x2 should not fail" ) ;
1384+ }
0 commit comments