thing-testkit: store::payload for raw-record tests

This commit is contained in:
Meta Vens 2026-11-27 23:36:25 +01:00
commit 0d5d14a401
2 changed files with 7 additions and 2 deletions

View file

@ -266,7 +266,7 @@ fn an_unresolved_use_is_a_placeholder_and_a_read() {
fn a_refused_composition_is_not_absence() {
big(|| {
let mut state = MemState::new();
let bytes = rmp_serde::to_vec(&surface(boxed("root", vec![]), &[])).unwrap();
let bytes = store::payload(&surface(boxed("root", vec![]), &[])).unwrap();
state.put_raw(comp_address("c"), bytes);
let document = surface(boxed("root", vec![use_of("u", "c", vec![])]), &[]);
let resolution = run(&document, &state);
@ -285,7 +285,7 @@ fn the_composition_record_must_be_the_one_the_use_names() {
let other = composition("other", &[], boxed("c-root", vec![]));
for wrong in [v2, other] {
let mut state = MemState::new();
state.put_raw(comp_address("c"), rmp_serde::to_vec(&wrong).unwrap());
state.put_raw(comp_address("c"), store::payload(&wrong).unwrap());
let resolution = run(&surface(boxed("root", vec![use_of("u", "c", vec![])]), &[]), &state);
only(&resolution, Code::CompositionInvalid, Some("u"), "differs");
}

View file

@ -60,3 +60,8 @@ pub fn bytes(fill: impl FnOnce(&mut CultCache)) -> Vec<u8> {
let _ = std::fs::remove_dir_all(&work);
bytes
}
/// The payload the contract writes for `value`, as a store would hold it.
pub fn payload<T: DatabaseEntry>(value: &T) -> Vec<u8> {
memory().prepare_entry("payload", value).unwrap().0.payload
}