Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sneh1999 committed Nov 26, 2024
1 parent 62dbad6 commit 29d1104
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 53 deletions.
10 changes: 5 additions & 5 deletions src/bridge/SequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,12 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox
}

function addSequencerL2BatchFromOrigin(
uint256 sequenceNumber,
bytes calldata data,
uint256 afterDelayedMessagesRead,
uint256,
bytes calldata,
uint256,
IGasRefunder gasRefunder,
uint256 prevMessageCount,
uint256 newMessageCount
uint256,
uint256
) external refundsGas(gasRefunder, IReader4844(address(0))) {
revert Deprecated();
}
Expand Down
5 changes: 4 additions & 1 deletion src/mocks/EspressoTEEVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ pragma solidity ^0.8.0;
contract EspressoTEEVerifierMock {
constructor() {}

function verify(bytes calldata rawQuote) external view returns (bool success) {
function verify(
bytes calldata rawQuote,
bytes32 reportDataHash
) external view returns (bool success) {
return (true);
}
}
1 change: 0 additions & 1 deletion test/e2e/orbitChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
Inbox__factory,
RollupCore__factory,
RollupCreator__factory,
TransparentUpgradeableProxy__factory,
} from '../../build/types'
import { getLocalNetworks } from '../../scripts/testSetup'
import { applyAlias } from '../contract/utils'
Expand Down
24 changes: 1 addition & 23 deletions test/foundry/EspressoTEEVerifier.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,17 @@ contract EspressoTEEVerifierTest is Test {
vm.stopPrank();
}

/*
Test that the verify function returns sucess for a valid quote
*/
function testVerifyQuoteValid() public {
vm.startPrank(adminTEE);

string memory quotePath = "/test/foundry/configs/valid_quote.bin";
string memory quotePath = "/test/foundry/configs/attestation.bin";
string memory inputFile = string.concat(vm.projectRoot(), quotePath);
bytes memory sampleQuote = vm.readFileBinary(inputFile);
bool success = espressoTEEVerifier.verify(sampleQuote, reportDataHash);
assertEq(success, true);
vm.stopPrank();
}

/*
Test that the verify function returns false for an invalid quote
*/
function testVerifyQuoteInValid() public {
string memory quotePath = "/test/foundry/configs/incorrect_attestation_quote.bin";
string memory inputFile = string.concat(vm.projectRoot(), quotePath);
Expand All @@ -56,7 +50,6 @@ contract EspressoTEEVerifierTest is Test {
/**
Test incorrect report data hash
*/

function testIncorrectReportDataHash() public {
vm.startPrank(adminTEE);

Expand All @@ -67,9 +60,6 @@ contract EspressoTEEVerifierTest is Test {
assertEq(success, false);
}

/**
Test incorrect mrEnclave
*/
function testIncorrectMrEnclave() public {
vm.startPrank(adminTEE);

Expand All @@ -85,9 +75,6 @@ contract EspressoTEEVerifierTest is Test {
assertEq(success, false);
}

/**
Test incorrect mrSigner
*/
function testIncorrectMrSigner() public {
vm.startPrank(adminTEE);

Expand All @@ -103,9 +90,6 @@ contract EspressoTEEVerifierTest is Test {
assertEq(success, false);
}

/**
Test set owner
*/
function testSetOwner() public {
vm.startPrank(adminTEE);

Expand All @@ -115,9 +99,6 @@ contract EspressoTEEVerifierTest is Test {
vm.stopPrank();
}

/**
Test set mrEnclave
*/
function testSetMrEnclave() public {
vm.startPrank(adminTEE);

Expand All @@ -129,9 +110,6 @@ contract EspressoTEEVerifierTest is Test {
vm.stopPrank();
}

/**
Test set mrSigner
*/
function testSetMrSigner() public {
vm.startPrank(adminTEE);

Expand Down
26 changes: 3 additions & 23 deletions test/foundry/SequencerInbox.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "../../src/bridge/Bridge.sol";
import "../../src/bridge/SequencerInbox.sol";
import {ERC20Bridge} from "../../src/bridge/ERC20Bridge.sol";
import "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";
import {EspressoTEEVerifier} from "../../src/bridge/EspressoTEEVerifier.sol";
import {EspressoTEEVerifierMock} from "../../src/mocks/EspressoTEEVerifier.sol";
import {
TransparentUpgradeableProxy
} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
Expand Down Expand Up @@ -67,21 +67,15 @@ contract SequencerInboxTest is Test {
address adminTEE = address(141);
address fakeAddress = address(145);

EspressoTEEVerifier espressoTEEVerifier;
EspressoTEEVerifierMock espressoTEEVerifier;
V3QuoteVerifier quoteVerifier;
bytes sampleQuote;
bytes invalidQuote;

function setUp() public {
vm.startPrank(adminTEE);
vm.createSelectFork("https://rpc.ankr.com/eth_sepolia");

espressoTEEVerifier = new EspressoTEEVerifier(
mrEnclave,
mrSigner,
// Address of the deployed V3Verifier contract
address(0x6E64769A13617f528a2135692484B681Ee1a7169)
);
espressoTEEVerifier = new EspressoTEEVerifierMock();

string memory quotePath = "/test/foundry/configs/attestation.bin";
string memory inputFile = string.concat(vm.projectRoot(), quotePath);
Expand Down Expand Up @@ -531,20 +525,6 @@ contract SequencerInboxTest is Test {
subMessageCount + 1,
sampleQuote
);

// expect revert InvalidTEEAttestationQuote when quote is invalid
vm.expectRevert(abi.encodeWithSelector(InvalidTEEAttestationQuote.selector));
vm.prank(tx.origin);

seqInbox.addSequencerL2BatchFromOrigin(
sequenceNumber + 6,
data,
delayedMessagesRead,
IGasRefunder(address(0)),
subMessageCount,
subMessageCount + 1,
invalidQuote
);
}

function testPostUpgradeInitAlreadyInit() public returns (SequencerInbox, SequencerInbox) {
Expand Down

0 comments on commit 29d1104

Please sign in to comment.