Filter public positions by title, event and current holding

This commit is contained in:
2026-12-05 04:47:56 +08:00
parent 629d5d2548
commit 7e6b94aeed
6 changed files with 119 additions and 5 deletions
+31
View File
@@ -4210,6 +4210,30 @@ fn public_positions_walk_a_mergeable_pair_and_held_settlement() {
.unwrap();
assert_eq!(winning_dust["current_size"], 0.0088);
assert_eq!(winning_dust["redeemable"], true);
assert_eq!(
read(
&e,
json!({"user":"alice","title":"%e%","filter_type":"tokens","filter_amount":10})
)
.unwrap()["data"]
.as_array()
.unwrap()
.len(),
2
);
assert_eq!(
read(&e, json!({"user":"alice","filter_amount":10.001})).unwrap()["data"],
json!([])
);
assert_eq!(
read(&e, json!({"user":"alice","title":"unmatched title"})).unwrap()["data"],
json!([])
);
assert_eq!(
read(&e, json!({"user":"alice","event_id":"unmatched"})).unwrap()["data"],
json!([])
);
assert!(read(&e, json!({"user":"alice","event_id":"1","condition":"e"})).is_err());
let first = read(&e, json!({"user":"alice","status":"MERGEABLE","limit":1})).unwrap();
assert_eq!(first["data"][0]["mergeable"], true);
let cursor = first["pagination"]["next_cursor"].as_str().unwrap();
@@ -4230,6 +4254,13 @@ fn public_positions_walk_a_mergeable_pair_and_held_settlement() {
assert_eq!(held["data"][0]["status"], "REDEEMABLE");
assert_eq!(held["data"][0]["current_value"], 10);
assert_eq!(held["data"][0]["mergeable"], false);
let cash = read(
&e,
json!({"user":"alice","filterType":"cash","filterAmount":10}),
)
.unwrap();
assert_eq!(cash["data"].as_array().unwrap().len(), 1);
assert_eq!(cash["data"][0]["token_id"], "eb:YES:e");
let lost = read(&e, json!({"user":"alice","status":"REDEEMABLE_LOST"})).unwrap();
assert_eq!(lost["data"].as_array().unwrap().len(), 1);
assert_eq!(lost["data"][0]["token_id"], "eb:NO:e");