diff --git a/packages/client/src/test.cairo b/packages/client/src/test.cairo index 87cde83d..6f70e0e5 100644 --- a/packages/client/src/test.cairo +++ b/packages/client/src/test.cairo @@ -1,5 +1,4 @@ use core::serde::Serde; -use core::testing::get_available_gas; use consensus::types::block::Block; use consensus::types::chain_state::{ChainState, BlockValidatorImpl}; use consensus::types::utxo_set::{UtxoSet, UtxoSetTrait}; @@ -42,7 +41,6 @@ struct UtreexoArgs { /// Prints result to the stdout. fn main(arguments: Array) -> Array { println!("Running integration test... "); - let mut gas_before = get_available_gas(); let mut args = arguments.span(); let Args { @@ -55,7 +53,7 @@ fn main(arguments: Array) -> Array { match chain_state.validate_and_apply(block, ref utxo_set, execute_script) { Result::Ok(new_chain_state) => { chain_state = new_chain_state; }, Result::Err(err) => { - println!("FAIL: gas_spent={} error='{}'", gas_before - get_available_gas(), err); + println!("FAIL: error='{}'", err); panic!(); }, } @@ -63,8 +61,7 @@ fn main(arguments: Array) -> Array { if chain_state != expected_chain_state { println!( - "FAIL: gas_spent={} error='expected chain state {:?}, actual {:?}'", - gas_before - get_available_gas(), + "FAIL: error='expected chain state {:?}, actual {:?}'", expected_chain_state, chain_state, ); @@ -72,7 +69,7 @@ fn main(arguments: Array) -> Array { } if let Result::Err(err) = utxo_set.finalize() { - println!("FAIL: gas_spent={} error='{}'", gas_before - get_available_gas(), err); + println!("FAIL: error='{}'", err); panic!(); } @@ -80,7 +77,7 @@ fn main(arguments: Array) -> Array { match state.verify_and_delete(@proof, utxo_set.leaves_to_delete.span()) { Result::Ok(new_state) => { state = new_state; }, Result::Err(err) => { - println!("FAIL: gas_spent={} error='{:?}'", gas_before - get_available_gas(), err); + println!("FAIL: error='{:?}'", err); panic!(); }, } @@ -89,8 +86,7 @@ fn main(arguments: Array) -> Array { if state != expected_state { println!( - "FAIL: gas_spent={} error='expected utreexo state {:?}, actual {:?}'", - gas_before - get_available_gas(), + "FAIL: error='expected utreexo state {:?}, actual {:?}'", expected_state, state, ); @@ -98,7 +94,7 @@ fn main(arguments: Array) -> Array { } } - println!("OK: gas_spent={}", gas_before - get_available_gas()); + println!("OK"); array![] } diff --git a/scripts/data/integration_tests.sh b/scripts/data/integration_tests.sh index 944d7779..58599ec4 100755 --- a/scripts/data/integration_tests.sh +++ b/scripts/data/integration_tests.sh @@ -63,24 +63,24 @@ for test_file in "${test_files[@]}"; do else arguments_file="$(dirname "$test_file")/.arguments-$(basename "$test_file")" python ../../scripts/data/format_args.py --input_file ${test_file} $([[ $execute_scripts -eq 1 ]] && echo "--execute_script") > $arguments_file - output=$(scarb cairo-run --no-build --function main --arguments-file $arguments_file) - gas_spent=$(echo $output | grep -o 'gas_spent=[0-9]*' | sed 's/gas_spent=//') + output=$(scarb cairo-run --no-build --function main --print-resource-usage --arguments-file $arguments_file) + steps=$(echo $output | grep -o 'steps: [0-9]*' | sed 's/steps: //') if [[ "$nocapture" -eq 1 ]]; then echo -e "\n$output" fi if [[ "$output" == *"FAIL"* ]]; then - echo -e "${RED} fail ${RESET}(gas usage est.: $gas_spent)" + echo -e "${RED} fail ${RESET}(steps: $steps)" num_fail=$((num_fail + 1)) error=$(echo $output | grep -o "error='[^']*'" | sed "s/error=//") failures+="\t$test_file — Panicked with $error\n" elif [[ "$output" == *"OK"* ]]; then - echo -e "${GREEN} ok ${RESET}(gas usage est.: $gas_spent)" + echo -e "${GREEN} ok ${RESET}(steps: $steps)" num_ok=$((num_ok + 1)) rm $arguments_file else - echo -e "${RED} fail ${RESET}(gas usage est.: 0)" + echo -e "${RED} fail ${RESET}" num_fail=$((num_fail + 1)) error=$(echo "$output" | sed '1d' | tr '\n' ' ' | sed 's/[[:space:]]\+/ /g') #spellchecker:disable-line failures+="\t$test_file — $error\n"