1
1
use serde_json:: json;
2
- use starknet_rs_core:: types:: BlockId ;
2
+ use starknet_rs_core:: types:: ConfirmedBlockId ;
3
+ use starknet_rs_providers:: Provider ;
4
+ use starknet_rs_providers:: jsonrpc:: JsonRpcError ;
3
5
4
6
use crate :: common:: background_devnet:: BackgroundDevnet ;
5
7
use crate :: common:: constants:: RPC_PATH ;
6
8
use crate :: common:: errors:: RpcError ;
7
9
use crate :: common:: reqwest_client:: PostReqwestSender ;
10
+ use crate :: common:: utils:: { assert_json_rpc_errors_equal, extract_json_rpc_error} ;
8
11
9
12
#[ tokio:: test]
10
13
async fn rpc_at_root ( ) {
@@ -55,13 +58,14 @@ async fn rpc_returns_invalid_params() {
55
58
#[ tokio:: test]
56
59
async fn storage_proof_request_should_always_return_error ( ) {
57
60
let devnet = BackgroundDevnet :: spawn ( ) . await . unwrap ( ) ;
58
- devnet. create_block ( ) . await . unwrap ( ) ;
61
+
62
+ let devnet_storage_proof_msg = "Devnet doesn't support storage proofs" ;
59
63
60
64
for ( req_params, expected_code, expected_msg) in [
61
65
( json ! ( { } ) , -32602 , "missing field `block_id`" ) ,
62
- ( json ! ( { "block_id" : BlockId :: Number ( 0 ) } ) , 42 , "Devnet doesn't support storage proofs" ) ,
63
- ( json ! ( { "block_id" : "latest" } ) , 42 , "Devnet doesn't support storage proofs" ) ,
64
- ( json ! ( { "block_id" : BlockId :: Number ( 5 ) } ) , 24 , "Block not found" ) ,
66
+ ( json ! ( { "block_id" : ConfirmedBlockId :: Number ( 0 ) } ) , 42 , devnet_storage_proof_msg ) ,
67
+ ( json ! ( { "block_id" : "latest" } ) , 42 , devnet_storage_proof_msg ) ,
68
+ ( json ! ( { "block_id" : ConfirmedBlockId :: Number ( 5 ) } ) , 24 , "Block not found" ) ,
65
69
] {
66
70
let error =
67
71
devnet. send_custom_rpc ( "starknet_getStorageProof" , req_params) . await . unwrap_err ( ) ;
@@ -70,4 +74,15 @@ async fn storage_proof_request_should_always_return_error() {
70
74
RpcError { code: expected_code. into( ) , message: expected_msg. into( ) , data: None }
71
75
) ;
72
76
}
77
+
78
+ // Test with starknet-rs
79
+ match devnet. json_rpc_client . get_storage_proof ( ConfirmedBlockId :: Latest , [ ] , [ ] , [ ] ) . await {
80
+ // Replace when this is accepted: https://github.com/xJonathanLEI/starknet-rs/pull/714
81
+ // Err(ProviderError::StarknetError(StarknetError::StorageProofNotSupported)) => (),
82
+ Err ( e) => assert_json_rpc_errors_equal (
83
+ extract_json_rpc_error ( e) . unwrap ( ) ,
84
+ JsonRpcError { code : 42 , message : devnet_storage_proof_msg. into ( ) , data : None } ,
85
+ ) ,
86
+ other => panic ! ( "Unexpected result: {other:?}" ) ,
87
+ }
73
88
}
0 commit comments