Skip to content

Commit f41a568

Browse files
greenhatbitwalker
authored andcommitted
test: add expected imports/exports check in basic wallet test
1 parent 059292c commit f41a568

File tree

2 files changed

+17
-6
lines changed
  • hir/src/component
  • tests/integration/src/rust_masm_tests

2 files changed

+17
-6
lines changed

hir/src/component/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ impl formatter::PrettyPrint for ComponentImport {
6969
}
7070

7171
/// The name of a exported function
72-
#[derive(Debug, Ord, PartialEq, PartialOrd, Eq, Hash, derive_more::From, derive_more::Into)]
72+
#[derive(
73+
Debug, Clone, Ord, PartialEq, PartialOrd, Eq, Hash, derive_more::From, derive_more::Into,
74+
)]
7375
pub struct FunctionExportName(Symbol);
7476

7577
/// A component export

tests/integration/src/rust_masm_tests/sdk.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
use std::collections::BTreeMap;
2+
13
use expect_test::expect_file;
24
use miden_core::crypto::hash::RpoDigest;
35
use miden_frontend_wasm::{ExportMetadata, ImportMetadata, WasmTranslationConfig};
4-
use miden_hir::{InterfaceFunctionIdent, InterfaceIdent, Symbol};
6+
use miden_hir::{FunctionExportName, InterfaceFunctionIdent, InterfaceIdent, Symbol};
57

68
use crate::CompilerTest;
79

@@ -27,7 +29,7 @@ fn sdk_basic_wallet() {
2729
interface: interface.clone(),
2830
function: Symbol::intern("remove-asset"),
2931
};
30-
let import_metadata = [
32+
let import_metadata: BTreeMap<InterfaceFunctionIdent, ImportMetadata> = [
3133
(
3234
create_note_ident.clone(),
3335
ImportMetadata {
@@ -52,7 +54,7 @@ fn sdk_basic_wallet() {
5254
]
5355
.into_iter()
5456
.collect();
55-
let export_metadata = [
57+
let export_metadata: BTreeMap<FunctionExportName, ExportMetadata> = [
5658
(
5759
Symbol::intern("send-asset").into(),
5860
ExportMetadata {
@@ -69,14 +71,21 @@ fn sdk_basic_wallet() {
6971
.into_iter()
7072
.collect();
7173
let config = WasmTranslationConfig {
72-
import_metadata,
73-
export_metadata,
74+
import_metadata: import_metadata.clone(),
75+
export_metadata: export_metadata.clone(),
7476
..Default::default()
7577
};
7678
let mut test = CompilerTest::rust_source_cargo_component("sdk/basic-wallet", config);
7779
let artifact_name = test.source.artifact_name();
7880
test.expect_wasm(expect_file![format!("../../expected/sdk_basic_wallet/{artifact_name}.wat")]);
7981
test.expect_ir(expect_file![format!("../../expected/sdk_basic_wallet/{artifact_name}.hir")]);
82+
let ir = test.hir().unwrap_component();
83+
for (_, import) in ir.imports() {
84+
assert!(import_metadata.contains_key(&import.interface_function));
85+
}
86+
for (name, _meta) in export_metadata {
87+
assert!(ir.exports().contains_key(&name));
88+
}
8089
}
8190

8291
#[test]

0 commit comments

Comments
 (0)