Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore flaky tests #947

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions crates/provider/src/alloy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,30 @@ mod tests {

use crate::new_alloy_provider;
fn setup() {
let server = Server::http("0.0.0.0:8000").unwrap();
let server = Server::http("0.0.0.0:9009").unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned that this will still be flaky in case something is using this port. Is there a way to let the OS assign an open port and retrieve it after? Sometimes this is done by setting the port to :0

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may be able to use that and then do .server_addr to get the port it was bound to by the OS

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may need to use bind and then from_listener to create the server.

Copy link
Collaborator Author

@andysim3d andysim3d Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mark the test to ignore for now. it should only run on local box.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, we should eventually fix this

for request in server.incoming_requests() {
sleep(Duration::from_secs(10));
sleep(Duration::from_secs(5));
let _ = request.respond(Response::from_string(
"{\"jsonrpc\": \"2.0\", \"id\": 1, \"result\": \"0x146b6d7\"}",
));
}
}
#[ignore = "this test is flaky with github action, should only run locally"]
#[tokio::test]
async fn test_timeout() {
thread::spawn(move || {
setup();
});
{
// Wait 11 seconds and get result
let provider = new_alloy_provider("http://localhost:8000", 15)
let provider = new_alloy_provider("http://localhost:9009", 15)
.expect("can not initialize provider");
let x = provider.get_block_number().await;
assert!(x.is_ok());
}
{
// Wait 9 seconds and timeout form client side
let provider = new_alloy_provider("http://localhost:8000", 5)
let provider = new_alloy_provider("http://localhost:9009", 1)
.expect("can not initialize provider");
let x = provider.get_block_number().await;
assert!(x.is_err());
Expand Down
Loading