Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavBreadless committed Dec 21, 2023
1 parent 0b238cd commit 80b1869
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions bootloader/tests/bootloader/bootloader_test.yul
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,51 @@ function TEST_simple_transaction() {
let innerTxDataOffset := add(txDataOffset, 0x20)
testing_assertEq(getGasPerPubdataByteLimit(innerTxDataOffset), 0xc350, "Invalid pubdata limit")
}

function TEST_getTransactionUpfrontOverhead() {
// For very large transactions it should be proportional to the memory,
// but for small ones, the transaction slots are more important

let smallTxOverhead := getTransactionUpfrontOverhead(32)
let largeTxOverhead := getTransactionUpfrontOverhead(1000000)

testing_assertEq(smallTxOverhead, TX_SLOT_OVERHEAD_GAS(), "Invalid small tx overhead")
testing_assertEq(largeTxOverhead, mul(1000000, MEMORY_OVERHEAD_GAS()), "Invalid small tx overhead")
}

function TEST_getFeeParams_HighPubdataPrice() {
// Under very large L1 gas price, the L2 base fee will start rising to ensure the
// boundary on the gasLimit

// 15k gwei L1 pubdata price
let veryHighL1PubdataPrice := 15000000000000
// 0.1 gwei L2 base fee
let l2GasPrice := 100000000

let baseFee, gasPricePerPubdata := getFeeParams(
veryHighL1PubdataPrice,
// 0.1 gwei L2 base fee
l2GasPrice
)

testing_assertEq(baseFee, div(veryHighL1PubdataPrice, MAX_L2_GAS_PER_PUBDATA()), "Invalid base fee")
testing_assertEq(gasPricePerPubdata, MAX_L2_GAS_PER_PUBDATA(), "Invalid gasPricePerPubdata")
}

function TEST_getFeeParams_LowPubdataPrice() {
// Under low to medium pubdata price, the baseFee is equal to the fair gas price,
// while the gas per pubdata pubdata is derived by strict division

// 0.2 gwei L1 pubdata price
let veryLowL1GasPrice := 200000000
// 0.1 gwei L2 base fee
let l2GasPrice := 100000000

let baseFee, gasPricePerPubdata := getFeeParams(
veryLowL1GasPrice,
l2GasPrice
)

testing_assertEq(baseFee, l2GasPrice, "Invalid base fee")
testing_assertEq(gasPricePerPubdata, div(veryLowL1GasPrice, l2GasPrice), "Invalid gasPricePerPubdata")
}

0 comments on commit 80b1869

Please sign in to comment.