1- use std:: time:: Duration ;
21use crate :: router:: { Channel , Price , PriceFeedId , Rate , TimestampUs } ;
3- use serde:: { Deserialize , Serialize } ;
42use crate :: symbol_state:: SymbolState ;
3+ use serde:: { Deserialize , Serialize } ;
4+ use std:: time:: Duration ;
55
66#[ derive( Serialize , Deserialize , Debug , Eq , PartialEq ) ]
77pub struct PythLazerAgentJrpcV1 {
@@ -91,6 +91,7 @@ pub enum JrpcError {
9191 InternalError ,
9292}
9393
94+ // note: error codes can be found in the rfc https://www.jsonrpc.org/specification#error_object
9495impl From < JrpcError > for JrpcErrorObject {
9596 fn from ( error : JrpcError ) -> Self {
9697 match error {
@@ -128,9 +129,8 @@ pub struct SymbolMetadata {
128129
129130#[ cfg( test) ]
130131mod tests {
132+ use super :: * ;
131133 use crate :: jrpc:: JrpcCall :: { GetMetadata , PushUpdate } ;
132- use crate :: jrpc:: { FeedUpdateParams , Filter , GetMetadataParams , JrpcErrorObject , JrpcErrorResponse , JrpcSuccessResponse , JsonRpcVersion , PythLazerAgentJrpcV1 , UpdateParams } ;
133- use crate :: router:: { Price , PriceFeedId , Rate , TimestampUs } ;
134134
135135 #[ test]
136136 fn test_push_update_price ( ) {
@@ -218,8 +218,8 @@ mod tests {
218218 "jsonrpc": "2.0",
219219 "method": "get_metadata",
220220 "params": {
221- "names": ["BTC/USD"],
222- "asset_types": ["crypto"]
221+ "names": ["BTC/USD"],
222+ "asset_types": ["crypto"]
223223 },
224224 "id": 1
225225 }
@@ -253,7 +253,10 @@ mod tests {
253253
254254 let expected = PythLazerAgentJrpcV1 {
255255 jsonrpc : JsonRpcVersion :: V2 ,
256- params : GetMetadata ( GetMetadataParams { names : None , asset_types : None } ) ,
256+ params : GetMetadata ( GetMetadataParams {
257+ names : None ,
258+ asset_types : None ,
259+ } ) ,
257260 id : 1 ,
258261 } ;
259262
@@ -275,18 +278,22 @@ mod tests {
275278 "code": -32603
276279 }
277280 }
278- "#
279- ) . unwrap ( ) ;
281+ "# ,
282+ )
283+ . unwrap ( ) ;
280284
281- assert_eq ! ( response, JrpcErrorResponse {
282- jsonrpc: JsonRpcVersion :: V2 ,
283- error: JrpcErrorObject {
284- code: -32603 ,
285- message: "Internal error" . to_string( ) ,
286- data: None ,
287- } ,
288- id: Some ( 2 ) ,
289- } ) ;
285+ assert_eq ! (
286+ response,
287+ JrpcErrorResponse {
288+ jsonrpc: JsonRpcVersion :: V2 ,
289+ error: JrpcErrorObject {
290+ code: -32603 ,
291+ message: "Internal error" . to_string( ) ,
292+ data: None ,
293+ } ,
294+ id: Some ( 2 ) ,
295+ }
296+ ) ;
290297 }
291298
292299 #[ test]
@@ -298,13 +305,17 @@ mod tests {
298305 "id": 2,
299306 "result": "success"
300307 }
301- "#
302- ) . unwrap ( ) ;
308+ "# ,
309+ )
310+ . unwrap ( ) ;
303311
304- assert_eq ! ( response, JrpcSuccessResponse :: <String > {
305- jsonrpc: JsonRpcVersion :: V2 ,
306- result: "success" . to_string( ) ,
307- id: 2 ,
308- } ) ;
312+ assert_eq ! (
313+ response,
314+ JrpcSuccessResponse :: <String > {
315+ jsonrpc: JsonRpcVersion :: V2 ,
316+ result: "success" . to_string( ) ,
317+ id: 2 ,
318+ }
319+ ) ;
309320 }
310321}
0 commit comments