-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix revert when getting upgrade interface version with OpenZeppelin C…
…ontracts v4 (#65)
- Loading branch information
Showing
4 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
// These contracts are for testing only. | ||
|
||
contract UpgradeInterfaceVersionString { | ||
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0"; | ||
} | ||
|
||
contract UpgradeInterfaceVersionNoGetter {} | ||
|
||
contract UpgradeInterfaceVersionEmpty { | ||
string public constant UPGRADE_INTERFACE_VERSION = ""; | ||
} | ||
|
||
contract UpgradeInterfaceVersionInteger { | ||
uint256 public constant UPGRADE_INTERFACE_VERSION = 5; | ||
} | ||
|
||
contract UpgradeInterfaceVersionVoid { | ||
function UPGRADE_INTERFACE_VERSION() external pure {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import {Test} from "forge-std/Test.sol"; | ||
|
||
import {Core} from "openzeppelin-foundry-upgrades/internal/Core.sol"; | ||
|
||
import {UpgradeInterfaceVersionString, UpgradeInterfaceVersionNoGetter, UpgradeInterfaceVersionEmpty, UpgradeInterfaceVersionInteger, UpgradeInterfaceVersionVoid} from "../contracts/UpgradeInterfaceVersions.sol"; | ||
|
||
/** | ||
* @dev Tests the Core internal library. | ||
*/ | ||
contract CoreTest is Test { | ||
function testGetUpgradeInterfaceVersion_string() public { | ||
UpgradeInterfaceVersionString u = new UpgradeInterfaceVersionString(); | ||
assertEq(Core.getUpgradeInterfaceVersion(address(u)), "5.0.0"); | ||
} | ||
|
||
function testGetUpgradeInterfaceVersion_noGetter() public { | ||
UpgradeInterfaceVersionNoGetter u = new UpgradeInterfaceVersionNoGetter(); | ||
assertEq(Core.getUpgradeInterfaceVersion(address(u)), ""); | ||
} | ||
|
||
function testGetUpgradeInterfaceVersion_empty() public { | ||
UpgradeInterfaceVersionEmpty u = new UpgradeInterfaceVersionEmpty(); | ||
assertEq(Core.getUpgradeInterfaceVersion(address(u)), ""); | ||
} | ||
|
||
function testGetUpgradeInterfaceVersion_integer() public { | ||
UpgradeInterfaceVersionInteger u = new UpgradeInterfaceVersionInteger(); | ||
assertEq(Core.getUpgradeInterfaceVersion(address(u)), ""); | ||
} | ||
|
||
function testGetUpgradeInterfaceVersion_void() public { | ||
UpgradeInterfaceVersionVoid u = new UpgradeInterfaceVersionVoid(); | ||
assertEq(Core.getUpgradeInterfaceVersion(address(u)), ""); | ||
} | ||
} |