Add network timeouts and fix tests
test_rpc_send_tx could fail if it didn't succeed on the first try * add some retries to consistently pass
This commit is contained in:
parent
590b88f718
commit
8e67a18551
30
src/rpc.rs
30
src/rpc.rs
|
@ -765,7 +765,7 @@ mod tests {
|
||||||
let json: Value = serde_json::from_str(&response.text().unwrap()).unwrap();
|
let json: Value = serde_json::from_str(&response.text().unwrap()).unwrap();
|
||||||
let signature = &json["result"];
|
let signature = &json["result"];
|
||||||
|
|
||||||
sleep(Duration::from_millis(500));
|
let mut confirmed_tx = false;
|
||||||
|
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let request = json!({
|
let request = json!({
|
||||||
|
@ -774,16 +774,26 @@ mod tests {
|
||||||
"method": "confirmTransaction",
|
"method": "confirmTransaction",
|
||||||
"params": [signature],
|
"params": [signature],
|
||||||
});
|
});
|
||||||
let mut response = client
|
|
||||||
.post(&rpc_string)
|
|
||||||
.header(CONTENT_TYPE, "application/json")
|
|
||||||
.body(request.to_string())
|
|
||||||
.send()
|
|
||||||
.unwrap();
|
|
||||||
let response_json_text = response.text().unwrap();
|
|
||||||
let json: Value = serde_json::from_str(&response_json_text).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(true, json["result"]);
|
for _ in 0..5 {
|
||||||
|
let mut response = client
|
||||||
|
.post(&rpc_string)
|
||||||
|
.header(CONTENT_TYPE, "application/json")
|
||||||
|
.body(request.to_string())
|
||||||
|
.send()
|
||||||
|
.unwrap();
|
||||||
|
let response_json_text = response.text().unwrap();
|
||||||
|
let json: Value = serde_json::from_str(&response_json_text).unwrap();
|
||||||
|
|
||||||
|
if true == json["result"] {
|
||||||
|
confirmed_tx = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep(Duration::from_millis(250));
|
||||||
|
}
|
||||||
|
|
||||||
|
assert!(confirmed_tx);
|
||||||
|
|
||||||
server.close().unwrap();
|
server.close().unwrap();
|
||||||
remove_dir_all(ledger_path).unwrap();
|
remove_dir_all(ledger_path).unwrap();
|
||||||
|
|
Loading…
Reference in New Issue