Skip to content

Commit affddaa

Browse files
kariyclaude
andauthored
fix(test): handle TxnHashNotFound in db-compat test (#435)
The db-compat test has been failing since #392 bumped Bockifier to v0.16.0-rc.0, which introduced a breaking change in `TransactionExecutionInfo` struct serialization. The v1.6.0 test database contains traces in the old format that can no longer be deserialized, causing `trace_transaction` to return `TxnHashNotFound` instead of the trace data. This updates the test to accept `TxnHashNotFound` as a valid (expected) outcome for that call. The provider returns `None` on deserialization failure as a backward-compatibility measure: ```rust match self.0.get::<tables::TxTraces>(num) { Ok(Some(execution)) => Ok(Some(execution)), Ok(None) => Ok(None), // Treat decompress errors as non-existent for backward compatibility Err(DatabaseError::Codec(CodecError::Decompress(err))) => { warn!(tx_num = %num, %err, "Failed to deserialize transaction trace"); Ok(None) } Err(e) => Err(e.into()), } ``` --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2a76014 commit affddaa

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

tests/db-compat/src/main.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use katana_db::version::CURRENT_DB_VERSION;
33
use katana_node_bindings::Katana;
44
use katana_primitives::block::{BlockIdOrTag, ConfirmedBlockIdOrTag};
55
use katana_primitives::{address, felt};
6-
use katana_rpc_client::starknet::Client as StarknetClient;
6+
use katana_rpc_client::starknet::{Client as StarknetClient, Error as RpcError, StarknetApiError};
77

88
#[tokio::main]
99
async fn main() -> Result<()> {
@@ -60,7 +60,30 @@ async fn test_rpc_queries(client: &StarknetClient) {
6060
let _ = client.get_transaction_by_block_id_and_index(BlockIdOrTag::Number(1), 0).await.unwrap();
6161

6262
let tx_hash = felt!("0x722b80b0fd8e4cd177bb565ee73843ce5ffb8cc07114207cd4399cb4e00c9ac");
63-
let _ = client.trace_transaction(tx_hash).await.unwrap();
63+
// The v1.6.0 database contains TransactionExecutionInfo serialized with an older blockifier
64+
// format. Since #392 (https://github.com/dojoengine/katana/pull/392), the new blockifier
65+
// format is incompatible so deserialization fails and the provider returns None, which
66+
// surfaces as TxnHashNotFound.
67+
//
68+
// See the backward-compat handling in DbProvider::transaction_execution():
69+
//
70+
// ```
71+
// match self.0.get::<tables::TxTraces>(num) {
72+
// Ok(Some(execution)) => Ok(Some(execution)),
73+
// Ok(None) => Ok(None),
74+
// // Treat decompress errors as non-existent for backward compatibility
75+
// Err(DatabaseError::Codec(CodecError::Decompress(err))) => {
76+
// warn!(tx_num = %num, %err, "Failed to deserialize transaction trace");
77+
// Ok(None)
78+
// }
79+
// Err(e) => Err(e.into()),
80+
// }
81+
// ```
82+
match client.trace_transaction(tx_hash).await {
83+
Ok(_) => {}
84+
Err(RpcError::Starknet(StarknetApiError::TxnHashNotFound)) => {}
85+
Err(e) => panic!("unexpected error from trace_transaction: {e}"),
86+
}
6487
let _ = client.trace_block_transactions(ConfirmedBlockIdOrTag::Number(1)).await.unwrap();
6588

6689
let class_hash = felt!("0x685ed02eefa98fe7e208aa295042e9bbad8029b0d3d6f0ba2b32546efe0a1f9");

0 commit comments

Comments
 (0)