Skip to content

Commit

Permalink
test(fixtures): add test helper to get panic reason
Browse files Browse the repository at this point in the history
  • Loading branch information
rymnc committed Dec 3, 2024
1 parent 7015214 commit 4776a7e
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions fuel-zkvm-primitives-test-fixtures/src/opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ use fuel_core_storage::vm_storage::IncreaseStorageKey;
use fuel_core_storage::{StorageAsMut, StorageAsRef};
use fuel_core_types::entities::contract::ContractUtxoInfo;
use fuel_core_types::fuel_crypto;
use fuel_core_types::fuel_tx::{AssetId, Bytes32};
use fuel_core_types::fuel_tx::{AssetId, Bytes32, Executable};
use fuel_zkvm_primitives_utils::vm::base::AsRepr;
use fuel_zkvm_primitives_utils::vm::blob::BlobInstruction;
use fuel_zkvm_primitives_utils::vm::contract::{ContractInstruction, ContractMetadata};
pub use fuel_zkvm_primitives_utils::vm::Instruction;
use fuels::prelude::Contract;
use fuels::{accounts::Account, prelude::WalletUnlocked, types::BlockHeight};
use fuels_core::types::coin::Coin;
use fuels_core::types::coin_type::CoinType;
use fuels_core::types::input::Input;
use fuels_core::types::output::Output;
use fuels_core::types::transaction_builders::{
Blob, BlobTransactionBuilder, BuildableTransaction, ScriptTransactionBuilder,
TransactionBuilder,
Expand All @@ -44,7 +48,10 @@ async fn send_script_transaction(
builder = builder.with_script_data(script_data);
}

if let Some(additional_inputs) = additional_inputs {
if let Some(mut additional_inputs) = additional_inputs {
let input_asset = wallet.get_asset_inputs_for_amount(*wallet.provider().unwrap().base_asset_id(), 0, None).await?;
additional_inputs.extend(input_asset.into_iter());

builder = builder.with_inputs(additional_inputs);
}

Expand Down Expand Up @@ -200,6 +207,21 @@ pub async fn start_node_with_transaction_and_produce_prover_input(
generate_input_at_block_height(fuel_node, tx_inclusion_block_height).await
}

// TODO: remove this when done debugging
#[cfg(test)]
mod local_tests {
use fuel_core_types::fuel_asm::PanicInstruction;
use fuels::types::Word;
use super::*;

#[test]
fn get_panic_readable() {
let r: Word = 160584292785717248u64;
let panic_readable = PanicInstruction::from(r);
println!("{panic_readable:?}");
}
}

#[allow(non_snake_case)]
#[cfg(test)]
mod tests {
Expand Down

0 comments on commit 4776a7e

Please sign in to comment.