Skip to content

Commit 3fbd386

Browse files
committed
Added test
1 parent 8d0b4f6 commit 3fbd386

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

crates/lib/src/transaction/versioned_transaction.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,58 @@ mod tests {
893893
assert_eq!(inner_instructions[0].data, vec![10, 20, 30]);
894894
}
895895

896+
#[tokio::test]
897+
async fn test_fetch_inner_instructions_with_sig_verify_false() {
898+
let config = setup_test_config();
899+
let _m = setup_config_mock(config);
900+
901+
let keypair = Keypair::new();
902+
let instruction = Instruction::new_with_bytes(
903+
Pubkey::new_unique(),
904+
&[1, 2, 3],
905+
vec![AccountMeta::new(keypair.pubkey(), true)],
906+
);
907+
let message =
908+
VersionedMessage::Legacy(Message::new(&[instruction], Some(&keypair.pubkey())));
909+
let transaction = VersionedTransaction::try_new(message, &[&keypair]).unwrap();
910+
911+
// Mock RPC client with inner instructions
912+
let inner_instruction_data = bs58::encode(&[10, 20, 30]).into_string();
913+
let mut mocks = HashMap::new();
914+
mocks.insert(
915+
RpcRequest::SimulateTransaction,
916+
json!({
917+
"context": { "slot": 1 },
918+
"value": {
919+
"err": null,
920+
"logs": [],
921+
"accounts": null,
922+
"unitsConsumed": 1000,
923+
"innerInstructions": [
924+
{
925+
"index": 0,
926+
"instructions": [
927+
{
928+
"programIdIndex": 1,
929+
"accounts": [0],
930+
"data": inner_instruction_data
931+
}
932+
]
933+
}
934+
]
935+
}
936+
}),
937+
);
938+
let rpc_client = RpcMockBuilder::new().with_custom_mocks(mocks).build();
939+
940+
let mut resolved = VersionedTransactionResolved::from_kora_built_transaction(&transaction);
941+
let inner_instructions =
942+
resolved.fetch_inner_instructions(&rpc_client, false).await.unwrap();
943+
944+
assert_eq!(inner_instructions.len(), 1);
945+
assert_eq!(inner_instructions[0].data, vec![10, 20, 30]);
946+
}
947+
896948
#[tokio::test]
897949
async fn test_get_or_parse_system_instructions() {
898950
let config = setup_test_config();

0 commit comments

Comments
 (0)