Skip to content

Commit

Permalink
chore: ignore E2E broadcast logs
Browse files Browse the repository at this point in the history
  • Loading branch information
danielattilasimon committed Jan 13, 2025
1 parent 01fbcdf commit 2cd299c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
3 changes: 3 additions & 0 deletions contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ testMatrix.json
# Fork script
/anvil.pid
/anvil.log

# E2E broadcast logs
/broadcast-e2e
2 changes: 1 addition & 1 deletion contracts/fork
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Exit on failure
set -e

export FOUNDRY_PROFILE=e2e
export E2E_RPC_URL="http://localhost:8545"

pidfile=anvil.pid
Expand Down Expand Up @@ -100,7 +101,6 @@ deploy() {
}

e2e() {
export FOUNDRY_NO_STORAGE_CACHING=true
forge test --match-path test/E2E.t.sol "$@"
}

Expand Down
8 changes: 8 additions & 0 deletions contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ shrink_run_limit = 0 # takes too damn long to shrink, don't waste Github minutes
mainnet = "${MAINNET_RPC_URL}"
tenderly-mainnet = "${TENDERLY_RPC_URL}"

[profile.e2e]
# Allows us to .gitignore broadcast logs of E2E deployments
broadcast = 'broadcast-e2e'
# As we are running tests in a fork that uses the same chain ID as the forked chain, it is important not to be caching
# any storage, as any new state on top of the forked block is ephemeral and should not be commingled with real state.
# Anvil is going to be caching any storage requests that hit the underlying RPC anyway.
no_storage_caching = true

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
24 changes: 13 additions & 11 deletions contracts/test/E2E.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,21 @@ library SideEffectFreeGetPrice {
}
}

library StringEquality {
function eq(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}

function notEq(string memory a, string memory b) internal pure returns (bool) {
return !eq(a, b);
}
}

contract E2ETest is Test {
using SideEffectFreeGetPrice for IPriceFeed;
using Strings for uint256;
using stdJson for string;
using StringEquality for string;

struct BranchContracts {
IERC20 collToken;
Expand Down Expand Up @@ -136,17 +147,8 @@ contract E2ETest is Test {
int256[] vetos;

function setUp() external {
bool noStorageCaching = vm.envOr("FOUNDRY_NO_STORAGE_CACHING", false);
string memory rpcUrl = vm.envOr("E2E_RPC_URL", string(""));
vm.skip(bytes(rpcUrl).length == 0);

// As we are running tests in a fork that uses the same chain ID as the forked chain, it is important not to
// be caching any storage, as any new state on top of the forked block is ephemeral and should not be commingled
// with real state.
// Anvil is going to be caching any storage requests that hit the underlying RPC anyway.
assertTrue(noStorageCaching, "FOUNDRY_NO_STORAGE_CACHING should be set to true");

vm.createSelectFork(rpcUrl);
vm.skip(vm.envOr("FOUNDRY_PROFILE", string("")).notEq("e2e"));
vm.createSelectFork(vm.envString("E2E_RPC_URL"));

string memory json = vm.readFile("deployment-manifest.json");
collateralRegistry = ICollateralRegistry(json.readAddress(".collateralRegistry"));
Expand Down

0 comments on commit 2cd299c

Please sign in to comment.