Skip to content

Commit

Permalink
chore(katana): clean up txn hash test (dojoengine#1941)
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy authored May 8, 2024
1 parent b68f9d1 commit 5a7ecd8
Showing 1 changed file with 18 additions and 36 deletions.
54 changes: 18 additions & 36 deletions crates/katana/primitives/src/utils/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,44 +311,32 @@ fn encode_da_mode(
#[cfg(test)]
mod tests {
use starknet::core::chain_id;
use starknet::macros::felt;

use super::*;

#[test]
fn test_compute_deploy_account_v1_transaction_hash() {
let contract_address = FieldElement::from_hex_be(
"0x0617e350ebed9897037bdef9a09af65049b85ed2e4c9604b640f34bffa152149",
)
.unwrap();
fn test_compute_deploy_account_v1_tx_hash() {
// Starknet mainnet tx hash: https://voyager.online/tx/0x3d013d17c20a5db05d5c2e06c948a4e0bf5ea5b851b15137316533ec4788b6b
let expected_hash =
felt!("0x3d013d17c20a5db05d5c2e06c948a4e0bf5ea5b851b15137316533ec4788b6b");

let contract_address =
felt!("0x0617e350ebed9897037bdef9a09af65049b85ed2e4c9604b640f34bffa152149");
let constructor_calldata = vec![
FieldElement::from_hex_be(
"0x33434ad846cdd5f23eb73ff09fe6fddd568284a0fb7d1be20ee482f044dabe2",
)
.unwrap(),
FieldElement::from_hex_be(
"0x79dc0da7c54b95f10aa182ad0a46400db63156920adb65eca2654c0945a463",
)
.unwrap(),
FieldElement::from_hex_be("0x2").unwrap(),
FieldElement::from_hex_be(
"0x43a8fbe19d5ace41a2328bb870143241831180eb3c3c48096642d63709c3096",
)
.unwrap(),
FieldElement::from_hex_be("0x0").unwrap(),
felt!("0x33434ad846cdd5f23eb73ff09fe6fddd568284a0fb7d1be20ee482f044dabe2"),
felt!("0x79dc0da7c54b95f10aa182ad0a46400db63156920adb65eca2654c0945a463"),
felt!("0x2"),
felt!("0x43a8fbe19d5ace41a2328bb870143241831180eb3c3c48096642d63709c3096"),
felt!("0x0"),
];
let class_hash = FieldElement::from_hex_be(
"0x025ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918",
)
.unwrap();
let salt = FieldElement::from_hex_be(
"0x43a8fbe19d5ace41a2328bb870143241831180eb3c3c48096642d63709c3096",
)
.unwrap();
let max_fee = FieldElement::from_hex_be("0x38d7ea4c68000").unwrap();
let class_hash = felt!("0x25ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918");
let salt = felt!("0x43a8fbe19d5ace41a2328bb870143241831180eb3c3c48096642d63709c3096");
let max_fee = felt!("0x38d7ea4c68000");
let chain_id = chain_id::MAINNET;
let nonce = FieldElement::ZERO;

let hash = compute_deploy_account_v1_tx_hash(
let actual_hash = compute_deploy_account_v1_tx_hash(
contract_address,
&constructor_calldata,
class_hash,
Expand All @@ -359,12 +347,6 @@ mod tests {
false,
);

assert_eq!(
hash,
FieldElement::from_hex_be(
"0x3d013d17c20a5db05d5c2e06c948a4e0bf5ea5b851b15137316533ec4788b6b"
)
.unwrap()
);
assert_eq!(actual_hash, expected_hash);
}
}

0 comments on commit 5a7ecd8

Please sign in to comment.