Skip to content

Commit

Permalink
Make existing tests work with feeTokenPricer
Browse files Browse the repository at this point in the history
  • Loading branch information
gvladika committed Sep 20, 2024
1 parent a6a3f55 commit f3eb844
Showing 1 changed file with 43 additions and 39 deletions.
82 changes: 43 additions & 39 deletions test/foundry/SequencerInbox.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -158,48 +158,46 @@ contract SequencerInboxTest is Test {
bytes32 delayedAcc = bridge.delayedInboxAccs(delayedMessagesRead - 1);
bytes32 afterAcc = keccak256(abi.encodePacked(beforeAcc, dataHash, delayedAcc));

if (!isUsingFeeToken) {
uint256 expectedReportedExtraGas = 0;
if (hostChainIsArbitrum) {
// set 0.1 gwei basefee
uint256 basefee = 100000000;
vm.fee(basefee);
// 30 gwei TX L1 fees
uint256 l1Fees = 30000000000;
vm.mockCall(
address(0x6c),
abi.encodeWithSignature("getCurrentTxL1GasFees()"),
abi.encode(l1Fees)
);
expectedReportedExtraGas = l1Fees / basefee;
}

bytes memory spendingReportMsg = abi.encodePacked(
block.timestamp,
msg.sender,
dataHash,
sequenceNumber,
block.basefee,
uint64(expectedReportedExtraGas)
uint256 expectedReportedExtraGas = 0;
if (hostChainIsArbitrum) {
// set 0.1 gwei basefee
uint256 basefee = 100000000;
vm.fee(basefee);
// 30 gwei TX L1 fees
uint256 l1Fees = 30000000000;
vm.mockCall(
address(0x6c),
abi.encodeWithSignature("getCurrentTxL1GasFees()"),
abi.encode(l1Fees)
);
expectedReportedExtraGas = l1Fees / basefee;
}

// spending report
vm.expectEmit();
emit MessageDelivered(
delayedMessagesRead,
delayedAcc,
address(seqInbox),
L1MessageType_batchPostingReport,
tx.origin,
keccak256(spendingReportMsg),
block.basefee,
uint64(block.timestamp)
);
bytes memory spendingReportMsg = abi.encodePacked(
block.timestamp,
msg.sender,
dataHash,
sequenceNumber,
block.basefee,
uint64(expectedReportedExtraGas)
);

// spending report event in seq inbox
vm.expectEmit();
emit InboxMessageDelivered(delayedMessagesRead, spendingReportMsg);
}
// spending report
vm.expectEmit();
emit MessageDelivered(
delayedMessagesRead,
delayedAcc,
address(seqInbox),
L1MessageType_batchPostingReport,
tx.origin,
keccak256(spendingReportMsg),
block.basefee,
uint64(block.timestamp)
);

// spending report event in seq inbox
vm.expectEmit();
emit InboxMessageDelivered(delayedMessagesRead, spendingReportMsg);

// sequencer batch delivered
vm.expectEmit();
Expand Down Expand Up @@ -384,6 +382,12 @@ contract SequencerInboxTest is Test {

expectEvents(IBridge(address(bridge)), seqInbox, data, true, true);

address feeTokenPricer = address(seqInbox.feeTokenPricer());
vm.mockCall(
feeTokenPricer,
abi.encodeWithSelector(IFeeTokenPricer.getExchangeRate.selector),
abi.encode(uint256(1e18))
);
vm.prank(tx.origin);
seqInbox.addSequencerL2BatchFromOrigin(
sequenceNumber,
Expand Down

0 comments on commit f3eb844

Please sign in to comment.