From 3d94c5e219d66ed517375d4d250128610f5714ed Mon Sep 17 00:00:00 2001 From: Feliciss <10203-feliciss@users.noreply.0xacab.org> Date: Mon, 2 Sep 2024 23:42:10 +0900 Subject: [PATCH] [gh-2287] add debug test case for transaction_validator.move. --- .../sources/transaction_validator.move | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/frameworks/rooch-framework/sources/transaction_validator.move b/frameworks/rooch-framework/sources/transaction_validator.move index 2b3a4ac4b8..c3476af3ac 100644 --- a/frameworks/rooch-framework/sources/transaction_validator.move +++ b/frameworks/rooch-framework/sources/transaction_validator.move @@ -23,6 +23,9 @@ module rooch_framework::transaction_validator { use rooch_framework::address_mapping; use rooch_framework::account_coin_store; use rooch_framework::builtin_validators; + use rooch_framework::bitcoin_address; + use std::vector; + use std::string; const MAX_U64: u128 = 18446744073709551615; @@ -175,4 +178,36 @@ module rooch_framework::transaction_validator { account_coin_store::deposit(gas_payment_account, refund_gas_coin); }; } + + #[test] + fun test_validate_success() { + let chain_id = chain_id::chain_id(); + std::debug::print(&chain_id); + let session_validator_id = session_validator::auth_validator_id(); + std::debug::print(&session_validator_id); + // let bitcoin_validator_id = bitcoin_validator::auth_validator_id(); + let authenticator_payload = vector::empty(); + std::debug::print(&authenticator_payload); + let tx_validate_result = validate(chain_id, session_validator_id, authenticator_payload); + std::debug::print(&tx_validate_result); + + let id = 1; + let module_address = @000000000003; + let module_name = string::utf8(b"rooch_framework::empty"); + let expected_auth_validator = auth_validator::new_auth_validator(id, module_address, module_name); + std::debug::print(&expected_auth_validator); + let expected_session_key = vector::empty(); + let expected_bitcoin_addr = bitcoin_address::from_string(&string::utf8(b"bc1p72fvqwm9w4wcsd205maky9qejf6dwa6qeku5f5vnu4phpp3vvpws0p2f4g")); + std::debug::print(&expected_bitcoin_addr); + + let auth_validator_id = 1; + let auth_validator = option::some(expected_auth_validator); + let session_key = option::some(expected_session_key); + let bitcoin_address = expected_bitcoin_addr; + + let expected_tx_validate_result = auth_validator::new_tx_validate_result(auth_validator_id, auth_validator, session_key, bitcoin_address); + std::debug::print(&expected_tx_validate_result); + + assert!(tx_validate_result == expected_tx_validate_result, 1000); + } }