Skip to content

Commit

Permalink
test: access foreign events and upgrade pragma
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzzzHui committed Dec 21, 2023
1 parent f50ec33 commit 2adaaa7
Show file tree
Hide file tree
Showing 18 changed files with 33 additions and 82 deletions.
2 changes: 1 addition & 1 deletion onchain/rollups/.changeset/quick-months-type.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"@cartesi/rollups": patch
"@cartesi/rollups": major
---

Bumped Solidity compiler version to 0.8.23.
26 changes: 4 additions & 22 deletions onchain/rollups/test/foundry/consensus/authority/Authority.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

/// @title Authority Test
pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import {Vm} from "forge-std/Vm.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
Expand All @@ -17,29 +17,11 @@ import {TestBase} from "../../util/TestBase.sol";
contract AuthorityTest is TestBase {
using LibInputRange for InputRange;

event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);

event ClaimSubmission(
address indexed submitter,
address indexed app,
InputRange inputRange,
bytes32 epochHash
);

event ClaimAcceptance(
address indexed app,
InputRange inputRange,
bytes32 epochHash
);

function testConstructor(address owner) public {
vm.assume(owner != address(0));

vm.expectEmit(true, true, false, false);
emit OwnershipTransferred(address(0), owner);
emit Ownable.OwnershipTransferred(address(0), owner);

vm.recordLogs();

Expand Down Expand Up @@ -123,9 +105,9 @@ contract AuthorityTest is TestBase {
bytes32 epochHash
) internal {
vm.expectEmit(true, true, false, true, address(authority));
emit ClaimSubmission(owner, app, inputRange, epochHash);
emit IConsensus.ClaimSubmission(owner, app, inputRange, epochHash);

vm.expectEmit(true, false, false, true, address(authority));
emit ClaimAcceptance(app, inputRange, epochHash);
emit IConsensus.ClaimAcceptance(app, inputRange, epochHash);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

/// @title Authority Factory Test
pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import {Test} from "forge-std/Test.sol";
import {AuthorityFactory} from "contracts/consensus/authority/AuthorityFactory.sol";
import {AuthorityFactory, IAuthorityFactory} from "contracts/consensus/authority/AuthorityFactory.sol";
import {Authority} from "contracts/consensus/authority/Authority.sol";
import {Vm} from "forge-std/Vm.sol";

contract AuthorityFactoryTest is Test {
AuthorityFactory factory;

event AuthorityCreated(address authorityOwner, Authority authority);

struct AuthorityCreatedEventData {
address authorityOwner;
Authority authority;
Expand Down Expand Up @@ -46,7 +44,7 @@ contract AuthorityFactoryTest is Test {

if (
entry.emitter == address(factory) &&
entry.topics[0] == AuthorityCreated.selector
entry.topics[0] == IAuthorityFactory.AuthorityCreated.selector
) {
++numOfAuthorityCreated;

Expand Down
19 changes: 6 additions & 13 deletions onchain/rollups/test/foundry/dapp/Application.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

/// @title Application Test
pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import {TestBase} from "../util/TestBase.sol";

Expand Down Expand Up @@ -95,13 +95,6 @@ contract ApplicationTest is TestBase {
uint256 immutable transferAmount;
IInputRelay[] inputRelays;

event VoucherExecuted(uint256 inputIndex, uint256 outputIndexWithinInput);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
event NewConsensus(IConsensus newConsensus);

constructor() {
appOwner = LibBytes.hashToAddress("appOwner");
initialSupply = LibBytes.hashToUint256("initialSupply");
Expand Down Expand Up @@ -176,7 +169,7 @@ contract ApplicationTest is TestBase {
vm.assume(_owner != address(0));

vm.expectEmit(true, true, false, false);
emit OwnershipTransferred(address(0), _owner);
emit Ownable.OwnershipTransferred(address(0), _owner);

app = new Application(
consensus,
Expand Down Expand Up @@ -241,7 +234,7 @@ contract ApplicationTest is TestBase {

// expect event
vm.expectEmit(false, false, false, true, address(app));
emit VoucherExecuted(
emit IApplication.VoucherExecuted(
_calculateInputIndex(proof),
proof.validity.outputIndexWithinInput
);
Expand Down Expand Up @@ -412,7 +405,7 @@ contract ApplicationTest is TestBase {

// expect event
vm.expectEmit(false, false, false, true, address(app));
emit VoucherExecuted(
emit IApplication.VoucherExecuted(
_calculateInputIndex(proof),
proof.validity.outputIndexWithinInput
);
Expand Down Expand Up @@ -529,7 +522,7 @@ contract ApplicationTest is TestBase {

// expect event
vm.expectEmit(false, false, false, true, address(app));
emit VoucherExecuted(
emit IApplication.VoucherExecuted(
_calculateInputIndex(proof),
proof.validity.outputIndexWithinInput
);
Expand Down Expand Up @@ -583,7 +576,7 @@ contract ApplicationTest is TestBase {
// now impersonate owner
vm.prank(_owner);
vm.expectEmit(false, false, false, true, address(app));
emit NewConsensus(newConsensus);
emit IApplication.NewConsensus(newConsensus);
app.migrateToConsensus(newConsensus);
assertEq(address(app.getConsensus()), address(newConsensus));

Expand Down
16 changes: 4 additions & 12 deletions onchain/rollups/test/foundry/dapp/ApplicationFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

/// @title Application Factory Test
pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import {TestBase} from "../util/TestBase.sol";
import {SimpleConsensus} from "../util/SimpleConsensus.sol";
import {ApplicationFactory} from "contracts/dapp/ApplicationFactory.sol";
import {ApplicationFactory, IApplicationFactory} from "contracts/dapp/ApplicationFactory.sol";
import {Application} from "contracts/dapp/Application.sol";
import {IConsensus} from "contracts/consensus/IConsensus.sol";
import {IInputBox} from "contracts/inputs/IInputBox.sol";
Expand All @@ -22,15 +22,6 @@ contract ApplicationFactoryTest is TestBase {
consensus = new SimpleConsensus();
}

event ApplicationCreated(
IConsensus indexed consensus,
IInputBox inputBox,
IInputRelay[] inputRelays,
address appOwner,
bytes32 templateHash,
Application app
);

function testNewApplication(
IInputBox _inputBox,
IInputRelay[] calldata _inputRelays,
Expand Down Expand Up @@ -187,7 +178,8 @@ contract ApplicationFactoryTest is TestBase {

if (
entry.emitter == address(factory) &&
entry.topics[0] == ApplicationCreated.selector
entry.topics[0] ==
IApplicationFactory.ApplicationCreated.selector
) {
++numOfApplicationsCreated;

Expand Down
11 changes: 2 additions & 9 deletions onchain/rollups/test/foundry/inputs/InputBox.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

/// @title Input Box Test
pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import {Test} from "forge-std/Test.sol";
import {InputBox} from "contracts/inputs/InputBox.sol";
Expand Down Expand Up @@ -137,13 +137,6 @@ contract InputBoxTest is Test {
InputBox inputBox;
InputBoxHandler handler;

event InputAdded(
address indexed app,
uint256 indexed inputIndex,
address sender,
bytes input
);

function setUp() public {
inputBox = new InputBox();
handler = new InputBoxHandler(inputBox);
Expand Down Expand Up @@ -188,7 +181,7 @@ contract InputBoxTest is Test {
vm.expectEmit(true, true, false, true, address(inputBox));

// The event we expect
emit InputAdded(_app, i, address(this), _inputs[i]);
emit IInputBox.InputAdded(_app, i, address(this), _inputs[i]);

returnedValues[i] = inputBox.addInput(_app, _inputs[i]);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
Expand Down
2 changes: 1 addition & 1 deletion onchain/rollups/test/foundry/portals/ERC20Portal.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
Expand Down
2 changes: 1 addition & 1 deletion onchain/rollups/test/foundry/portals/ERC721Portal.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
Expand Down
2 changes: 1 addition & 1 deletion onchain/rollups/test/foundry/portals/EtherPortal.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

/// @title Application Address Relay Test
pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import {Test} from "forge-std/Test.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
Expand All @@ -17,13 +17,6 @@ contract ApplicationAddressRelayTest is Test {
IInputBox inputBox;
IApplicationAddressRelay relay;

event InputAdded(
address indexed app,
uint256 indexed inputIndex,
address sender,
bytes input
);

function setUp() public {
inputBox = new InputBox();
relay = new ApplicationAddressRelay(inputBox);
Expand Down Expand Up @@ -59,7 +52,7 @@ contract ApplicationAddressRelayTest is Test {

// Expect InputAdded to be emitted with the right arguments
vm.expectEmit(true, true, false, true, address(inputBox));
emit InputAdded(_app, 0, address(relay), input);
emit IInputBox.InputAdded(_app, 0, address(relay), input);

// Relay the application's address
relay.relayApplicationAddress(_app);
Expand Down
2 changes: 1 addition & 1 deletion onchain/rollups/test/foundry/util/LibBytes.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

library LibBytes {
/// @notice Generate an address from a byte array.
Expand Down
2 changes: 1 addition & 1 deletion onchain/rollups/test/foundry/util/LibServerManager.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import {Vm} from "forge-std/Vm.sol";
import {InputRange} from "contracts/common/InputRange.sol";
Expand Down
2 changes: 1 addition & 1 deletion onchain/rollups/test/foundry/util/SimpleConsensus.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

/// @title A Simple Consensus Contract
pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import {AbstractConsensus} from "contracts/consensus/AbstractConsensus.sol";
import {InputRange} from "contracts/common/InputRange.sol";
Expand Down
2 changes: 1 addition & 1 deletion onchain/rollups/test/foundry/util/SimpleERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

/// @title A Simple ERC-20 Contract
pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion onchain/rollups/test/foundry/util/SimpleERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

/// @title A Simple ERC-721 Contract
pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";

Expand Down
2 changes: 1 addition & 1 deletion onchain/rollups/test/foundry/util/TestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

/// @title Test base contract
pragma solidity ^0.8.8;
pragma solidity ^0.8.22;

import {Test} from "forge-std/Test.sol";

Expand Down

0 comments on commit 2adaaa7

Please sign in to comment.