integration: engine config as a dependency for testing against different backends

Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
Cyrill Leutwiler
2024-03-25 11:38:35 +01:00
parent 2327a58213
commit a400286a3a
2 changed files with 6 additions and 6 deletions
+4 -4
View File
@@ -36,7 +36,7 @@ mod tests {
fn flipper() {
let code = crate::compile_blob("Flipper", include_str!("../contracts/flipper.sol"));
let state = State::new(0xcde4efa9u32.to_be_bytes().to_vec());
let (instance, export) = mock_runtime::prepare(&code);
let (instance, export) = mock_runtime::prepare(&code, None);
let state = crate::mock_runtime::call(state, &instance, export);
assert_eq!(state.output.flags, 0);
@@ -66,7 +66,7 @@ mod tests {
let input = TestSha3::testCall::new((param.to_string(),)).abi_encode();
let state = State::new(input);
let (instance, export) = mock_runtime::prepare(&code);
let (instance, export) = mock_runtime::prepare(&code, None);
let state = crate::mock_runtime::call(state, &instance, export);
assert_eq!(state.output.flags, 0);
@@ -94,7 +94,7 @@ mod tests {
input.extend_from_slice(&param.to_be_bytes::<32>());
let state = State::new(input);
let (instance, export) = mock_runtime::prepare(&code);
let (instance, export) = mock_runtime::prepare(&code, None);
let state = crate::mock_runtime::call(state, &instance, export);
assert_eq!(state.output.flags, 0);
@@ -114,7 +114,7 @@ mod tests {
input.extend_from_slice(&param.to_be_bytes::<32>());
let state = State::new(input);
let (instance, export) = mock_runtime::prepare(&code);
let (instance, export) = mock_runtime::prepare(&code, None);
let state = crate::mock_runtime::call(state, &instance, export);
assert_eq!(state.output.flags, 0);
+2 -2
View File
@@ -192,10 +192,10 @@ fn link_host_functions(engine: &Engine) -> Linker<State> {
linker
}
pub fn prepare(code: &[u8]) -> (InstancePre<State>, ExportIndex) {
pub fn prepare(code: &[u8], config: Option<Config>) -> (InstancePre<State>, ExportIndex) {
let blob = ProgramBlob::parse(code).unwrap();
let engine = Engine::new(&Config::new()).unwrap();
let engine = Engine::new(&config.unwrap_or_default()).unwrap();
let mut module_config = ModuleConfig::new();
module_config.set_gas_metering(Some(GasMeteringKind::Sync));