mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 07:37:57 +00:00
Offchain testing: Fix reading response (#10294)
This commit is contained in:
@@ -535,6 +535,38 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_send_huge_response() {
|
||||
let (offchain, state) = testing::TestOffchainExt::new();
|
||||
let mut t = TestExternalities::default();
|
||||
t.register_extension(OffchainWorkerExt::new(offchain));
|
||||
|
||||
t.execute_with(|| {
|
||||
let request: Request = Request::get("http://localhost:1234");
|
||||
let pending = request.add_header("X-Auth", "hunter2").send().unwrap();
|
||||
// make sure it's sent correctly
|
||||
state.write().fulfill_pending_request(
|
||||
0,
|
||||
testing::PendingRequest {
|
||||
method: "GET".into(),
|
||||
uri: "http://localhost:1234".into(),
|
||||
headers: vec![("X-Auth".into(), "hunter2".into())],
|
||||
sent: true,
|
||||
..Default::default()
|
||||
},
|
||||
vec![0; 5923],
|
||||
None,
|
||||
);
|
||||
|
||||
// wait
|
||||
let response = pending.wait().unwrap();
|
||||
|
||||
let body = response.body();
|
||||
assert_eq!(body.clone().collect::<Vec<_>>(), vec![0; 5923]);
|
||||
assert_eq!(body.error(), &None);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_send_a_post_request() {
|
||||
let (offchain, state) = testing::TestOffchainExt::new();
|
||||
|
||||
Reference in New Issue
Block a user