@@ -5,7 +5,8 @@ use starknet_core::constants::DEVNET_DEFAULT_GAS_PRICE;
5
5
use starknet_rs_accounts:: { Account , AccountError , ExecutionEncoding , SingleOwnerAccount } ;
6
6
use starknet_rs_core:: chain_id:: SEPOLIA ;
7
7
use starknet_rs_core:: types:: { Felt , ResourcePrice , StarknetError } ;
8
- use starknet_rs_providers:: ProviderError ;
8
+ use starknet_rs_core:: utils:: cairo_short_string_to_felt;
9
+ use starknet_rs_providers:: { Provider , ProviderError } ;
9
10
use starknet_rs_signers:: Signer ;
10
11
11
12
use crate :: common:: background_devnet:: BackgroundDevnet ;
@@ -47,14 +48,15 @@ impl SetGasPrice for BackgroundDevnet {
47
48
/// 1. Execute simulateTransactions with a declare transaction and check gas fees.
48
49
/// 2. Set the gas values.
49
50
/// 3. Execute simulateTransactions again and check gas fees.
50
- async fn set_gas_scenario ( devnet : BackgroundDevnet , expected_chain_id : & str ) {
51
+ /// Chain ID assertion justified in: https://github.com/0xSpaceShard/starknet-devnet-rs/pull/551#discussion_r1682755696
52
+ async fn set_gas_scenario ( devnet : BackgroundDevnet , expected_chain_id : Felt ) {
51
53
// get account
52
54
let ( signer, account_address) = devnet. get_first_predeployed_account ( ) . await ;
53
55
let account = SingleOwnerAccount :: new (
54
56
devnet. clone_provider ( ) ,
55
57
signer. clone ( ) ,
56
58
account_address,
57
- Felt :: from_hex_unchecked ( expected_chain_id) ,
59
+ expected_chain_id,
58
60
ExecutionEncoding :: New ,
59
61
) ;
60
62
@@ -93,7 +95,7 @@ async fn set_gas_scenario(devnet: BackgroundDevnet, expected_chain_id: &str) {
93
95
} )
94
96
} ;
95
97
96
- let chain_id = & devnet. send_custom_rpc ( "starknet_chainId" , json ! ( { } ) ) . await . unwrap ( ) ;
98
+ let chain_id = devnet. json_rpc_client . chain_id ( ) . await . unwrap ( ) ;
97
99
assert_eq ! ( chain_id, expected_chain_id) ;
98
100
99
101
let params_skip_fee_charge = get_params ( & [ "SKIP_FEE_CHARGE" ] ) ;
@@ -109,7 +111,7 @@ async fn set_gas_scenario(devnet: BackgroundDevnet, expected_chain_id: &str) {
109
111
resp_no_flags[ "fee_estimation" ] [ "data_gas_price" ] ,
110
112
to_hex_felt( & DEVNET_DEFAULT_GAS_PRICE )
111
113
) ;
112
- assert_eq ! ( resp_no_flags[ "fee_estimation" ] [ "overall_fee" ] , "0x7398c659d800 " ) ;
114
+ assert_eq ! ( resp_no_flags[ "fee_estimation" ] [ "overall_fee" ] , "0xa7275ca6d3000 " ) ;
113
115
114
116
let params_skip_validation_and_fee_charge = get_params ( & [ "SKIP_VALIDATE" , "SKIP_FEE_CHARGE" ] ) ;
115
117
let resp_skip_validation = & devnet
@@ -127,7 +129,7 @@ async fn set_gas_scenario(devnet: BackgroundDevnet, expected_chain_id: &str) {
127
129
resp_skip_validation[ "fee_estimation" ] [ "data_gas_price" ] ,
128
130
to_hex_felt( & DEVNET_DEFAULT_GAS_PRICE )
129
131
) ;
130
- assert_eq ! ( resp_skip_validation[ "fee_estimation" ] [ "overall_fee" ] , "0x736a356c0800 " ) ;
132
+ assert_eq ! ( resp_skip_validation[ "fee_estimation" ] [ "overall_fee" ] , "0xa7247397f6000 " ) ;
131
133
132
134
assert_difference_if_validation (
133
135
resp_no_flags,
@@ -148,7 +150,7 @@ async fn set_gas_scenario(devnet: BackgroundDevnet, expected_chain_id: &str) {
148
150
149
151
assert_eq ! ( gas_response, & gas_request) ;
150
152
151
- let chain_id = & devnet. send_custom_rpc ( "starknet_chainId" , json ! ( { } ) ) . await . unwrap ( ) ;
153
+ let chain_id = devnet. json_rpc_client . chain_id ( ) . await . unwrap ( ) ;
152
154
assert_eq ! ( chain_id, expected_chain_id) ;
153
155
154
156
let resp_no_flags = & devnet
@@ -158,7 +160,7 @@ async fn set_gas_scenario(devnet: BackgroundDevnet, expected_chain_id: &str) {
158
160
159
161
assert_eq ! ( resp_no_flags[ "fee_estimation" ] [ "gas_price" ] , to_hex_felt( & wei_price) ) ;
160
162
assert_eq ! ( resp_no_flags[ "fee_estimation" ] [ "data_gas_price" ] , to_hex_felt( & wei_price_data) ) ;
161
- assert_eq ! ( resp_no_flags[ "fee_estimation" ] [ "overall_fee" ] , "0x261b37abed7125c0000 " ) ;
163
+ assert_eq ! ( resp_no_flags[ "fee_estimation" ] [ "overall_fee" ] , "0x38008384ec45ab780000 " ) ;
162
164
163
165
let resp_skip_validation = & devnet
164
166
. send_custom_rpc ( "starknet_simulateTransactions" , params_skip_validation_and_fee_charge)
@@ -169,7 +171,7 @@ async fn set_gas_scenario(devnet: BackgroundDevnet, expected_chain_id: &str) {
169
171
resp_skip_validation[ "fee_estimation" ] [ "data_gas_price" ] ,
170
172
to_hex_felt( & wei_price_data)
171
173
) ;
172
- assert_eq ! ( resp_skip_validation[ "fee_estimation" ] [ "overall_fee" ] , "0x260b9ade6354d540000 " ) ;
174
+ assert_eq ! ( resp_skip_validation[ "fee_estimation" ] [ "overall_fee" ] , "0x37ff89b813a3e6700000 " ) ;
173
175
174
176
assert_difference_if_validation (
175
177
resp_no_flags,
@@ -184,7 +186,7 @@ async fn set_gas() {
184
186
let devnet = BackgroundDevnet :: spawn ( ) . await . expect ( "Could not start Devnet" ) ;
185
187
186
188
// Testnet gas modification test scenario
187
- set_gas_scenario ( devnet, & SEPOLIA . to_hex_string ( ) ) . await ;
189
+ set_gas_scenario ( devnet, SEPOLIA ) . await ;
188
190
}
189
191
190
192
#[ tokio:: test]
@@ -194,7 +196,8 @@ async fn set_gas_fork() {
194
196
let fork_devnet = BackgroundDevnet :: spawn_with_additional_args ( & cli_args) . await . unwrap ( ) ;
195
197
196
198
// Sepolia fork gas modification test scenario
197
- set_gas_scenario ( fork_devnet, "0x534e5f494e544547524154494f4e5f5345504f4c4941" ) . await ;
199
+ set_gas_scenario ( fork_devnet, cairo_short_string_to_felt ( "SN_INTEGRATION_SEPOLIA" ) . unwrap ( ) )
200
+ . await ;
198
201
}
199
202
200
203
#[ tokio:: test]
0 commit comments