Skip to content

Commit 0ee0a6a

Browse files
marshallyaleValuedMammal
authored andcommitted
test: add batch response ordering test
1 parent 6721929 commit 0ee0a6a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/raw_client.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,26 @@ mod test {
11901190
assert_eq!(resp.hash_function, Some("sha256".into()));
11911191
assert_eq!(resp.pruning, None);
11921192
}
1193+
1194+
#[test]
1195+
#[ignore = "depends on a live server"]
1196+
fn test_batch_response_ordering() {
1197+
// The electrum.blockstream.info:50001 node always sends back ordered responses which will make this always pass.
1198+
// However, many servers do not, so we use one of those servers for this test.
1199+
let client = RawClient::new("exs.dyshek.org:50001", None).unwrap();
1200+
let heights: Vec<u32> = vec![1, 4, 8, 12, 222, 6666, 12];
1201+
let result_times = [
1202+
1231469665, 1231470988, 1231472743, 1231474888, 1231770653, 1236456633, 1231474888,
1203+
];
1204+
// Check ordering 10 times. This usually fails within 5 if ordering is incorrect.
1205+
for _ in 0..10 {
1206+
let results = client.batch_block_header(&heights).unwrap();
1207+
for (index, result) in results.iter().enumerate() {
1208+
assert_eq!(result_times[index], result.time);
1209+
}
1210+
}
1211+
}
1212+
11931213
#[test]
11941214
fn test_relay_fee() {
11951215
let client = RawClient::new(get_test_server(), None).unwrap();

0 commit comments

Comments
 (0)