Skip to content

Commit c3ab60b

Browse files
committed
test(contract): address pre-review findings on async attestation tests
- test-utils/Cargo.toml: sort tee-verifier-interface into dependency order (fixes the cargo-sort Fast CI failure) - test-tee-verifier/Cargo.toml: ignore borsh in cargo-shear (used only via the abi feature, like the sibling tee-verifier crate), avoiding a --deny-warnings failure - test-tee-verifier-types: reword the StubResponse::Panic doc comment to the no-yield flow (it described the removed yield timeout) - tee_verifier.rs: bound the ignored happy-path test's net spend on both sides so a wrongly-retained deposit fails; note why the failure assertion substring-matches; retarget the ignored tests at the fixture follow-up (#3787)
1 parent 34a644c commit c3ab60b

4 files changed

Lines changed: 25 additions & 10 deletions

File tree

crates/contract/tests/sandbox/tee_verifier.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ async fn assert_submission_failed_cleanly(
126126
!failures.is_empty(),
127127
"expected the promise chain to fail on a receipt, got: {result:#?}"
128128
);
129+
// Substring-match: near-workspaces keeps `ExecutionOutcome.status`
130+
// `pub(crate)`, so the error is only reachable via the Debug dump.
129131
let rendered = format!("{failures:?}");
130132
let expected = expected_error.to_string();
131133
assert!(
@@ -229,13 +231,13 @@ async fn submit_participant_info__should_fail_and_store_nothing_on_verifier_cras
229231
.await;
230232
}
231233

232-
// TODO(#3738): un-ignore once the fixture allowlist setup lands. A Verified
234+
// TODO(#3787): un-ignore once the fixture allowlist setup lands. A Verified
233235
// verdict routes through `verify_post_dcap_and_store`, whose allowlist checks
234236
// (fixture image/launcher hashes and measurements voted in, submitter using the
235237
// fixture keys) must pass before the attestation is stored. With an empty
236238
// allowlist the post-DCAP check fails and the submission is rejected instead of
237239
// stored, so the happy path cannot be exercised here yet.
238-
#[ignore = "needs fixture allowlist setup to pass the post-DCAP checks; tracked in #3738"]
240+
#[ignore = "needs fixture allowlist setup to pass the post-DCAP checks; tracked in #3787"]
239241
#[tokio::test]
240242
async fn submit_participant_info__should_store_attestation_on_verified_quote() {
241243
// Given: a verifier that returns the report the real verifier would produce
@@ -247,8 +249,8 @@ async fn submit_participant_info__should_store_attestation_on_verified_quote() {
247249
let result = submit_dstack(&submitter, &contract).await;
248250

249251
// Then: the chain succeeds and the attestation is stored; storage is charged
250-
// and the excess deposit refunded (net spend is storage + gas, well under the
251-
// full deposit).
252+
// and the excess deposit refunded, so net spend is storage + gas, well under
253+
// the full deposit.
252254
assert!(
253255
result.failures().is_empty(),
254256
"the verified submission chain must succeed, got: {result:#?}"
@@ -257,14 +259,24 @@ async fn submit_participant_info__should_store_attestation_on_verified_quote() {
257259
.await
258260
.unwrap();
259261
assert!(stored.is_some(), "a verified attestation must be stored");
262+
263+
// Bound net spend both sides: storage was charged (> 0), but the excess was
264+
// refunded (< floor). The upper bound catches a wrongly-retained deposit.
260265
let balance_after = submitter.view_account().await.unwrap().balance;
266+
let net_spent = balance_before.as_yoctonear() - balance_after.as_yoctonear();
267+
let refund_floor = NearToken::from_millinear(100).as_yoctonear();
261268
assert!(
262-
balance_after < balance_before,
269+
net_spent > 0,
263270
"storage must be charged from the attached deposit"
264271
);
272+
assert!(
273+
net_spent < refund_floor,
274+
"excess deposit must be refunded (net spent {net_spent} yoctoNEAR should be \
275+
storage + gas, < {refund_floor}); a retained {SUBMIT_DEPOSIT} deposit would exceed this"
276+
);
265277
}
266278

267-
// TODO(#3738): un-ignore once the fixture allowlist setup lands. To OOG,
279+
// TODO(#3787): un-ignore once the fixture allowlist setup lands. To OOG,
268280
// `resolve_verification` must reach the heavy RTMR3 replay in the post-DCAP
269281
// checks, which needs the allowlist populated and the submitter using the fixture
270282
// keys. With an empty allowlist the post-DCAP check fails fast and
@@ -273,7 +285,7 @@ async fn submit_participant_info__should_store_attestation_on_verified_quote() {
273285
// receipt back atomically: nothing is stored, the runtime refunds the attached
274286
// deposit to the predecessor, and `fail_attestation_submission` never fires, so
275287
// the chain still surfaces a failed receipt. No timeout is involved.
276-
#[ignore = "needs fixture allowlist setup to reach the gas-heavy post-DCAP path; tracked in #3738"]
288+
#[ignore = "needs fixture allowlist setup to reach the gas-heavy post-DCAP path; tracked in #3787"]
277289
#[tokio::test]
278290
async fn submit_participant_info__should_fail_and_store_nothing_when_resolve_verification_runs_out_of_gas()
279291
{

crates/test-tee-verifier-types/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub enum StubResponse {
2424
/// Return [`tee_verifier_interface::VerificationResult::Rejected`] with this
2525
/// reason.
2626
Rejected(String),
27-
/// Panic, simulating an unreachable / crashing verifier (the no-verdict path
28-
/// that mpc-contract resolves via the yield timeout).
27+
/// Panic, simulating an unreachable or crashing verifier: the verify-quote
28+
/// receipt fails, which mpc-contract reports as the verifier being unavailable.
2929
Panic,
3030
}

crates/test-tee-verifier/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ version = { workspace = true }
44
license = { workspace = true }
55
edition = { workspace = true }
66

7+
[package.metadata.cargo-shear]
8+
ignored = ["borsh"]
9+
710
[lib]
811
crate-type = ["cdylib", "lib"]
912

crates/test-utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ edition = { workspace = true }
88
cargo-near-build = { workspace = true }
99
hex = { workspace = true }
1010
mpc-attestation = { workspace = true, features = ["test-utils", "local-verify"] }
11-
tee-verifier-interface = { workspace = true }
1211
mpc-primitives = { workspace = true }
1312
near-mpc-contract-interface = { workspace = true }
1413
near-sdk = { workspace = true, features = ["non-contract-usage"] }
1514
serde_json = { workspace = true }
1615
serde_yaml = { workspace = true }
1716
sha2 = { workspace = true }
17+
tee-verifier-interface = { workspace = true }
1818

1919
[lints]
2020
workspace = true

0 commit comments

Comments
 (0)