From df39a38da58835784b6409bca3059b3a4130ab76 Mon Sep 17 00:00:00 2001 From: Gregory Edison Date: Thu, 8 Aug 2024 13:14:13 +0200 Subject: [PATCH] add failing test on chain id conversion --- .../src/implementation/blockifier/utils.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/katana/executor/src/implementation/blockifier/utils.rs b/crates/katana/executor/src/implementation/blockifier/utils.rs index 7d7044d41a..40b4742f1f 100644 --- a/crates/katana/executor/src/implementation/blockifier/utils.rs +++ b/crates/katana/executor/src/implementation/blockifier/utils.rs @@ -715,6 +715,24 @@ mod tests { assert_eq!(actual_id, id) } + #[test] + #[ignore = "The blockifier chain id conversion adds bytes for chain ids which don't have a valid utf8 representation"] + fn failing_blockifier_chain_id_conversion() { + let id = felt!("0xc72dd9d5e883e"); + + let katana_id = katana_primitives::chain::ChainId::Id(id); + let blockifier_id = to_blk_chain_id(katana_id); + + // Mimic how blockifier convert from ChainId to FieldElement. + // + // This is how blockifier pass the chain id to the contract through a syscall. + // https://github.com/dojoengine/blockifier/blob/f2246ce2862d043e4efe2ecf149a4cb7bee689cd/crates/blockifier/src/execution/syscalls/hint_processor.rs#L600-L602 + let actual_id = FieldElement::from_hex(blockifier_id.as_hex().as_str()).unwrap(); + + assert_eq!(actual_id, id) + } + + fn create_blockifier_call_info() -> CallInfo { let top_events = vec![OrderedEvent { order: 0,