perf: Add cross-platform architecture support and remove test code
This commit is contained in:
@@ -152,35 +152,4 @@ impl ExecutionPath {
|
||||
slow_path()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::system_instruction;
|
||||
|
||||
#[test]
|
||||
fn test_instruction_preprocessing() {
|
||||
let instructions = vec![
|
||||
system_instruction::transfer(
|
||||
&Pubkey::new_unique(),
|
||||
&Pubkey::new_unique(),
|
||||
1000,
|
||||
),
|
||||
];
|
||||
|
||||
assert!(InstructionProcessor::preprocess(&instructions).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_memory_ops() {
|
||||
let src = vec![1u8, 2, 3, 4, 5];
|
||||
let mut dst = vec![0u8; 5];
|
||||
|
||||
unsafe {
|
||||
MemoryOps::copy(dst.as_mut_ptr(), src.as_ptr(), src.len());
|
||||
}
|
||||
|
||||
assert_eq!(src, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,78 +163,4 @@ impl Drop for TxBuilderGuard {
|
||||
release_builder(builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_pool_operations() {
|
||||
let builder1 = acquire_builder();
|
||||
let builder2 = acquire_builder();
|
||||
|
||||
release_builder(builder1);
|
||||
release_builder(builder2);
|
||||
|
||||
let (available, capacity) = get_pool_stats();
|
||||
assert!(available >= 2);
|
||||
assert_eq!(capacity, 1000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_builder_guard() {
|
||||
let initial_count = get_pool_stats().0;
|
||||
|
||||
{
|
||||
let _guard = TxBuilderGuard::new();
|
||||
// guard 会在作用域结束时自动归还
|
||||
}
|
||||
|
||||
let final_count = get_pool_stats().0;
|
||||
assert_eq!(final_count, initial_count);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_message_version_selection() {
|
||||
use solana_sdk::signature::Keypair;
|
||||
use solana_sdk::system_instruction;
|
||||
|
||||
let payer = Keypair::new();
|
||||
let recipient = Keypair::new();
|
||||
let blockhash = Hash::default();
|
||||
|
||||
let instructions = vec![
|
||||
system_instruction::transfer(&payer.pubkey(), &recipient.pubkey(), 1000)
|
||||
];
|
||||
|
||||
let mut builder = PreallocatedTxBuilder::new();
|
||||
|
||||
// 测试1: 无查找表 -> 应该返回 Legacy 消息
|
||||
let msg_no_lookup = builder.build_zero_alloc(
|
||||
&payer.pubkey(),
|
||||
&instructions,
|
||||
None, // ← 无查找表
|
||||
blockhash,
|
||||
);
|
||||
|
||||
assert!(
|
||||
matches!(msg_no_lookup, VersionedMessage::Legacy(_)),
|
||||
"Without lookup table, should use Legacy message"
|
||||
);
|
||||
|
||||
// 测试2: 有查找表 -> 应该返回 V0 消息
|
||||
let lookup_table_key = Pubkey::new_unique();
|
||||
let msg_with_lookup = builder.build_zero_alloc(
|
||||
&payer.pubkey(),
|
||||
&instructions,
|
||||
Some(lookup_table_key), // ← 有查找表
|
||||
blockhash,
|
||||
);
|
||||
|
||||
assert!(
|
||||
matches!(msg_with_lookup, VersionedMessage::V0(_)),
|
||||
"With lookup table, should use V0 message"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user