Skip to content

refactor: deploy all libraries when running tests#8034

Merged
mattsse merged 7 commits into
masterfrom
klkvr/predeploy-libs-in-tests
Jun 3, 2024
Merged

refactor: deploy all libraries when running tests#8034
mattsse merged 7 commits into
masterfrom
klkvr/predeploy-libs-in-tests

Conversation

@klkvr

@klkvr klkvr commented Jun 2, 2024

Copy link
Copy Markdown
Member

Motivation

Closes #1161
Closes #6120
Closes #8014

Keeping foundry-rs/book#1361 open as this still won't work in scripts.

Solution

Instead of linking each contract separately and keeping separate libs_to_deploy for each test contract we now link entire project output and keep single libs_to_deploy and known_contracts. That way, we reduce memory usage and by deploying all needed libraries unblock usage of getCode/getDeployedCode with artifacts requiring linking.

To avoid nonce of the sender being affected by the number of external libraries used in project, I've inroduced separate LIBRARY_DEPLOYER which deploys all libraries, that way, test contract will always have the same address regardless of the number of libraries it requires to run.

Comment thread crates/forge/bin/cmd/test/mod.rs Outdated
Comment thread crates/forge/src/runner.rs Outdated
Comment thread crates/forge/src/runner.rs Outdated
@DaniPopes

Copy link
Copy Markdown
Member

This should close #8014

Comment thread crates/forge/bin/cmd/test/mod.rs Outdated
Comment thread crates/forge/bin/cmd/test/mod.rs

@DaniPopes DaniPopes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice

@mattsse mattsse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

awesome

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.

perf(forge test): memory leak in latest foundry Support library linking in vm.getDeployedCode feat: getCode for linked contracts

3 participants