From c08086ce5643342d180d9543f6ed03f0e2fe8b19 Mon Sep 17 00:00:00 2001 From: Guilherme Dantas Date: Mon, 31 Jul 2023 23:28:51 -0300 Subject: [PATCH] refactor(contracts): minimize diff --- .../test/foundry/dapp/CartesiDApp.t.sol | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/onchain/rollups/test/foundry/dapp/CartesiDApp.t.sol b/onchain/rollups/test/foundry/dapp/CartesiDApp.t.sol index 955524d1..19b56ecd 100644 --- a/onchain/rollups/test/foundry/dapp/CartesiDApp.t.sol +++ b/onchain/rollups/test/foundry/dapp/CartesiDApp.t.sol @@ -16,11 +16,11 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; +import {LibServerManager} from "../util/LibServerManager.sol"; import {SimpleConsensus} from "../util/SimpleConsensus.sol"; import {SimpleERC20} from "../util/SimpleERC20.sol"; import {SimpleERC721} from "../util/SimpleERC721.sol"; import {SimpleERC721Receiver} from "../util/SimpleERC721Receiver.sol"; -import {LibServerManager} from "../util/LibServerManager.sol"; import "forge-std/console.sol"; @@ -77,7 +77,7 @@ contract CartesiDAppTest is TestBase { ); event NewConsensus(IConsensus newConsensus); - constructor() { + function setUp() public { deployContracts(); generateOutputs(); writeInputs(); @@ -105,12 +105,12 @@ contract CartesiDAppTest is TestBase { emit OwnershipTransferred(address(this), _owner); // perform call to constructor - CartesiDApp newDApp = new CartesiDApp(consensus, _owner, _templateHash); + dapp = new CartesiDApp(consensus, _owner, _templateHash); // check set values - assertEq(address(newDApp.getConsensus()), address(consensus)); - assertEq(newDApp.owner(), _owner); - assertEq(newDApp.getTemplateHash(), _templateHash); + assertEq(address(dapp.getConsensus()), address(consensus)); + assertEq(dapp.owner(), _owner); + assertEq(dapp.getTemplateHash(), _templateHash); } // test notices @@ -495,35 +495,35 @@ contract CartesiDAppTest is TestBase { vm.assume(address(_newOwner) != address(0)); vm.assume(_nonZeroAddress != address(0)); - CartesiDApp newDApp = new CartesiDApp(consensus, _owner, _templateHash); + dapp = new CartesiDApp(consensus, _owner, _templateHash); IConsensus newConsensus = new SimpleConsensus(); // migrate fail if not called from owner vm.expectRevert("Ownable: caller is not the owner"); - newDApp.migrateToConsensus(newConsensus); + dapp.migrateToConsensus(newConsensus); // now impersonate owner vm.prank(_owner); - vm.expectEmit(false, false, false, true, address(newDApp)); + vm.expectEmit(false, false, false, true, address(dapp)); emit NewConsensus(newConsensus); - newDApp.migrateToConsensus(newConsensus); - assertEq(address(newDApp.getConsensus()), address(newConsensus)); + dapp.migrateToConsensus(newConsensus); + assertEq(address(dapp.getConsensus()), address(newConsensus)); // if owner changes, then original owner no longer can migrate consensus vm.prank(_owner); - newDApp.transferOwnership(_newOwner); + dapp.transferOwnership(_newOwner); vm.expectRevert("Ownable: caller is not the owner"); vm.prank(_owner); - newDApp.migrateToConsensus(consensus); + dapp.migrateToConsensus(consensus); // if new owner renounce ownership (give ownership to address 0) // no one will be able to migrate consensus vm.prank(_newOwner); - newDApp.renounceOwnership(); + dapp.renounceOwnership(); vm.expectRevert("Ownable: caller is not the owner"); vm.prank(_nonZeroAddress); - newDApp.migrateToConsensus(consensus); + dapp.migrateToConsensus(consensus); } // Store proof in storage