Lines
100 %
Functions
Branches
//! An entity is a list on the wire, so it counts toward `MAX_WIRE_LIST_DEPTH`.
use super::*;
async fn decode_nested_entity(levels: usize) -> wasmtime::Result<EvalValue> {
let mut form = r#"(list (ent) "x")"#.to_string();
for _ in 2..levels {
form = format!("(list {form})");
}
try_entity_widened_to_anyref(
nomiscript::EntityKind::SshKey,
"alloc_ssh_key",
&[b"k", b"f", b"n", b"t", b"c", b"u"],
&form,
)
.await
#[tokio::test(flavor = "current_thread")]
async fn an_entity_at_the_ceiling_decodes() {
assert!(decode_nested_entity(MAX_WIRE_LIST_DEPTH).await.is_ok());
async fn an_entity_one_level_deeper_is_a_depth_error() {
let err = decode_nested_entity(MAX_WIRE_LIST_DEPTH + 1)
.unwrap_err();
assert!(err.to_string().contains("depth limit"), "{err}");