Implement exact State Anchor mount and lease lifecycle
This commit is contained in:
parent
27bc3d835e
commit
e6d6406c64
1 changed files with 1852 additions and 0 deletions
|
|
@ -174,6 +174,66 @@ fn shared_artifact_waits_for_every_lease() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn release_evidence_is_checked_while_lease_remains_locked() {
|
||||
let fixture = Fixture::new();
|
||||
let artifact = fixture.publish(31);
|
||||
let exact = lease(&artifact, 1, 3);
|
||||
fixture.catalog.acquire_lease(&exact).unwrap();
|
||||
|
||||
let refused = fixture.catalog.release_lease_checked(&exact, || {
|
||||
Err(CatalogError::Io(std::io::Error::other(
|
||||
"injected release-evidence mismatch",
|
||||
)))
|
||||
});
|
||||
assert!(matches!(refused, Err(CatalogError::Io(_))));
|
||||
assert_eq!(
|
||||
fixture.catalog.snapshot().unwrap().artifact_leases,
|
||||
vec![exact]
|
||||
);
|
||||
|
||||
fixture
|
||||
.catalog
|
||||
.release_lease_checked(&exact, || Ok(()))
|
||||
.unwrap();
|
||||
assert!(
|
||||
fixture
|
||||
.catalog
|
||||
.snapshot()
|
||||
.unwrap()
|
||||
.artifact_leases
|
||||
.is_empty()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lease_acquisition_binds_the_exact_artifact_row() {
|
||||
let fixture = Fixture::new();
|
||||
let artifact = fixture.publish(32);
|
||||
let exact = lease(&artifact, 2, 4);
|
||||
let mut forged = artifact.clone();
|
||||
forged.inode = InodeId::new(9_999);
|
||||
|
||||
assert!(matches!(
|
||||
fixture.catalog.acquire_lease_checked(&forged, &exact),
|
||||
Err(CatalogError::OwnershipMismatch {
|
||||
row: CatalogRow::PreparedArtifact
|
||||
})
|
||||
));
|
||||
assert!(
|
||||
fixture
|
||||
.catalog
|
||||
.snapshot()
|
||||
.unwrap()
|
||||
.artifact_leases
|
||||
.is_empty()
|
||||
);
|
||||
fixture
|
||||
.catalog
|
||||
.acquire_lease_checked(&artifact, &exact)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn one_domain_generation_cannot_bind_two_artifacts() {
|
||||
let fixture = Fixture::new();
|
||||
|
|
|
|||
Loading…
Reference in a new issue