diag: also test through aldabra's hex_decode
This commit is contained in:
parent
df61535d0f
commit
285c6e5a84
1 changed files with 17 additions and 3 deletions
|
|
@ -20,9 +20,10 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
|
use aldabra_core::hex_decode as aldabra_hex_decode;
|
||||||
use pallas_addresses::Address;
|
use pallas_addresses::Address;
|
||||||
use pallas_txbuilder::{BuildConway, Input, Output as TxOutput, ScriptKind, StagingTransaction};
|
|
||||||
use pallas_crypto::hash::Hash;
|
use pallas_crypto::hash::Hash;
|
||||||
|
use pallas_txbuilder::{BuildConway, Input, Output as TxOutput, ScriptKind, StagingTransaction};
|
||||||
|
|
||||||
fn hex_to_bytes(s: &str) -> Vec<u8> {
|
fn hex_to_bytes(s: &str) -> Vec<u8> {
|
||||||
let s = s.trim();
|
let s = s.trim();
|
||||||
|
|
@ -51,11 +52,24 @@ fn main() {
|
||||||
let path = env::var("ALDABRA_REPRO_HEX")
|
let path = env::var("ALDABRA_REPRO_HEX")
|
||||||
.expect("set ALDABRA_REPRO_HEX to a file containing the script 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 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!(
|
println!(
|
||||||
"input script: {} bytes ({} hex chars)",
|
"input script: {} bytes ({} hex chars)",
|
||||||
script_bytes.len(),
|
script_bytes.len(),
|
||||||
hex.trim().len()
|
trimmed.len()
|
||||||
);
|
);
|
||||||
|
|
||||||
let dummy_tx_hash: Hash<32> = Hash::new([0u8; 32]);
|
let dummy_tx_hash: Hash<32> = Hash::new([0u8; 32]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue