diff --git a/crates/aldabra-dao/examples/repro_script_corruption.rs b/crates/aldabra-dao/examples/repro_script_corruption.rs index 240f478..8b623c0 100644 --- a/crates/aldabra-dao/examples/repro_script_corruption.rs +++ b/crates/aldabra-dao/examples/repro_script_corruption.rs @@ -20,9 +20,10 @@ use std::env; use std::fs; +use aldabra_core::hex_decode as aldabra_hex_decode; use pallas_addresses::Address; -use pallas_txbuilder::{BuildConway, Input, Output as TxOutput, ScriptKind, StagingTransaction}; use pallas_crypto::hash::Hash; +use pallas_txbuilder::{BuildConway, Input, Output as TxOutput, ScriptKind, StagingTransaction}; fn hex_to_bytes(s: &str) -> Vec { let s = s.trim(); @@ -51,11 +52,24 @@ fn main() { let path = env::var("ALDABRA_REPRO_HEX") .expect("set ALDABRA_REPRO_HEX to a file containing the script hex"); let hex = fs::read_to_string(&path).expect("read hex file"); - let script_bytes = hex_to_bytes(&hex); + let trimmed = hex.trim(); + let script_bytes_local = hex_to_bytes(trimmed); + let script_bytes_aldabra = aldabra_hex_decode(trimmed).expect("aldabra hex_decode"); + println!( + "input hex chars: {} | local hex_to_bytes: {} bytes | aldabra hex_decode: {} bytes", + trimmed.len(), + script_bytes_local.len(), + script_bytes_aldabra.len() + ); + assert_eq!( + script_bytes_local, script_bytes_aldabra, + "local and aldabra decoders must agree" + ); + let script_bytes = script_bytes_aldabra; println!( "input script: {} bytes ({} hex chars)", script_bytes.len(), - hex.trim().len() + trimmed.len() ); let dummy_tx_hash: Hash<32> = Hash::new([0u8; 32]);