Commit 43910748 authored by Maurelian's avatar Maurelian Committed by Kelvin Fichter

test(contracts): Assert lower bound on gas costs.

Although we're quite happy when the CTC gets cheaper, we want to know about it
and lock-in the savings.
parent 9142149a
......@@ -163,7 +163,12 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => {
'Non-calldata overhead gas cost per transaction:',
(gasUsed - fixedCalldataCost) / numTxs
)
expectApprox(gasUsed, 1_605_796, { upperPercentDeviation: 0 })
expectApprox(gasUsed, 1_605_796, {
upperPercentDeviation: 0,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value!
lowerPercentDeviation: 1,
})
}).timeout(10_000_000)
it('200 transactions in 200 contexts', async () => {
......@@ -206,7 +211,12 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => {
'Non-calldata overhead gas cost per transaction:',
(gasUsed - fixedCalldataCost) / numTxs
)
expectApprox(gasUsed, 1_739_811, { upperPercentDeviation: 0 })
expectApprox(gasUsed, 1_739_811, {
upperPercentDeviation: 0,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value!
lowerPercentDeviation: 1,
})
}).timeout(10_000_000)
it('100 Sequencer transactions and 100 Queue transactions in 100 contexts', async () => {
......@@ -287,7 +297,12 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => {
console.log('Benchmark complete.')
console.log('Gas used:', gasUsed)
expectApprox(gasUsed, 217_615, { upperPercentDeviation: 0 })
expectApprox(gasUsed, 217_615, {
upperPercentDeviation: 0,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value!
lowerPercentDeviation: 1,
})
})
it('cost to enqueue a transaction below the prepaid threshold', async () => {
......@@ -304,7 +319,12 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => {
console.log('Benchmark complete.')
console.log('Gas used:', gasUsed)
expectApprox(gasUsed, 156_711, { upperPercentDeviation: 0 })
expectApprox(gasUsed, 156_711, {
upperPercentDeviation: 0,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value!
lowerPercentDeviation: 1,
})
})
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment