Skip to content

Commit

Permalink
ethereum/forge-test: clean up warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-gray committed Aug 11, 2024
1 parent 0a50809 commit d7d153a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 34 deletions.
11 changes: 4 additions & 7 deletions ethereum/forge-test/Bridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,6 @@ contract TestBridge is Test {
feeToken.mint(address(this), mintAmount);
feeToken.approve(address(bridge), mintAmount);

uint256 bridgeBalanceBefore = feeToken.balanceOf(address(bridge));

uint256 feeAmount = (amount * 9) / 10;

bytes memory transferPayload = abi.encodePacked(
Expand Down Expand Up @@ -1080,13 +1078,13 @@ contract TestBridge is Test {
);
}

function addressToBytes32(address input) internal returns (bytes32 output) {
function addressToBytes32(address input) internal pure returns (bytes32 output) {
return bytes32(uint256(uint160(input)));
}

function uint256Array(
uint256 member
) internal returns (uint256[] memory arr) {
) internal pure returns (uint256[] memory arr) {
arr = new uint256[](1);
arr[0] = member;
}
Expand All @@ -1101,7 +1099,7 @@ contract TestBridge is Test {
uint256[] memory signers,
uint32 guardianSetIndex,
uint8 consistencyLevel
) public returns (bytes memory signedMessage) {
) public pure returns (bytes memory signedMessage) {
bytes memory body = abi.encodePacked(
timestamp,
nonce,
Expand Down Expand Up @@ -1167,7 +1165,6 @@ contract TestBridge is Test {
);

bytes32 IMPLEMENTATION_STORAGE_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
bytes32 before = vm.load(address(bridge), IMPLEMENTATION_STORAGE_SLOT);

bridge.upgrade(vaa);

Expand Down Expand Up @@ -1245,7 +1242,6 @@ contract TestBridge is Test {
);

bytes32 IMPLEMENTATION_STORAGE_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
bytes32 before = vm.load(address(bridge), IMPLEMENTATION_STORAGE_SLOT);

bridge.upgrade(vaa);

Expand Down Expand Up @@ -1434,4 +1430,5 @@ contract TestBridge is Test {
}

fallback() external payable {}
receive() external payable {}
}
27 changes: 6 additions & 21 deletions ethereum/forge-test/Implementation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ contract TestImplementation is TestUtils {

function uint256Array(
uint256 member
) internal returns (uint256[] memory arr) {
) internal pure returns (uint256[] memory arr) {
arr = new uint256[](1);
arr[0] = member;
}
Expand Down Expand Up @@ -270,7 +270,7 @@ contract TestImplementation is TestUtils {
uint256[] memory signers,
uint32 guardianSetIndex,
uint8 consistencyLevel
) public returns (bytes memory signedMessage) {
) public pure returns (bytes memory signedMessage) {
bytes memory body = abi.encodePacked(
timestamp,
nonce,
Expand Down Expand Up @@ -320,7 +320,7 @@ contract TestImplementation is TestUtils {
uint256[] memory signers,
uint32 guardianSetIndex,
uint8 consistencyLevel
) public returns (bytes memory signedMessage) {
) public pure returns (bytes memory signedMessage) {
bytes memory body = abi.encodePacked(
timestamp,
nonce,
Expand Down Expand Up @@ -492,7 +492,7 @@ contract TestImplementation is TestUtils {
consistencyLevel
);

(IWormhole.VM memory parsed, bool valid, string memory reason) = proxied
(, bool valid, string memory reason) = proxied
.parseAndVerifyVM(signedMessage);

assertEq(valid, false, "Signed vaa shouldn't be valid");
Expand Down Expand Up @@ -527,8 +527,7 @@ contract TestImplementation is TestUtils {
);

vm.expectRevert("signature indices must be ascending");
(IWormhole.VM memory parsed, bool valid, string memory reason) = proxied
.parseAndVerifyVM(signedMessage);
proxied.parseAndVerifyVM(signedMessage);
}

function testShouldSetAndEnforceFees() public {
Expand Down Expand Up @@ -642,7 +641,6 @@ contract TestImplementation is TestUtils {
function testShouldAcceptANewGuardianSet() public {
uint32 timestamp = 1000;
uint32 nonce = 1001;
address zeroAddress = address(0x0);

uint32 oldGuardianSetIndex = proxied.getCurrentGuardianSetIndex();

Expand Down Expand Up @@ -708,8 +706,6 @@ contract TestImplementation is TestUtils {

MockImplementation mock = new MockImplementation();

uint256 oldGuardianSetIndex = proxied.getCurrentGuardianSetIndex();

bytes memory data = abi.encodePacked(
core,
actionContractUpgrade,
Expand All @@ -729,7 +725,6 @@ contract TestImplementation is TestUtils {
);

bytes32 IMPLEMENTATION_STORAGE_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
bytes32 before = vm.load(address(proxied), IMPLEMENTATION_STORAGE_SLOT);

proxied.submitContractUpgrade(vaa);

Expand All @@ -751,7 +746,6 @@ contract TestImplementation is TestUtils {
{
uint32 timestamp = 1000;
uint32 nonce = 1001;
address zeroAddress = address(0x0);

bytes memory data = abi.encodePacked(
core,
Expand Down Expand Up @@ -779,7 +773,6 @@ contract TestImplementation is TestUtils {
function testShouldRevertGovernancePacketsFromOldGuardianSet() public {
uint32 timestamp = 1000;
uint32 nonce = 1001;
address zeroAddress = address(0x0);

// upgrade guardian set
bytes memory data = abi.encodePacked(
Expand Down Expand Up @@ -832,9 +825,6 @@ contract TestImplementation is TestUtils {
function testShouldTimeOutOldGuardians() public {
uint32 timestamp = 1000;
uint32 nonce = 1001;
address zeroAddress = address(0x0);
uint16 emitterChainId = 11;
bytes32 emitterAddress = 0x0000000000000000000000000000000000000000000000000000000000000eee;

// upgrade guardian set
bytes memory data = abi.encodePacked(
Expand Down Expand Up @@ -890,7 +880,6 @@ contract TestImplementation is TestUtils {
{
uint32 timestamp = 1000;
uint32 nonce = 1001;
address zeroAddress = address(0x0);

bytes memory data = abi.encodePacked(
core,
Expand Down Expand Up @@ -920,7 +909,6 @@ contract TestImplementation is TestUtils {
{
uint32 timestamp = 1000;
uint32 nonce = 1001;
address zeroAddress = address(0x0);

bytes memory data = abi.encodePacked(
core,
Expand Down Expand Up @@ -950,7 +938,6 @@ contract TestImplementation is TestUtils {
{
uint32 timestamp = 1000;
uint32 nonce = 1001;
address zeroAddress = address(0x0);

uint256 amount = 1;
vm.deal(address(proxied), amount);
Expand Down Expand Up @@ -980,7 +967,7 @@ contract TestImplementation is TestUtils {
proxied.submitTransferFees(vaa);
}

function addressToBytes32(address input) internal returns (bytes32 output) {
function addressToBytes32(address input) internal pure returns (bytes32 output) {
return bytes32(uint256(uint160(input)));
}

Expand Down Expand Up @@ -1010,7 +997,6 @@ contract TestImplementation is TestUtils {
);

bytes32 IMPLEMENTATION_STORAGE_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
bytes32 before = vm.load(address(proxied), IMPLEMENTATION_STORAGE_SLOT);

proxied.submitContractUpgrade(vaa);

Expand Down Expand Up @@ -1090,7 +1076,6 @@ contract TestImplementation is TestUtils {
);

bytes32 IMPLEMENTATION_STORAGE_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
bytes32 before = vm.load(address(proxied), IMPLEMENTATION_STORAGE_SLOT);

proxied.submitContractUpgrade(vaa);

Expand Down
11 changes: 5 additions & 6 deletions ethereum/forge-test/NFT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -610,13 +610,13 @@ contract TestNFTBridge is Test {
wrapped.ownerOf(tokenId);
}

function addressToBytes32(address input) internal returns (bytes32 output) {
function addressToBytes32(address input) internal pure returns (bytes32 output) {
return bytes32(uint256(uint160(input)));
}

function uint256Array(
uint256 member
) internal returns (uint256[] memory arr) {
) internal pure returns (uint256[] memory arr) {
arr = new uint256[](1);
arr[0] = member;
}
Expand All @@ -631,7 +631,7 @@ contract TestNFTBridge is Test {
uint256[] memory signers,
uint32 guardianSetIndex,
uint8 consistencyLevel
) public returns (bytes memory signedMessage) {
) public pure returns (bytes memory signedMessage) {
bytes memory body = abi.encodePacked(
timestamp,
nonce,
Expand Down Expand Up @@ -697,7 +697,6 @@ contract TestNFTBridge is Test {
);

bytes32 IMPLEMENTATION_STORAGE_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
bytes32 before = vm.load(address(bridge), IMPLEMENTATION_STORAGE_SLOT);

bridge.upgrade(vaa);

Expand Down Expand Up @@ -775,7 +774,6 @@ contract TestNFTBridge is Test {
);

bytes32 IMPLEMENTATION_STORAGE_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
bytes32 before = vm.load(address(bridge), IMPLEMENTATION_STORAGE_SLOT);

bridge.upgrade(vaa);

Expand Down Expand Up @@ -968,9 +966,10 @@ contract TestNFTBridge is Test {
address,
uint256,
bytes calldata
) external returns (bytes4) {
) external pure returns (bytes4) {
return 0x150b7a02;
}

fallback() external payable {}
receive() external payable {}
}

0 comments on commit d7d153a

Please sign in to comment.