Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bootloader setters tests #1049

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,72 @@ function TEST_systemLogKeys() {
testing_assertEq(numberOfLayer1TxsLogKey, 6, "Invalid num layer 1 txns log key")
testing_assertEq(protocolUpgradeTxHashKey, 13, "Invalid protocol upgrade txn hash log key")
}

function TEST_setTxOrigin() {
let newTxOrigin := 0
setTxOrigin(newTxOrigin)

testing_assertEq(newTxOrigin, mload(4), "Invalid Tx Origin")
}

function TEST_setGasPrice() {
let newGasPrice := 10
setGasPrice(newGasPrice)

testing_assertEq(newGasPrice, mload(4), "Invalid gas price")
}

function TEST_setPubdataInfo() {
let txPtr := TX_DESCRIPTION_BEGIN_BYTE()
let txDataOffset := mload(add(txPtr, 32))
let innerTxDataOffset := add(txDataOffset, 32)
let newGasPerPubdata := getGasPerPubdataByteLimit(innerTxDataOffset)
let basePubdataSpent := getPubdataCounter()

setPubdataInfo(newGasPerPubdata, basePubdataSpent)
}

function TEST_setNewBatch() {
let prevBatchHash := mload(32)
let newTimestamp := mload(64)
let newBatchNumber := mload(96)
let baseFee := 10

setNewBatch(prevBatchHash, newTimestamp, newBatchNumber, baseFee)

assertEq(baseFee, basefee(), "Invalid base fee")
}

function TEST_setL2Block() {
let txId := 0

setL2Block(txId)
}

function TEST_setL2BlockRevert() {
let txId := 1

testing_testWillFailWith(25)
setL2Block(txId)
}

function TEST_setContextVal() {
let selector := 0xbf1fe42000000000000000000000000000000000000000000000000000000000
let value := 10
mstore(0, selector)
mstore(4, value)

let expected := call(
gas(),
SYSTEM_CONTEXT_ADDR(),
0,
0,
36,
0,
0
)

let returnValue := setContextVal(selector, value)

testing_assertEq(expected, returnValue, "Invalid context value")
}