Skip to content

Commit

Permalink
Update forge-std, fix compiler warnings (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau authored Mar 20, 2024
1 parent 7c66927 commit ebf5a0f
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 21 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Changelog

## 0.2.0 (2024-03-20)

- Update forge-std to v1.8.0, restrict state mutability of some functions. ([#30](https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades/pull/30))

### Breaking changes
- Requires forge-std version v1.8.0 or later.

## 0.1.0 (2024-03-11)

- Support private networks and forked networks with Defender.
- Support private networks and forked networks with Defender. ([#25](https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades/pull/25))

## 0.0.2 (2024-02-20)

Expand Down
2 changes: 1 addition & 1 deletion src/Upgrades.sol
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ library Upgrades {
string memory contractName,
Options memory opts,
bool requireReference
) private returns (string[] memory) {
) private view returns (string[] memory) {
string memory outDir = Utils.getOutDir();

string[] memory inputBuilder = new string[](255);
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ library Utils {
/**
* @dev Gets the output directory from the FOUNDRY_OUT environment variable, or defaults to "out" if not set.
*/
function getOutDir() internal returns (string memory) {
function getOutDir() internal view returns (string memory) {
Vm vm = Vm(CHEATCODE_ADDRESS);

string memory defaultOutDir = "out";
Expand Down
2 changes: 1 addition & 1 deletion test/UpgradesUseDefenderDeploy.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract UpgradesUseDefenderDeployTest is Test {
d = new Deployer();
}

function _assertDefenderNotAvailable(strings.slice memory slice) private {
function _assertDefenderNotAvailable(strings.slice memory slice) private pure {
assertTrue(
slice.contains(
"The current network with chainId 31337 is not supported by OpenZeppelin Defender".toSlice()
Expand Down
3 changes: 2 additions & 1 deletion test/contracts/Validations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ pragma solidity ^0.8.20;

contract Unsafe {
function unsafe() public {
selfdestruct(payable(msg.sender));
(bool s, ) = msg.sender.delegatecall("");
s;
}
}

Expand Down
12 changes: 6 additions & 6 deletions test/internal/DefenderDeploy.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ contract DefenderDeployTest is Test {
);
}

function testBuildProposeUpgradeCommand() public {
function testBuildProposeUpgradeCommand() public view {
ContractInfo memory contractInfo = Utils.getContractInfo("MyContractFile.sol:MyContractName", "out");

Options memory opts;
Expand All @@ -134,7 +134,7 @@ contract DefenderDeployTest is Test {
);
}

function testParseProposeUpgradeResponse() public {
function testParseProposeUpgradeResponse() public pure {
string memory output = "Upgrade proposal created.\nProposal ID: 123\nProposal URL: https://my.url/my-tx";

ProposeUpgradeResponse memory response = DefenderDeploy.parseProposeUpgradeResponse(output);
Expand All @@ -143,7 +143,7 @@ contract DefenderDeployTest is Test {
assertEq(response.url, "https://my.url/my-tx");
}

function testParseProposeUpgradeResponseNoUrl() public {
function testParseProposeUpgradeResponseNoUrl() public pure {
string memory output = "Upgrade proposal created.\nProposal ID: 123";

ProposeUpgradeResponse memory response = DefenderDeploy.parseProposeUpgradeResponse(output);
Expand All @@ -152,7 +152,7 @@ contract DefenderDeployTest is Test {
assertEq(response.url, "");
}

function testBuildGetApprovalProcessCommand() public {
function testBuildGetApprovalProcessCommand() public view {
string memory commandString = _toString(
DefenderDeploy.buildGetApprovalProcessCommand("getDeployApprovalProcess")
);
Expand All @@ -167,7 +167,7 @@ contract DefenderDeployTest is Test {
);
}

function testParseApprovalProcessResponse() public {
function testParseApprovalProcessResponse() public pure {
string
memory output = "Approval process ID: abc\nVia: 0x1230000000000000000000000000000000000456\nVia type: Relayer";

Expand All @@ -178,7 +178,7 @@ contract DefenderDeployTest is Test {
assertEq(response.viaType, "Relayer");
}

function testParseApprovalProcessResponseIdOnly() public {
function testParseApprovalProcessResponseIdOnly() public pure {
string memory output = "Approval process ID: abc";

ApprovalProcessResponse memory response = DefenderDeploy.parseApprovalProcessResponse(output);
Expand Down
18 changes: 9 additions & 9 deletions test/internal/Utils.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {Utils, ContractInfo} from "openzeppelin-foundry-upgrades/internal/Utils.
* @dev Tests the Utils internal library.
*/
contract UtilsTest is Test {
function testGetContractInfo_from_file() public {
function testGetContractInfo_from_file() public view {
ContractInfo memory info = Utils.getContractInfo("Greeter.sol", "out");

assertEq(info.shortName, "Greeter");
Expand All @@ -20,14 +20,14 @@ contract UtilsTest is Test {
assertEq(info.sourceCodeHash, "0xf9875b1fd90da13f5f990d5ba7e66481f4b7e13e4a8f57fa9145fe90a1cb9324"); // source code hash of Greeter.sol
}

function testGetContractInfo_from_fileAndName() public {
function testGetContractInfo_from_fileAndName() public view {
ContractInfo memory info = Utils.getContractInfo("MyContractFile.sol:MyContractName", "out");

assertEq(info.shortName, "MyContractName");
assertEq(info.contractPath, "test/contracts/MyContractFile.sol");
}

function testGetContractInfo_from_artifact() public {
function testGetContractInfo_from_artifact() public view {
ContractInfo memory info = Utils.getContractInfo("out/MyContractFile.sol/MyContractName.json", "out");

assertEq(info.shortName, "MyContractName");
Expand All @@ -46,7 +46,7 @@ contract UtilsTest is Test {
}
}

function testGetContractInfo_outDirTrailingSlash() public {
function testGetContractInfo_outDirTrailingSlash() public view {
ContractInfo memory info = Utils.getContractInfo("Greeter.sol", "out/");

assertEq(info.shortName, "Greeter");
Expand All @@ -60,19 +60,19 @@ contract UtilsTest is Test {
} catch {}
}

function testGetFullyQualifiedName_from_file() public {
function testGetFullyQualifiedName_from_file() public view {
string memory fqName = Utils.getFullyQualifiedName("Greeter.sol", "out");

assertEq(fqName, "test/contracts/Greeter.sol:Greeter");
}

function testGetFullyQualifiedName_from_fileAndName() public {
function testGetFullyQualifiedName_from_fileAndName() public view {
string memory fqName = Utils.getFullyQualifiedName("MyContractFile.sol:MyContractName", "out");

assertEq(fqName, "test/contracts/MyContractFile.sol:MyContractName");
}

function testGetFullyQualifiedName_from_artifact() public {
function testGetFullyQualifiedName_from_artifact() public view {
string memory fqName = Utils.getFullyQualifiedName("out/MyContractFile.sol/MyContractName.json", "out");

assertEq(fqName, "test/contracts/MyContractFile.sol:MyContractName");
Expand All @@ -97,7 +97,7 @@ contract UtilsTest is Test {
} catch {}
}

function testGetOutDir() public {
function testGetOutDir() public view {
assertEq(Utils.getOutDir(), "out");
}

Expand All @@ -115,7 +115,7 @@ contract UtilsTest is Test {
assertTrue(buildInfoFile.toSlice().endsWith(".json".toSlice()));
}

function testToBashCommand() public {
function testToBashCommand() public pure {
string[] memory inputs = new string[](3);
inputs[0] = "foo";
inputs[1] = "param";
Expand Down

0 comments on commit ebf5a0f

Please sign in to comment.