1
use std::collections::HashSet;
2

            
3
use super::{check, offenders, registry};
4

            
5
#[test]
6
1
fn the_trigger_linker_binds_no_registry_native() {
7
1
    let (imports, findings) = check();
8

            
9
1
    assert_eq!(findings, []);
10
1
    assert!(imports > 0);
11
1
    assert!(!registry().is_empty());
12
1
}
13

            
14
#[test]
15
1
fn a_linked_registry_native_is_reported() {
16
1
    let get_account = ("nomi".to_string(), "account_get_account".to_string());
17
1
    let env = ("env".to_string(), "write_bytes".to_string());
18
1
    let registry = HashSet::from([get_account.clone()]);
19

            
20
1
    let findings = offenders(&[env, get_account], &registry);
21

            
22
1
    assert_eq!(findings.len(), 1);
23
1
    assert!(findings[0].reason.contains("nomi.account_get_account"));
24
1
}
25

            
26
#[test]
27
1
fn the_registry_holds_the_lookup_natives() {
28
1
    let lookups = ["GET-ACCOUNT", "GET-COMMODITY"];
29
1
    let names: Vec<_> = crate::natives::all_compiler_specs()
30
1
        .into_iter()
31
70
        .map(|spec| spec.nomi_name)
32
        .collect();
33

            
34
30
    assert!(lookups.iter().all(|name| names.iter().any(|n| n == name)));
35
1
}