diff --git a/polyjuice-tests/src/helper.rs b/polyjuice-tests/src/helper.rs index d9fcbe12..08777697 100644 --- a/polyjuice-tests/src/helper.rs +++ b/polyjuice-tests/src/helper.rs @@ -22,7 +22,7 @@ use gw_traits::CodeStore; use gw_types::{ bytes::Bytes, core::{AllowedContractType, AllowedEoaType, ScriptHashType}, - offchain::{RunResult, RunResultCycles}, + offchain::{RunResult, CycleMeter}, packed::{ AllowedTypeHash, BatchSetMapping, BlockInfo, Fee, LogItem, RawL2Transaction, RollupConfig, Script, SetMapping, Uint64, @@ -725,7 +725,7 @@ pub(crate) fn create_eth_eoa_account( (account_id, script_hash) } -pub(crate) fn check_cycles(l2_tx_label: &str, cycles: RunResultCycles, warning_cycles: u64) { +pub(crate) fn check_cycles(l2_tx_label: &str, cycles: CycleMeter, warning_cycles: u64) { if POLYJUICE_GENERATOR_NAME.contains("_log") { return; // disable cycles check } diff --git a/polyjuice-tests/src/test_cases/create2.rs b/polyjuice-tests/src/test_cases/create2.rs index a156ab41..55838ae3 100644 --- a/polyjuice-tests/src/test_cases/create2.rs +++ b/polyjuice-tests/src/test_cases/create2.rs @@ -100,7 +100,7 @@ fn test_create2() { // [Create2Impl.deploy(...)] used cycles: 1197555 < 1230K helper::check_cycles( "Create2Impl.deploy(...)", - run_result.cycles, + run_result.cycles.to_owned(), 1_750_000, ); state.finalise().expect("update state"); diff --git a/polyjuice-tests/src/test_cases/pre_compiled_contracts.rs b/polyjuice-tests/src/test_cases/pre_compiled_contracts.rs index 5e4ea63c..36de6bf2 100644 --- a/polyjuice-tests/src/test_cases/pre_compiled_contracts.rs +++ b/polyjuice-tests/src/test_cases/pre_compiled_contracts.rs @@ -265,14 +265,14 @@ fn test_bn256_pairing() -> anyhow::Result<()> { .to_id(contract_account_id.pack()) .args(Bytes::from(args).pack()) .build(); - let db = store.begin_transaction(); + let db = &store.begin_transaction(); let tip_block_hash = db.get_tip_block_hash().unwrap(); let t = std::time::Instant::now(); let run_result = generator .execute_transaction( &gw_store::chain_view::ChainView::new(&db, tip_block_hash), - &state, + &mut state, &new_block_info(block_producer.clone(), block_number, 0), &raw_tx, L2TX_MAX_CYCLES, @@ -282,7 +282,7 @@ fn test_bn256_pairing() -> anyhow::Result<()> { // time consumed println!("[Bn256Pairing] {case_name} elapsed {}ms", t.elapsed().as_millis()); - crate::helper::print_gas_used(case_name, &run_result.write.logs); + crate::helper::print_gas_used(case_name, &run_result.logs); assert_eq!(run_result.exit_code, crate::constant::EVMC_SUCCESS); assert_eq!( @@ -290,7 +290,7 @@ fn test_bn256_pairing() -> anyhow::Result<()> { hex::decode(expected_output_hex).unwrap() ); - crate::helper::check_cycles(case_name, run_result.cycles, 860_000 + input_len / 192 * 34_000 * 3); + crate::helper::check_cycles(case_name, run_result.cycles, 1_320_000 + input_len / 192 * 34_000 * 3); } Ok(()) } @@ -346,12 +346,12 @@ fn test_bn256_add() -> anyhow::Result<()> { .to_id(contract_account_id.pack()) .args(Bytes::from(args).pack()) .build(); - let db = store.begin_transaction(); + let db = &store.begin_transaction(); let tip_block_hash = db.get_tip_block_hash().unwrap(); let run_result = generator .execute_transaction( &gw_store::chain_view::ChainView::new(&db, tip_block_hash), - &state, + &mut state, &new_block_info(block_producer.clone(), block_number, 0), &raw_tx, L2TX_MAX_CYCLES, @@ -457,14 +457,14 @@ fn test_bn256_add() -> anyhow::Result<()> { .to_id(contract_account_id.pack()) .args(Bytes::from(args).pack()) .build(); - let db = store.begin_transaction(); + let db = &store.begin_transaction(); let tip_block_hash = db.get_tip_block_hash().unwrap(); let t = std::time::Instant::now(); let run_result = generator .execute_transaction( &gw_store::chain_view::ChainView::new(&db, tip_block_hash), - &state, + &mut state, &new_block_info(block_producer.clone(), block_number, 0), &raw_tx, L2TX_MAX_CYCLES, @@ -474,7 +474,7 @@ fn test_bn256_add() -> anyhow::Result<()> { // time consumed println!("[Bn256Add] {case_name} elapsed {}ms", t.elapsed().as_millis()); - crate::helper::print_gas_used(case_name, &run_result.write.logs); + crate::helper::print_gas_used(case_name, &run_result.logs); assert_eq!(run_result.exit_code, crate::constant::EVMC_SUCCESS); assert_eq!( @@ -538,12 +538,12 @@ fn test_bn256_scalar_mul() -> anyhow::Result<()> { .to_id(contract_account_id.pack()) .args(Bytes::from(args).pack()) .build(); - let db = store.begin_transaction(); + let db = &store.begin_transaction(); let tip_block_hash = db.get_tip_block_hash().unwrap(); let run_result = generator .execute_transaction( &gw_store::chain_view::ChainView::new(&db, tip_block_hash), - &state, + &mut state, &new_block_info(block_producer.clone(), block_number, 0), &raw_tx, L2TX_MAX_CYCLES, @@ -668,14 +668,14 @@ fn test_bn256_scalar_mul() -> anyhow::Result<()> { .to_id(contract_account_id.pack()) .args(Bytes::from(args).pack()) .build(); - let db = store.begin_transaction(); + let db = &store.begin_transaction(); let tip_block_hash = db.get_tip_block_hash().unwrap(); let t = std::time::Instant::now(); let run_result = generator .execute_transaction( &gw_store::chain_view::ChainView::new(&db, tip_block_hash), - &state, + &mut state, &new_block_info(block_producer.clone(), block_number, 0), &raw_tx, L2TX_MAX_CYCLES, @@ -684,7 +684,7 @@ fn test_bn256_scalar_mul() -> anyhow::Result<()> { .expect(case_name); // time consumed println!("[bn256ScalarMul] {case_name} elapsed {}ms", t.elapsed().as_millis()); - crate::helper::print_gas_used(case_name, &run_result.write.logs); + crate::helper::print_gas_used(case_name, &run_result.logs); assert_eq!(run_result.exit_code, crate::constant::EVMC_SUCCESS); assert_eq!(