Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 180dc4d

Browse files
authored
Rename test artifact getters (starknet-io#783)
* [skip ci]
1 parent d9520e2 commit 180dc4d

23 files changed

Lines changed: 75 additions & 103 deletions

tests/integration/common/utils.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,33 +69,33 @@ pub fn get_flattened_sierra_contract_and_casm_hash(sierra_path: &str) -> SierraW
6969
(sierra_class.flatten().unwrap(), casm_hash)
7070
}
7171

72-
pub fn get_messaging_contract_in_sierra_and_compiled_class_hash() -> SierraWithCasmHash {
72+
pub fn get_messaging_contract_artifacts() -> SierraWithCasmHash {
7373
let sierra_path = "../../contracts/l1-l2-artifacts/cairo_l1_l2.contract_class.sierra";
7474
get_flattened_sierra_contract_and_casm_hash(sierra_path)
7575
}
7676

77-
pub fn get_messaging_lib_in_sierra_and_compiled_class_hash() -> SierraWithCasmHash {
77+
pub fn get_messaging_lib_artifacts() -> SierraWithCasmHash {
7878
let sierra_path = "../../contracts/l1-l2-artifacts/cairo_l1_l2_lib.contract_class.sierra";
7979
get_flattened_sierra_contract_and_casm_hash(sierra_path)
8080
}
8181

82-
pub fn get_events_contract_in_sierra_and_compiled_class_hash() -> SierraWithCasmHash {
82+
pub fn get_events_contract_artifacts() -> SierraWithCasmHash {
8383
let events_sierra_path =
8484
"../../contracts/test_artifacts/cairo1/events/events_2.0.1_compiler.sierra";
8585
get_flattened_sierra_contract_and_casm_hash(events_sierra_path)
8686
}
8787

88-
pub fn get_block_reader_contract_in_sierra_and_compiled_class_hash() -> SierraWithCasmHash {
88+
pub fn get_block_reader_contract_artifacts() -> SierraWithCasmHash {
8989
let timestamp_sierra_path =
9090
"../../contracts/test_artifacts/cairo1/block_reader/block_reader.sierra";
9191
get_flattened_sierra_contract_and_casm_hash(timestamp_sierra_path)
9292
}
9393

94-
pub fn get_simple_contract_in_sierra_and_compiled_class_hash() -> SierraWithCasmHash {
94+
pub fn get_simple_contract_artifacts() -> SierraWithCasmHash {
9595
get_flattened_sierra_contract_and_casm_hash(CAIRO_1_CONTRACT_PATH)
9696
}
9797

98-
pub fn get_timestamp_asserter() -> SierraWithCasmHash {
98+
pub fn get_timestamp_asserter_contract_artifacts() -> SierraWithCasmHash {
9999
get_flattened_sierra_contract_and_casm_hash(
100100
"../../contracts/test_artifacts/cairo1/timestamp_asserter/target/dev/\
101101
cairo_TimestampAsserter.contract_class.json",
@@ -302,7 +302,7 @@ pub async fn declare_v3_deploy_v3(
302302
pub async fn declare_deploy_simple_contract(
303303
account: &SingleOwnerAccount<&JsonRpcClient<HttpTransport>, LocalWallet>,
304304
) -> Result<(Felt, Felt), anyhow::Error> {
305-
let (contract_class, casm_hash) = get_simple_contract_in_sierra_and_compiled_class_hash();
305+
let (contract_class, casm_hash) = get_simple_contract_artifacts();
306306

307307
let declaration_result = account
308308
.declare_v3(Arc::new(contract_class), casm_hash)
@@ -339,7 +339,7 @@ pub async fn declare_deploy_simple_contract(
339339
pub async fn declare_deploy_events_contract(
340340
account: &SingleOwnerAccount<&JsonRpcClient<HttpTransport>, LocalWallet>,
341341
) -> Result<Felt, anyhow::Error> {
342-
let (contract_class, casm_hash) = get_events_contract_in_sierra_and_compiled_class_hash();
342+
let (contract_class, casm_hash) = get_events_contract_artifacts();
343343

344344
let declaration_result = account
345345
.declare_v3(Arc::new(contract_class), casm_hash)

tests/integration/get_transaction_by_hash.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ use crate::common::constants::{
1212
self, CAIRO_1_ACCOUNT_CONTRACT_SIERRA_HASH, ETH_ERC20_CONTRACT_ADDRESS,
1313
};
1414
use crate::common::utils::{
15-
assert_tx_successful, get_deployable_account_signer,
16-
get_simple_contract_in_sierra_and_compiled_class_hash,
15+
assert_tx_successful, get_deployable_account_signer, get_simple_contract_artifacts,
1716
};
1817

1918
#[tokio::test]
2019
async fn get_declare_v3_transaction_by_hash_happy_path() {
2120
let devnet = BackgroundDevnet::spawn().await.expect("Could not start Devnet");
2221

23-
let (contract_class, casm_hash) = get_simple_contract_in_sierra_and_compiled_class_hash();
22+
let (contract_class, casm_hash) = get_simple_contract_artifacts();
2423

2524
let (signer, address) = devnet.get_first_predeployed_account().await;
2625
let mut account = SingleOwnerAccount::new(

tests/integration/get_transaction_receipt_by_hash.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ use crate::common::background_devnet::BackgroundDevnet;
1414
use crate::common::constants::{
1515
self, CAIRO_0_ACCOUNT_CONTRACT_HASH, CHAIN_ID, ETH_ERC20_CONTRACT_ADDRESS,
1616
};
17-
use crate::common::utils::{
18-
get_deployable_account_signer, get_events_contract_in_sierra_and_compiled_class_hash,
19-
};
17+
use crate::common::utils::{get_deployable_account_signer, get_events_contract_artifacts};
2018

2119
#[tokio::test]
2220
async fn deploy_account_transaction_receipt() {
@@ -68,8 +66,7 @@ async fn deploy_transaction_receipt() {
6866
ExecutionEncoding::New,
6967
));
7068

71-
let (cairo_1_contract, casm_class_hash) =
72-
get_events_contract_in_sierra_and_compiled_class_hash();
69+
let (cairo_1_contract, casm_class_hash) = get_events_contract_artifacts();
7370

7471
// declare the contract
7572
let declaration_result = predeployed_account
@@ -122,8 +119,7 @@ async fn invalid_deploy_transaction_receipt() {
122119
ExecutionEncoding::New,
123120
));
124121

125-
let (cairo_1_contract, casm_class_hash) =
126-
get_events_contract_in_sierra_and_compiled_class_hash();
122+
let (cairo_1_contract, casm_class_hash) = get_events_contract_artifacts();
127123

128124
// declare the contract
129125
let declaration_result = predeployed_account

tests/integration/test_account_impersonation.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ use starknet_rs_signers::{LocalWallet, SigningKey};
1010
use crate::common::background_devnet::BackgroundDevnet;
1111
use crate::common::constants::STRK_ERC20_CONTRACT_ADDRESS;
1212
use crate::common::utils::{
13-
FeeUnit, ImpersonationAction, assert_contains,
14-
get_simple_contract_in_sierra_and_compiled_class_hash,
13+
FeeUnit, ImpersonationAction, assert_contains, get_simple_contract_artifacts,
1514
};
1615

1716
const IMPERSONATED_ACCOUNT_PRIVATE_KEY: Felt = Felt::ONE;
@@ -222,8 +221,7 @@ async fn test_declare_transaction(
222221
forked_devnet.execute_impersonation_action(action).await?;
223222
}
224223

225-
let (flattened_class, compiled_class_hash) =
226-
get_simple_contract_in_sierra_and_compiled_class_hash();
224+
let (flattened_class, compiled_class_hash) = get_simple_contract_artifacts();
227225

228226
account.set_block_id(BlockId::Tag(BlockTag::Latest));
229227

tests/integration/test_account_selection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::common::constants::{
1616
use crate::common::reqwest_client::GetReqwestSender;
1717
use crate::common::utils::{
1818
FeeUnit, assert_contains, assert_tx_successful, deploy_argent_account, deploy_oz_account,
19-
get_simple_contract_in_sierra_and_compiled_class_hash,
19+
get_simple_contract_artifacts,
2020
};
2121

2222
pub async fn get_predeployed_accounts(
@@ -160,7 +160,7 @@ async fn can_declare_deploy_invoke_cairo1_using_account(
160160
ExecutionEncoding::New,
161161
));
162162

163-
let (contract_class, casm_hash) = get_simple_contract_in_sierra_and_compiled_class_hash();
163+
let (contract_class, casm_hash) = get_simple_contract_artifacts();
164164

165165
// declare the contract
166166
let declaration_result = account

tests/integration/test_advancing_time.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use crate::common::background_devnet::BackgroundDevnet;
1515
use crate::common::constants;
1616
use crate::common::utils::{
1717
UniqueAutoDeletableFile, assert_contains, declare_v3_deploy_v3, extract_message_error,
18-
extract_nested_error, get_block_reader_contract_in_sierra_and_compiled_class_hash,
19-
get_timestamp_asserter, get_unix_timestamp_as_seconds, increase_time,
18+
extract_nested_error, get_block_reader_contract_artifacts,
19+
get_timestamp_asserter_contract_artifacts, get_unix_timestamp_as_seconds, increase_time,
2020
send_ctrl_c_signal_and_wait, set_time,
2121
};
2222

@@ -53,8 +53,7 @@ pub async fn setup_timestamp_contract(devnet: &BackgroundDevnet) -> Felt {
5353
);
5454

5555
// declare
56-
let (cairo_1_contract, casm_class_hash) =
57-
get_block_reader_contract_in_sierra_and_compiled_class_hash();
56+
let (cairo_1_contract, casm_class_hash) = get_block_reader_contract_artifacts();
5857
let declaration_result = predeployed_account
5958
.declare_v3(Arc::new(cairo_1_contract), casm_class_hash)
6059
.send()
@@ -572,7 +571,7 @@ async fn tx_resource_estimation_fails_unless_time_incremented() {
572571
ExecutionEncoding::New,
573572
);
574573

575-
let (contract_class, casm_hash) = get_timestamp_asserter();
574+
let (contract_class, casm_hash) = get_timestamp_asserter_contract_artifacts();
576575

577576
let lock_interval = 86_400;
578577
let ctor_args = &[Felt::from(lock_interval)];
@@ -625,7 +624,7 @@ async fn tx_execution_fails_unless_time_incremented() {
625624
ExecutionEncoding::New,
626625
);
627626

628-
let (contract_class, casm_hash) = get_timestamp_asserter();
627+
let (contract_class, casm_hash) = get_timestamp_asserter_contract_artifacts();
629628

630629
let lock_interval = 86_400;
631630
let ctor_args = &[Felt::from(lock_interval)];

tests/integration/test_advancing_time_on_fork.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::common::background_devnet::BackgroundDevnet;
1010
use crate::common::constants;
1111
use crate::common::utils::{
1212
ImpersonationAction, assert_contains, declare_v3_deploy_v3, extract_message_error,
13-
extract_nested_error, get_timestamp_asserter, increase_time,
13+
extract_nested_error, get_timestamp_asserter_contract_artifacts, increase_time,
1414
};
1515

1616
#[tokio::test]
@@ -27,7 +27,7 @@ async fn tx_resource_estimation_fails_on_forked_devnet_with_impersonation_unless
2727
ExecutionEncoding::New,
2828
);
2929

30-
let (contract_class, casm_hash) = get_timestamp_asserter();
30+
let (contract_class, casm_hash) = get_timestamp_asserter_contract_artifacts();
3131

3232
let lock_interval = 86_400;
3333
let ctor_args = &[Felt::from(lock_interval)];
@@ -98,7 +98,7 @@ async fn tx_execution_fails_on_forked_devnet_with_impersonation_unless_time_incr
9898
ExecutionEncoding::New,
9999
);
100100

101-
let (contract_class, casm_hash) = get_timestamp_asserter();
101+
let (contract_class, casm_hash) = get_timestamp_asserter_contract_artifacts();
102102

103103
let lock_interval = 86_400;
104104
let ctor_args = &[Felt::from(lock_interval)];

tests/integration/test_blocks_generation.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ use crate::common::background_devnet::BackgroundDevnet;
1818
use crate::common::constants::{self, CAIRO_1_ACCOUNT_CONTRACT_SIERRA_HASH};
1919
use crate::common::utils::{
2020
FeeUnit, UniqueAutoDeletableFile, assert_equal_elements, assert_tx_successful,
21-
get_contract_balance, get_contract_balance_by_block_id,
22-
get_events_contract_in_sierra_and_compiled_class_hash,
23-
get_simple_contract_in_sierra_and_compiled_class_hash, send_ctrl_c_signal_and_wait,
21+
get_contract_balance, get_contract_balance_by_block_id, get_events_contract_artifacts,
22+
get_simple_contract_artifacts, send_ctrl_c_signal_and_wait,
2423
};
2524

2625
static DUMMY_ADDRESS: u128 = 1;
@@ -293,10 +292,7 @@ async fn blocks_on_demand_declarations() {
293292
predeployed_account.set_block_id(BlockId::Tag(BlockTag::Pending));
294293

295294
// perform declarations
296-
let classes_with_hash = [
297-
get_simple_contract_in_sierra_and_compiled_class_hash(),
298-
get_events_contract_in_sierra_and_compiled_class_hash(),
299-
];
295+
let classes_with_hash = [get_simple_contract_artifacts(), get_events_contract_artifacts()];
300296

301297
let mut declaration_results = vec![];
302298
for (nonce, (class, casm_hash)) in classes_with_hash.iter().enumerate() {
@@ -376,7 +372,7 @@ async fn blocks_on_demand_invoke_and_call() {
376372
);
377373
predeployed_account.set_block_id(BlockId::Tag(BlockTag::Pending));
378374

379-
let (contract_class, casm_class_hash) = get_simple_contract_in_sierra_and_compiled_class_hash();
375+
let (contract_class, casm_class_hash) = get_simple_contract_artifacts();
380376

381377
// declare the contract
382378
let declaration_result = predeployed_account

tests/integration/test_deploy.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ use crate::common::constants::{
1313
self, CAIRO_1_ACCOUNT_CONTRACT_SIERRA_HASH, UDC_CONTRACT_ADDRESS, UDC_CONTRACT_CLASS_HASH,
1414
};
1515
use crate::common::utils::{
16-
assert_contains, extract_message_error, extract_nested_error,
17-
get_simple_contract_in_sierra_and_compiled_class_hash,
16+
assert_contains, extract_message_error, extract_nested_error, get_simple_contract_artifacts,
1817
};
1918

2019
#[tokio::test]
@@ -31,7 +30,7 @@ async fn double_deployment_not_allowed() {
3130
);
3231

3332
// declare
34-
let (contract_class, casm_hash) = get_simple_contract_in_sierra_and_compiled_class_hash();
33+
let (contract_class, casm_hash) = get_simple_contract_artifacts();
3534
let declaration_result = account
3635
.declare_v3(Arc::new(contract_class), casm_hash)
3736
.l1_gas(0)
@@ -95,7 +94,7 @@ async fn cannot_deploy_undeclared_class() {
9594
);
9695

9796
// skip declaration
98-
let (contract_class, _) = get_simple_contract_in_sierra_and_compiled_class_hash();
97+
let (contract_class, _) = get_simple_contract_artifacts();
9998

10099
// prepare deployment
101100
let contract_factory = ContractFactory::new(contract_class.class_hash(), account.clone());

tests/integration/test_dump_and_load.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use starknet_rs_accounts::{Account, ExecutionEncoding, SingleOwnerAccount};
1818
use starknet_rs_contract::ContractFactory;
1919
use starknet_rs_core::types::{DeclareTransaction, Felt, InvokeTransaction, Transaction};
2020

21-
use crate::common::utils::get_events_contract_in_sierra_and_compiled_class_hash;
21+
use crate::common::utils::get_events_contract_artifacts;
2222

2323
async fn dump_load_dump_load(mode: &str) {
2424
let dump_file =
@@ -239,8 +239,7 @@ async fn declare_deploy() {
239239
ExecutionEncoding::New,
240240
);
241241

242-
let (cairo_1_contract, casm_class_hash) =
243-
get_events_contract_in_sierra_and_compiled_class_hash();
242+
let (cairo_1_contract, casm_class_hash) = get_events_contract_artifacts();
244243

245244
// declare the contract
246245
let declaration_result = predeployed_account

0 commit comments

Comments
 (0)