Skip to content

Commit 478004d

Browse files
committed
fix tests
1 parent 1116639 commit 478004d

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lazer/sdk/rust/protocol/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ itertools = "0.13.0"
1616
rust_decimal = "1.36.0"
1717
protobuf = "3.7.2"
1818
humantime-serde = "1.1.1"
19+
jsonrpc-types = "0.3.3"
1920

2021
[dev-dependencies]
2122
bincode = "1.3.3"

lazer/sdk/rust/protocol/src/jrpc.rs

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ pub struct PythLazerAgentJrpcV1 {
1313

1414
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
1515
#[serde(tag = "method", content = "params")]
16+
#[serde(rename_all = "snake_case")]
1617
pub enum JrpcCall {
17-
#[serde(rename_all = "snake_case")]
1818
PushUpdate(FeedUpdateParams),
19-
#[serde(rename = "get_symbols")]
2019
GetMetadata(GetMetadataParams),
2120
}
2221

@@ -134,11 +133,11 @@ mod tests {
134133
use crate::router::{Price, PriceFeedId, Rate, TimestampUs};
135134

136135
#[test]
137-
fn test_send_updates_price() {
136+
fn test_push_update_price() {
138137
let json = r#"
139138
{
140139
"jsonrpc": "2.0",
141-
"method": "send_updates",
140+
"method": "push_update",
142141
"params": {
143142
"feed_id": 1,
144143
"source_timestamp": 124214124124,
@@ -156,7 +155,7 @@ mod tests {
156155

157156
let expected = PythLazerAgentJrpcV1 {
158157
jsonrpc: JsonRpcVersion::V2,
159-
params: SendUpdates(FeedUpdateParams {
158+
params: PushUpdate(FeedUpdateParams {
160159
feed_id: PriceFeedId(1),
161160
source_timestamp: TimestampUs(124214124124),
162161
update: UpdateParams::PriceUpdate {
@@ -175,11 +174,11 @@ mod tests {
175174
}
176175

177176
#[test]
178-
fn test_send_updates_funding_rate() {
177+
fn test_push_update_funding_rate() {
179178
let json = r#"
180179
{
181180
"jsonrpc": "2.0",
182-
"method": "send_updates",
181+
"method": "push_update",
183182
"params": {
184183
"feed_id": 1,
185184
"source_timestamp": 124214124124,
@@ -196,7 +195,7 @@ mod tests {
196195

197196
let expected = PythLazerAgentJrpcV1 {
198197
jsonrpc: JsonRpcVersion::V2,
199-
params: SendUpdates(FeedUpdateParams {
198+
params: PushUpdate(FeedUpdateParams {
200199
feed_id: PriceFeedId(1),
201200
source_timestamp: TimestampUs(124214124124),
202201
update: UpdateParams::FundingRateUpdate {
@@ -213,16 +212,14 @@ mod tests {
213212
);
214213
}
215214
#[test]
216-
fn test_send_get_symbols() {
215+
fn test_send_get_metadata() {
217216
let json = r#"
218217
{
219218
"jsonrpc": "2.0",
220-
"method": "get_symbols",
219+
"method": "get_metadata",
221220
"params": {
222-
"filters": [
223-
{"name": "BTC/USD"},
224-
{"asset_type": "crypto"}
225-
]
221+
"names": ["BTC/USD"],
222+
"asset_types": ["crypto"]
226223
},
227224
"id": 1
228225
}
@@ -231,16 +228,8 @@ mod tests {
231228
let expected = PythLazerAgentJrpcV1 {
232229
jsonrpc: JsonRpcVersion::V2,
233230
params: GetMetadata(GetMetadataParams {
234-
filters: Some(vec![
235-
Filter {
236-
name: Some("BTC/USD".to_string()),
237-
asset_type: None,
238-
},
239-
Filter {
240-
name: None,
241-
asset_type: Some("crypto".to_string()),
242-
},
243-
]),
231+
names: Some(vec!["BTC/USD".to_string()]),
232+
asset_types: Some(vec!["crypto".to_string()]),
244233
}),
245234
id: 1,
246235
};
@@ -252,19 +241,19 @@ mod tests {
252241
}
253242

254243
#[test]
255-
fn test_get_symbols_without_filters() {
244+
fn test_get_metadata_without_filters() {
256245
let json = r#"
257246
{
258247
"jsonrpc": "2.0",
259-
"method": "get_symbols",
248+
"method": "get_metadata",
260249
"params": {},
261250
"id": 1
262251
}
263252
"#;
264253

265254
let expected = PythLazerAgentJrpcV1 {
266255
jsonrpc: JsonRpcVersion::V2,
267-
params: GetMetadata(GetMetadataParams { filters: None }),
256+
params: GetMetadata(GetMetadataParams { names: None, asset_types: None }),
268257
id: 1,
269258
};
270259

0 commit comments

Comments
 (0)