diff --git a/src/StdChains.sol b/src/StdChains.sol index 87e620a3..7ad12cc9 100644 --- a/src/StdChains.sol +++ b/src/StdChains.sol @@ -159,10 +159,18 @@ abstract contract StdChains { } else { chain.rpcUrl = vm.envString(envName); } - // distinguish 'not found' from 'cannot read' - bytes memory notFoundError = + // Distinguish 'not found' from 'cannot read' + // The upstream error thrown by forge for failing cheats changed so we check both the old and new versions + bytes memory oldNotFoundError = abi.encodeWithSignature("CheatCodeError", string(abi.encodePacked("invalid rpc url ", chainAlias))); - if (keccak256(notFoundError) != keccak256(err) || bytes(chain.rpcUrl).length == 0) { + bytes memory newNotFoundError = abi.encodeWithSignature( + "CheatcodeError(string)", string(abi.encodePacked("invalid rpc url: ", chainAlias)) + ); + bytes32 errHash = keccak256(err); + if ( + (errHash != keccak256(oldNotFoundError) && errHash != keccak256(newNotFoundError)) + || bytes(chain.rpcUrl).length == 0 + ) { /// @solidity memory-safe-assembly assembly { revert(add(32, err), mload(err)) diff --git a/test/StdChains.t.sol b/test/StdChains.t.sol index dab37519..b329125e 100644 --- a/test/StdChains.t.sol +++ b/test/StdChains.t.sol @@ -208,13 +208,9 @@ contract StdChainsTest is Test { // Should error if default RPCs flag is set to false. stdChainsMock.exposed_setFallbackToDefaultRpcUrls(false); - vm.expectRevert( - "Failed to get environment variable `ANVIL_RPC_URL` as type `string`: environment variable not found" - ); + vm.expectRevert(); stdChainsMock.exposed_getChain(31337); - vm.expectRevert( - "Failed to get environment variable `SEPOLIA_RPC_URL` as type `string`: environment variable not found" - ); + vm.expectRevert(); stdChainsMock.exposed_getChain("sepolia"); } }