diff --git a/src/program.rs b/src/program.rs index fe019dd1..b3df0c7e 100644 --- a/src/program.rs +++ b/src/program.rs @@ -415,39 +415,3 @@ macro_rules! declare_builtin_function { } }; } - -#[cfg(test)] -mod tests { - use super::*; - use crate::{syscalls, vm::TestContextObject}; - - #[test] - fn test_builtin_program_eq() { - let mut function_registry_a = - FunctionRegistry::>::default(); - function_registry_a - .register_function_hashed(*b"log", syscalls::SyscallString::vm) - .unwrap(); - function_registry_a - .register_function_hashed(*b"log_64", syscalls::SyscallU64::vm) - .unwrap(); - let mut function_registry_b = - FunctionRegistry::>::default(); - function_registry_b - .register_function_hashed(*b"log_64", syscalls::SyscallU64::vm) - .unwrap(); - function_registry_b - .register_function_hashed(*b"log", syscalls::SyscallString::vm) - .unwrap(); - let mut function_registry_c = - FunctionRegistry::>::default(); - function_registry_c - .register_function_hashed(*b"log_64", syscalls::SyscallU64::vm) - .unwrap(); - let builtin_program_a = BuiltinProgram::new_loader(Config::default(), function_registry_a); - let builtin_program_b = BuiltinProgram::new_loader(Config::default(), function_registry_b); - assert_eq!(builtin_program_a, builtin_program_b); - let builtin_program_c = BuiltinProgram::new_loader(Config::default(), function_registry_c); - assert_ne!(builtin_program_a, builtin_program_c); - } -} diff --git a/tests/vm.rs b/tests/vm.rs index a6f172b2..2c790890 100644 --- a/tests/vm.rs +++ b/tests/vm.rs @@ -1,7 +1,8 @@ use solana_sbpf::{ elf::Executable, - program::BuiltinProgram, - vm::{RuntimeEnvironmentSlot, TestContextObject}, + program::{BuiltinProgram, BuiltinFunction, FunctionRegistry}, + syscalls, + vm::{RuntimeEnvironmentSlot, TestContextObject, Config}, }; use std::{fs::File, io::Read, sync::Arc}; use test_utils::create_vm; @@ -49,3 +50,30 @@ fn test_runtime_environment_slots() { check_slot!(env, program_result, ProgramResult); check_slot!(env, memory_mapping, MemoryMapping); } + +#[test] +fn test_builtin_program_eq() { + let mut function_registry_a = FunctionRegistry::>::default(); + function_registry_a + .register_function_hashed(*b"log", syscalls::SyscallString::vm) + .unwrap(); + function_registry_a + .register_function_hashed(*b"log_64", syscalls::SyscallU64::vm) + .unwrap(); + let mut function_registry_b = FunctionRegistry::>::default(); + function_registry_b + .register_function_hashed(*b"log_64", syscalls::SyscallU64::vm) + .unwrap(); + function_registry_b + .register_function_hashed(*b"log", syscalls::SyscallString::vm) + .unwrap(); + let mut function_registry_c = FunctionRegistry::>::default(); + function_registry_c + .register_function_hashed(*b"log_64", syscalls::SyscallU64::vm) + .unwrap(); + let builtin_program_a = BuiltinProgram::new_loader(Config::default(), function_registry_a); + let builtin_program_b = BuiltinProgram::new_loader(Config::default(), function_registry_b); + assert_eq!(builtin_program_a, builtin_program_b); + let builtin_program_c = BuiltinProgram::new_loader(Config::default(), function_registry_c); + assert_ne!(builtin_program_a, builtin_program_c); +}