Skip to content

Commit

Permalink
move IBCChannelUpgradableMockApp into apps/mock
Browse files Browse the repository at this point in the history
Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele committed Jul 31, 2024
1 parent e70f0d5 commit 6b6cf96
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;

import {UpgradeFields, Timeout} from "../../../../contracts/proto/Channel.sol";
import {
IIBCChannelUpgradeBase
} from "../../../../contracts/core/04-channel/IIBCChannelUpgrade.sol";
import {IIBCHandler} from "../../../../contracts/core/25-handler/IIBCHandler.sol";
import {IBCMockApp} from "../../../../contracts/apps/mock/IBCMockApp.sol";
import {IBCChannelUpgradableModuleBase} from "../../../../contracts/apps/commons/IBCChannelUpgradableModule.sol";
import {IBCAppBase} from "../../../../contracts/apps/commons/IBCAppBase.sol";
import {UpgradeFields, Timeout} from "../../proto/Channel.sol";
import {IIBCChannelUpgradeBase} from "../../core/04-channel/IIBCChannelUpgrade.sol";
import {IIBCHandler} from "../../core/25-handler/IIBCHandler.sol";
import {IBCMockApp} from "./IBCMockApp.sol";
import {IBCChannelUpgradableModuleBase} from "../commons/IBCChannelUpgradableModule.sol";
import {IBCAppBase} from "../commons/IBCAppBase.sol";

contract TestIBCChannelUpgradableMockApp is IBCMockApp, IBCChannelUpgradableModuleBase {
contract IBCChannelUpgradableMockApp is IBCMockApp, IBCChannelUpgradableModuleBase {
constructor(IIBCHandler ibcHandler_) IBCMockApp(ibcHandler_) {}

function supportsInterface(bytes4 interfaceId) public view virtual override(IBCChannelUpgradableModuleBase, IBCAppBase) returns (bool) {
return
super.supportsInterface(interfaceId) || interfaceId == this.proposeAndInitUpgrade.selector;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(IBCChannelUpgradableModuleBase, IBCAppBase)
returns (bool)
{
return super.supportsInterface(interfaceId) || interfaceId == this.proposeAndInitUpgrade.selector;
}

/**
* @dev Propose upgrade and perform chanUpgradeInit.
*/
function proposeAndInitUpgrade(
string calldata portId,
string calldata channelId,
Expand Down
6 changes: 3 additions & 3 deletions tests/foundry/src/ICS04Upgrade.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {LocalhostClientLib} from "../../../contracts/clients/09-localhost/Localh
import {LocalhostHelper} from "../../../contracts/clients/09-localhost/LocalhostHelper.sol";
import {IIBCChannelRecvPacket, IIBCChannelAcknowledgePacket} from "../../../contracts/core/04-channel/IIBCChannel.sol";
import {IIBCChannelUpgradeBase} from "../../../contracts/core/04-channel/IIBCChannelUpgrade.sol";
import {IBCChannelUpgradableMockApp} from "../../../contracts/apps/mock/IBCChannelUpgradableMockApp.sol";
import {IIBCHostErrors} from "../../../contracts/core/24-host/IIBCHostErrors.sol";
import {TestIBCChannelUpgradableMockApp} from "./helpers/TestIBCChannelUpgradableMockApp.t.sol";
import {TestIBCChannelUpgradableMockAppInconsistentVersions} from "./helpers/TestIBCChannelUpgradableMockAppInconsistentVersions.t.sol";
import {ICS04UpgradeTestHelper} from "./helpers/ICS04UpgradeTestHelper.t.sol";
import {ICS04PacketEventTestHelper} from "./helpers/ICS04PacketTestHelper.t.sol";
Expand All @@ -28,7 +28,7 @@ contract TestICS04Upgrade is ICS04UpgradeTestHelper, ICS04PacketEventTestHelper
string internal constant MOCK_APP_VERSION_2 = "mockapp-2";

TestableIBCHandler ibcHandler;
TestIBCChannelUpgradableMockApp mockApp;
IBCChannelUpgradableMockApp mockApp;
TestIBCChannelUpgradableMockAppInconsistentVersions maliciousMockApp;

struct ChannelInfo {
Expand All @@ -39,7 +39,7 @@ contract TestICS04Upgrade is ICS04UpgradeTestHelper, ICS04PacketEventTestHelper

function setUp() public {
ibcHandler = defaultIBCHandler();
mockApp = new TestIBCChannelUpgradableMockApp(ibcHandler);
mockApp = new IBCChannelUpgradableMockApp(ibcHandler);
maliciousMockApp = new TestIBCChannelUpgradableMockAppInconsistentVersions(ibcHandler);
ibcHandler.bindPort(MOCK_APP_PORT, mockApp);
ibcHandler.registerLocalhostClient();
Expand Down
6 changes: 3 additions & 3 deletions tests/foundry/src/ICS04UpgradeApp.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {LocalhostHelper} from "../../../contracts/clients/09-localhost/Localhost
import {
IIBCChannelUpgradableModule, IIBCChannelUpgradableModuleErrors
} from "../../../contracts/apps/commons/IBCChannelUpgradableModule.sol";
import {TestIBCChannelUpgradableMockApp} from "./helpers/TestIBCChannelUpgradableMockApp.t.sol";
import {IBCChannelUpgradableMockApp} from "../../../contracts/apps/mock/IBCChannelUpgradableMockApp.sol";
import {ICS04UpgradeTestHelper} from "./helpers/ICS04UpgradeTestHelper.t.sol";

contract TestICS04UpgradeApp is ICS04UpgradeTestHelper {
Expand All @@ -19,7 +19,7 @@ contract TestICS04UpgradeApp is ICS04UpgradeTestHelper {
string internal constant MOCK_APP_VERSION_2 = "mockapp-2";

TestableIBCHandler ibcHandler;
TestIBCChannelUpgradableMockApp mockApp;
IBCChannelUpgradableMockApp mockApp;

struct ChannelInfo {
string connectionId;
Expand All @@ -29,7 +29,7 @@ contract TestICS04UpgradeApp is ICS04UpgradeTestHelper {

function setUp() public {
ibcHandler = defaultIBCHandler();
mockApp = new TestIBCChannelUpgradableMockApp(ibcHandler);
mockApp = new IBCChannelUpgradableMockApp(ibcHandler);
ibcHandler.bindPort(MOCK_APP_PORT, mockApp);
ibcHandler.registerLocalhostClient();
ibcHandler.createLocalhostClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ pragma solidity ^0.8.20;

import {UpgradeFields} from "../../../../contracts/proto/Channel.sol";
import {TestableIBCHandler} from "./TestableIBCHandler.t.sol";
import {TestIBCChannelUpgradableMockApp} from "./TestIBCChannelUpgradableMockApp.t.sol";
import {IBCChannelUpgradableMockApp} from "../../../../contracts/apps/mock/IBCChannelUpgradableMockApp.sol";

contract TestIBCChannelUpgradableMockAppInconsistentVersions is TestIBCChannelUpgradableMockApp {
constructor(TestableIBCHandler _ibcHandler) TestIBCChannelUpgradableMockApp(_ibcHandler) {}
contract TestIBCChannelUpgradableMockAppInconsistentVersions is IBCChannelUpgradableMockApp {
constructor(TestableIBCHandler _ibcHandler) IBCChannelUpgradableMockApp(_ibcHandler) {}

function onChanUpgradeInit(
string calldata portId,
Expand Down

0 comments on commit 6b6cf96

Please sign in to comment.