Skip to content

Commit de21cf9

Browse files
committed
refine
1 parent 30a52ac commit de21cf9

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

lib/ain-ocean/src/api/block.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ struct BlockHash {
1414
}
1515

1616
#[derive(Deserialize)]
17-
struct ListBlocksRequest {
18-
size: usize,
19-
next: Option<String>
17+
pub struct ListBlocksRequest {
18+
pub size: usize,
19+
pub next: Option<String>
2020
}
2121

2222
#[debug_handler]

lib/ain-ocean/src/api_paged_response.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,20 @@ mod tests {
9292
sort: String,
9393
}
9494

95+
impl Item {
96+
fn new(id: &str, sort: &str) -> Self {
97+
Self {
98+
id: id.into(),
99+
sort: sort.into(),
100+
}
101+
}
102+
}
103+
95104
#[test]
96105
fn should_next_with_none() {
97106
let items: Vec<Item> = vec![
98-
Item{id: "1".into(), sort: "a".into()},
99-
Item{id: "2".into(), sort: "b".into()},
107+
Item::new("0", "a"),
108+
Item::new("1", "b"),
100109
];
101110

102111
let next = ApiPagedResponse::next(items, None).page.next;
@@ -106,8 +115,8 @@ mod tests {
106115
#[test]
107116
fn should_next_with_value() {
108117
let items: Vec<Item> = vec![
109-
Item{id: "1".into(), sort: "a".into()},
110-
Item{id: "2".into(), sort: "b".into()},
118+
Item::new("0", "a"),
119+
Item::new("1", "b"),
111120
];
112121

113122
let next = ApiPagedResponse::next(items, Some("b".into())).page.next;
@@ -117,9 +126,9 @@ mod tests {
117126
#[test]
118127
fn should_of_with_limit_3() {
119128
let items: Vec<Item> = vec![
120-
Item{id: "1".into(), sort: "a".into()},
121-
Item{id: "2".into(), sort: "b".into()},
122-
Item{id: "3".into(), sort: "c".into()},
129+
Item::new("0", "a"),
130+
Item::new("1", "b"),
131+
Item::new("2", "c"),
123132
];
124133

125134
let next = ApiPagedResponse::of(items, 3, |item| item.sort.to_owned()).page.next;
@@ -129,8 +138,8 @@ mod tests {
129138
#[test]
130139
fn should_not_create_with_limit_3_while_size_2() {
131140
let items: Vec<Item> = vec![
132-
Item{id: "1".into(), sort: "a".into()},
133-
Item{id: "2".into(), sort: "b".into()},
141+
Item::new("0", "a"),
142+
Item::new("1", "b"),
134143
];
135144

136145
let page = ApiPagedResponse::of(items, 3, |item| item.sort.to_owned()).page;

0 commit comments

Comments
 (0)