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

feat: add Foundry Anvil image impl #272

Merged
merged 3 commits into from
Jan 17, 2025
Merged

Conversation

suchapalaver
Copy link
Contributor

@suchapalaver suchapalaver commented Jan 13, 2025

Community Testcontainers Implementation for Foundry Anvil

This is a community implementation of the Testcontainers interface for Foundry Anvil.

It is not officially supported by Foundry, but it is a community effort to provide a more user-friendly interface for running Anvil inside a Docker container.

The endpoint of the container is intended to be injected into your provider configuration, so that you can easily run tests against a local Anvil instance. See the test_anvil_node_container test in src/anvil/mod.rs to run this example:

let node = testcontainers_modules::anvil::AnvilNode::default().start().await.unwrap();
let port = node.get_host_port_ipv4(PORT).await.unwrap();

let provider: RootProvider<Http<_>, AnyNetwork> =
    RootProvider::new_http(format!("http://localhost:{port}").parse().unwrap());

let block_number = provider.get_block_number().await.unwrap();

assert_eq!(block_number, 0);

@suchapalaver suchapalaver force-pushed the main branch 2 times, most recently from 310cc04 to 6312c7a Compare January 13, 2025 22:21
@suchapalaver
Copy link
Contributor Author

suchapalaver commented Jan 14, 2025

The CI failures do not appear to be caused by the changes in this PR, unless I'm mistaken @DDtKey?

@DDtKey
Copy link
Contributor

DDtKey commented Jan 15, 2025

@suchapalaver Yes, gitea and oracle tests have became flaky in CI, not related to this PR.

Copy link
Contributor

@DDtKey DDtKey left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution!

Just one comment and LGTM!

src/anvil/mod.rs Outdated Show resolved Hide resolved
@suchapalaver suchapalaver force-pushed the main branch 3 times, most recently from 15b72aa to 60162e3 Compare January 16, 2025 00:57
@suchapalaver suchapalaver requested a review from DDtKey January 16, 2025 01:02
@DDtKey DDtKey merged commit b179b48 into testcontainers:main Jan 17, 2025
9 of 12 checks passed
@suchapalaver
Copy link
Contributor Author

@DDtKey thanks for your help on this one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants