GasBuiltin, as well as the amount of gas unused in
the local wallet.
Useful for asserting that a certain amount of gas was used.
Note: This function call costs exactly 2300 gas, so this may be ignored in calculations.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
GasBuiltin, as well as the amount of gas unused in
the local wallet.
Useful for asserting that a certain amount of gas was used.
Note: This function call costs exactly 2300 gas, so this may be ignored in calculations.
use core::testing::get_unspent_gas;
fn gas_heavy_function() {
// ... some gas-intensive code
}
fn test_gas_consumption() {
let gas_before = get_unspent_gas();
gas_heavy_function();
let gas_after = get_unspent_gas();
assert!(gas_after - gas_before u128 implicits(GasBuiltin) nopanic;
Was this page helpful?