#![doc(hidden)]
#[must_use]
pub fn metadata_wat(name: &str) -> String {
assert_eq!(name.len(), 3, "test fixture only supports 3-char names");
let abi = rustledger_plugin_types::ABI_VERSION;
format!(
r#"
(module
(memory (export "memory") 1)
;; 0x92 fixarray-2, 0xa3 fixstr-3 "<name>", 0xa3 fixstr-3 "tst"
(data (i32.const 0) "\92\a3{name}\a3tst")
(global $bump (mut i32) (i32.const 1024))
(func (export "alloc") (param i32) (result i32) global.get $bump)
(func (export "metadata") (result i64) i64.const 9)
(func (export "identify") (param i32 i32) (result i64) i64.const 0)
(func (export "extract") (param i32 i32) (result i64) i64.const 0)
(func (export "extract_enriched") (param i32 i32) (result i64) i64.const 0)
(func (export "__rustledger_abi_version") (result i32) i32.const {abi})
)
"#
)
}
#[must_use]
pub fn identifying_wat(name: &str) -> String {
assert_eq!(name.len(), 3, "test fixture only supports 3-char names");
let abi = rustledger_plugin_types::ABI_VERSION;
format!(
r#"
(module
(memory (export "memory") 1)
;; Metadata at offset 0 (9 bytes): fixarray-2 + name + "tst"
(data (i32.const 0) "\92\a3{name}\a3tst")
;; IdentifyOutput true at offset 16 (2 bytes): fixarray-1 + true
(data (i32.const 16) "\91\c3")
(global $bump (mut i32) (i32.const 1024))
(func (export "alloc") (param i32) (result i32) global.get $bump)
(func (export "metadata") (result i64) i64.const 9)
;; identify: ptr=16, len=2 — packed (16 << 32) | 2
(func (export "identify") (param i32 i32) (result i64) i64.const 0x10_0000_0002)
(func (export "extract") (param i32 i32) (result i64) i64.const 0)
(func (export "extract_enriched") (param i32 i32) (result i64) i64.const 0)
(func (export "__rustledger_abi_version") (result i32) i32.const {abi})
)
"#
)
}