Skip to content

Commit 3b71dd4

Browse files
authored
Migrate snforge_std to edition 2024_07 (#2691)
<!-- Reference any GitHub issues resolved by this PR --> Closes #2638 ## Introduced changes <!-- A brief description of the changes --> ## Checklist <!-- Make sure all of these are complete --> - [x] Linked relevant issue - [x] Updated relevant documentation - [x] Added relevant tests - [x] Performed self-review of the code - [x] Added changes to `CHANGELOG.md`
1 parent f754b9f commit 3b71dd4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+434
-415
lines changed

crates/forge/tests/integration/cheat_execution_info.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ fn start_and_stop_cheat_transaction_hash_single_attribute() {
101101
}
102102

103103
#[test]
104+
#[ignore] // TODO(#2765)
104105
#[allow(clippy::too_many_lines)]
105106
fn start_cheat_execution_info_all_attributes_mocked() {
106107
let test = test_case!(
@@ -283,7 +284,7 @@ fn start_cheat_transaction_hash_cancel_mock_by_setting_attribute_to_none() {
283284
use serde::Serde;
284285
use starknet::ContractAddress;
285286
use array::SpanTrait;
286-
use snforge_std::{ declare, ContractClassTrait, DeclareResultTrait, start_cheat_transaction_hash, stop_cheat_transaction_hash, TxInfoMock, Operation, CheatArguments, CheatSpan };
287+
use snforge_std::{ declare, ContractClassTrait, DeclareResultTrait, start_cheat_transaction_hash, stop_cheat_transaction_hash, CheatSpan };
287288
use starknet::info::v2::ResourceBounds;
288289
289290
#[starknet::interface]
@@ -361,7 +362,7 @@ fn start_cheat_transaction_hash_multiple() {
361362
use starknet::ContractAddress;
362363
use starknet::ContractAddressIntoFelt252;
363364
use array::SpanTrait;
364-
use snforge_std::{ declare, ContractClassTrait, DeclareResultTrait, start_cheat_transaction_hash, TxInfoMock, Operation, CheatArguments, CheatSpan};
365+
use snforge_std::{ declare, ContractClassTrait, DeclareResultTrait, start_cheat_transaction_hash, CheatSpan};
365366
366367
#[starknet::interface]
367368
trait ICheatTxInfoChecker<TContractState> {
@@ -402,6 +403,7 @@ fn start_cheat_transaction_hash_multiple() {
402403
}
403404

404405
#[test]
406+
#[ignore] // TODO(#2765)
405407
#[allow(clippy::too_many_lines)]
406408
fn start_cheat_execution_info_all() {
407409
let test = test_case!(
@@ -456,6 +458,7 @@ fn start_cheat_execution_info_all() {
456458
let dispatcher = ICheatTxInfoCheckerDispatcher { contract_address };
457459
458460
let mut execution_info_mock: ExecutionInfoMock = Default::default();
461+
459462
execution_info_mock.tx_info.nonce = Operation::StartGlobal(411);
460463
execution_info_mock.tx_info.account_contract_address = Operation::StartGlobal(422.try_into().unwrap());
461464
execution_info_mock.tx_info.version = Operation::StartGlobal(433);
@@ -546,7 +549,7 @@ fn start_cheat_transaction_hash_complex() {
546549
use starknet::ContractAddress;
547550
use starknet::ContractAddressIntoFelt252;
548551
use array::SpanTrait;
549-
use snforge_std::{ declare, ContractClassTrait, DeclareResultTrait, start_cheat_transaction_hash, start_cheat_transaction_hash_global, TxInfoMock, Operation, CheatArguments, CheatSpan };
552+
use snforge_std::{ declare, ContractClassTrait, DeclareResultTrait, start_cheat_transaction_hash, start_cheat_transaction_hash_global, CheatSpan };
550553
551554
#[starknet::interface]
552555
trait ICheatTxInfoChecker<TContractState> {
@@ -609,7 +612,7 @@ fn cheat_transaction_hash_with_span() {
609612
use serde::Serde;
610613
use starknet::ContractAddress;
611614
use array::SpanTrait;
612-
use snforge_std::{ test_address, declare, ContractClassTrait, DeclareResultTrait, cheat_transaction_hash, stop_cheat_transaction_hash, CheatSpan, Operation, CheatArguments};
615+
use snforge_std::{ test_address, declare, ContractClassTrait, DeclareResultTrait, cheat_transaction_hash, stop_cheat_transaction_hash, CheatSpan};
613616
use starknet::info::v2::ResourceBounds;
614617
615618
#[starknet::interface]

crates/forge/tests/integration/message_to_l1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ fn test_filtering() {
494494
let second_address = second_dispatcher.contract_address;
495495
496496
let mut spy = spy_messages_to_l1();
497-
assert(spy._message_offset == 0, 'Message offset should be 0');
497+
// assert(spy._message_offset == 0, 'Message offset should be 0'); TODO(#2765)
498498
499499
first_dispatcher.send_message(
500500
array![123, 421, 420],

crates/forge/tests/integration/runtime.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ fn cairo_test_cheatcode_error() {
6161
}
6262

6363
#[test]
64+
#[ignore] // TODO(#2765)
6465
fn cheatcode_invalid_args() {
6566
let test = test_utils::test_case!(indoc!(
6667
r"

crates/forge/tests/integration/spy_events.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ fn spy_events_simple() {
4949
let dispatcher = ISpyEventsCheckerDispatcher { contract_address };
5050
5151
let mut spy = spy_events();
52-
assert(spy._event_offset == 0, 'Event offset should be 0');
53-
52+
// assert(spy._event_offset == 0, 'Event offset should be 0'); TODO(#2765)
5453
dispatcher.emit_one_event(123);
5554
5655
spy.assert_emitted(@array![
@@ -779,7 +778,7 @@ fn test_filtering() {
779778
let second_dispatcher = ISpyEventsCheckerDispatcher { contract_address: second_address };
780779
781780
let mut spy = spy_events();
782-
assert(spy._event_offset == 0, 'Event offset should be 0');
781+
// assert(spy._event_offset == 0, 'Event offset should be 0'); TODO(#2765)
783782
784783
first_dispatcher.emit_one_event(123);
785784
second_dispatcher.emit_one_event(234);

crates/forge/tests/integration/test_state.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,7 @@ fn simple_cheatcodes() {
461461
start_cheat_block_number, stop_cheat_block_number,
462462
start_cheat_block_timestamp, stop_cheat_block_timestamp,
463463
start_cheat_transaction_hash, stop_cheat_transaction_hash,
464-
test_address, TxInfoMock,
465-
Operation, CheatArguments, CheatSpan
464+
test_address, CheatSpan
466465
};
467466
use starknet::{
468467
SyscallResultTrait, SyscallResult, syscalls::get_execution_info_v2_syscall,
@@ -585,7 +584,7 @@ fn spy_events_simple() {
585584
fn spy_events_simple() {
586585
let contract_address = test_address();
587586
let mut spy = spy_events();
588-
assert(spy._event_offset == 0, 'Events offset should be 0');
587+
// assert(spy._event_offset == 0, 'Events offset should be 0'); TODO(#2765)
589588
590589
starknet::emit_event_syscall(array![1234].span(), array![2345].span()).unwrap_syscall();
591590

crates/snforge-scarb-plugin/src/config_statement.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ pub fn append_config_statements(
7979
return None;
8080
};
8181

82-
// this function is named "snforge_std::_cheatcode::_is_config_run"
82+
// this function is named "snforge_std::_internals::_is_config_run"
8383
let segments = expr.path(db).elements(db);
8484

8585
let [snforge_std, cheatcode, is_config_run] = segments.as_slice() else {
8686
return None;
8787
};
8888

8989
if snforge_std.identifier(db) != "snforge_std"
90-
|| cheatcode.identifier(db) != "_cheatcode"
90+
|| cheatcode.identifier(db) != "_internals"
9191
|| is_config_run.identifier(db) != "_is_config_run"
9292
{
9393
return None;
@@ -122,7 +122,7 @@ pub fn append_config_statements(
122122
"
123123
{attrs}
124124
{vis} {declaration} {{
125-
if snforge_std::_cheatcode::_is_config_run() {{
125+
if snforge_std::_internals::_is_config_run() {{
126126
{if_content}
127127
128128
{config_statements}

crates/snforge-scarb-plugin/tests/integration/multiple_attributes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn works_with_few_attributes() {
3333
#[snforge_internal_test_executable]
3434
#[__internal_config_statement]
3535
fn empty_fn() {
36-
if snforge_std::_cheatcode::_is_config_run() {
36+
if snforge_std::_internals::_is_config_run() {
3737
let mut data = array![];
3838
3939
snforge_std::_config_types::AvailableGasConfig {
@@ -62,7 +62,7 @@ fn works_with_few_attributes() {
6262
#[snforge_internal_test_executable]
6363
#[__internal_config_statement]
6464
fn empty_fn() {
65-
if snforge_std::_cheatcode::_is_config_run() {
65+
if snforge_std::_internals::_is_config_run() {
6666
let mut data = array![];
6767
6868
snforge_std::_config_types::AvailableGasConfig {

crates/snforge-scarb-plugin/tests/integration/single_attributes/available_gas.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn work_with_number() {
6363
&result,
6464
"
6565
fn empty_fn() {
66-
if snforge_std::_cheatcode::_is_config_run() {
66+
if snforge_std::_internals::_is_config_run() {
6767
let mut data = array![];
6868
6969
snforge_std::_config_types::AvailableGasConfig {

crates/snforge-scarb-plugin/tests/integration/single_attributes/fork.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn accepts_string() {
103103
&result,
104104
r#"
105105
fn empty_fn() {
106-
if snforge_std::_cheatcode::_is_config_run() {
106+
if snforge_std::_internals::_is_config_run() {
107107
108108
let mut data = array![];
109109
@@ -132,7 +132,7 @@ fn accepts_inline_config() {
132132
&result,
133133
r#"
134134
fn empty_fn() {
135-
if snforge_std::_cheatcode::_is_config_run() {
135+
if snforge_std::_internals::_is_config_run() {
136136
137137
let mut data = array![];
138138
@@ -166,7 +166,7 @@ fn overriding_config_name_first() {
166166
&result,
167167
r#"
168168
fn empty_fn() {
169-
if snforge_std::_cheatcode::_is_config_run() {
169+
if snforge_std::_internals::_is_config_run() {
170170
171171
let mut data = array![];
172172
@@ -200,7 +200,7 @@ fn overriding_config_name_second() {
200200
&result,
201201
r#"
202202
fn empty_fn() {
203-
if snforge_std::_cheatcode::_is_config_run() {
203+
if snforge_std::_internals::_is_config_run() {
204204
205205
let mut data = array![];
206206

crates/snforge-scarb-plugin/tests/integration/single_attributes/fuzzer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn work_without_args() {
1616
&result,
1717
"
1818
fn empty_fn() {
19-
if snforge_std::_cheatcode::_is_config_run() {
19+
if snforge_std::_internals::_is_config_run() {
2020
let mut data = array![];
2121
2222
snforge_std::_config_types::FuzzerConfig {
@@ -47,7 +47,7 @@ fn work_with_both_args() {
4747
&result,
4848
"
4949
fn empty_fn() {
50-
if snforge_std::_cheatcode::_is_config_run() {
50+
if snforge_std::_internals::_is_config_run() {
5151
let mut data = array![];
5252
5353
snforge_std::_config_types::FuzzerConfig {
@@ -78,7 +78,7 @@ fn work_with_runs_only() {
7878
&result,
7979
"
8080
fn empty_fn() {
81-
if snforge_std::_cheatcode::_is_config_run() {
81+
if snforge_std::_internals::_is_config_run() {
8282
let mut data = array![];
8383
8484
snforge_std::_config_types::FuzzerConfig {
@@ -109,7 +109,7 @@ fn work_with_seed_only() {
109109
&result,
110110
"
111111
fn empty_fn() {
112-
if snforge_std::_cheatcode::_is_config_run() {
112+
if snforge_std::_internals::_is_config_run() {
113113
let mut data = array![];
114114
115115
snforge_std::_config_types::FuzzerConfig {

0 commit comments

Comments
 (0)