MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / test_version_mismatch

Function test_version_mismatch

tests/all/module_serialize.rs:16–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14
15#[test]
16fn test_version_mismatch() -> Result<()> {
17 let engine = Engine::default();
18 let buffer = serialize(&engine, "(module)")?;
19
20 let mut config = Config::new();
21 config
22 .module_version(ModuleVersionStrategy::Custom("custom!".to_owned()))
23 .unwrap();
24 let custom_version_engine = Engine::new(&config).unwrap();
25 match unsafe { Module::deserialize(&custom_version_engine, &buffer) } {
26 Ok(_) => bail!("expected deserialization to fail"),
27 Err(e) => assert!(
28 e.to_string()
29 .starts_with("Module was compiled with incompatible version")
30 ),
31 }
32
33 let mut config = Config::new();
34 config.module_version(ModuleVersionStrategy::None).unwrap();
35 let none_version_engine = Engine::new(&config).unwrap();
36 unsafe { Module::deserialize(&none_version_engine, &buffer) }
37 .expect("accepts the wasmtime versioned module");
38
39 let buffer = serialize(&custom_version_engine, "(module)")?;
40 unsafe { Module::deserialize(&none_version_engine, &buffer) }
41 .expect("accepts the custom versioned module");
42
43 Ok(())
44}
45
46#[test]
47#[cfg_attr(miri, ignore)]

Callers

nothing calls this directly

Calls 8

CustomClass · 0.85
OkFunction · 0.85
module_versionMethod · 0.80
serializeFunction · 0.70
newFunction · 0.50
deserializeFunction · 0.50
unwrapMethod · 0.45
expectMethod · 0.45

Tested by

no test coverage detected