Skip to content

test: fix contract integration tests - #1725

Merged
kevindeforth merged 24 commits into
mainfrom
1144-fix-contract-integration-tests
Jan 14, 2026
Merged

kevindeforth merged 24 commits into
mainfrom
1144-fix-contract-integration-tests

Conversation

@pbeza

@pbeza pbeza commented Jan 8, 2026 •

Copy link
Copy Markdown
Contributor

Add unit tests for validate_tee() and integration test for expired attestation resharing.

Fixes #1144

Add unit tests for `validate_tee()` and integration test for expired attestation resharing

Fixes #1144
@pbeza pbeza linked an issue Jan 8, 2026 that may be closed by this pull request
@pbeza
pbeza marked this pull request as ready for review January 8, 2026 16:27
Copilot AI review requested due to automatic review settings January 8, 2026 16:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds comprehensive test coverage for TEE attestation validation and expired attestation resharing functionality. The changes address issue #1144 by adding unit tests for the validate_tee() function and a full integration test for the expired attestation resharing flow.

Key Changes:

  • Added 5 unit tests covering different scenarios of validate_tee() including valid attestations, missing attestations, expired attestations, and invalid attestations
  • Added integration test verifying the complete flow of detecting expired attestations and triggering resharing
  • Refactored existing Rust test to focus specifically on verifying resharing trigger rather than complete resharing flow

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
pytest/tests/test_expired_attestation_resharing.py New integration test that verifies verify_tee() correctly triggers resharing when a participant's attestation expires, and validates the participant is removed from the active set
pytest/common_lib/contracts.py Added two new contract method enums (SUBMIT_PARTICIPANT_INFO and VERIFY_TEE) to support the integration test
crates/contract/tests/inprocess/attestation_submission.rs Refactored test to focus on verifying resharing state transition on expired attestation, removed unused import (KeyEventId), and updated documentation to clarify the test's purpose
crates/contract/src/tee/tee_state.rs Added 5 comprehensive unit tests for validate_tee() covering all validation scenarios: all valid, missing attestation, expired attestation, not yet expired, and invalid attestation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pbeza
pbeza requested review from DSharifi and kevindeforth January 8, 2026 16:43

@gilcu3 gilcu3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR does not seem to solve the issue at hand. It is adding a system test (pytest), while the issue mentions integration test (sandbox tests)

@pbeza

pbeza commented Jan 9, 2026

Copy link
Copy Markdown
Contributor Author

This PR does not seem to solve the issue at hand. It is adding a system test (pytest), while the issue mentions integration test (sandbox tests)

I assumed the integration tests were the ones in the /pytest directory, as mentioned in our README:

mpc/README.md

Lines 24 to 27 in ac75f07

## Testing
- **Unit Tests**: Run with `cargo test --release` (`--release` flag is advised for performance reasons).
- **Integration Test** : Located in the `/pytest` directory.

Looks like the naming we use for different test types is still a bit confusing. No worries though — I can implement a sandbox test instead. Thanks for catching that!

@kevindeforth

kevindeforth commented Jan 9, 2026 •

Copy link
Copy Markdown
Contributor

This PR does not seem to solve the issue at hand. It is adding a system test (pytest), while the issue mentions integration test (sandbox tests)

I assumed the integration tests were the ones in the /pytest directory, as mentioned in our README:

mpc/README.md

Lines 24 to 27 in ac75f07

## Testing
- **Unit Tests**: Run with `cargo test --release` (`--release` flag is advised for performance reasons).
- **Integration Test** : Located in the `/pytest` directory.

Looks like the naming we use for different test types is still a bit confusing. No worries though — I can implement a sandbox test instead. Thanks for catching that!

Yes, this used to be a contention, but we aligned on the respective definitions in August thanks to @DSharifi's initiative.
https://nearone.slack.com/archives/C07UW93JVQ8/p1756219425948399
Seems like we didn't update the documentation.

edit: tracking issue: #1732

@pbeza

pbeza commented Jan 9, 2026

Copy link
Copy Markdown
Contributor Author

I’ve reimplemented the pytest as an integration test. Feel free to re-review, @gilcu3 @kevindeforth.

@pbeza
pbeza requested a review from gilcu3 January 9, 2026 17:24
@pbeza
pbeza enabled auto-merge January 9, 2026 18:35

@gilcu3 gilcu3 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Only blocked is that a function should be converted to unit test, or not simplified if it should remain an integration test, as per the issue. See #1725 (comment)

Comment thread crates/contract/tests/inprocess/attestation_submission.rs Outdated
Comment thread crates/contract/tests/sandbox/tee.rs Outdated
Comment thread crates/contract/src/tee/tee_state.rs Outdated
@pbeza
pbeza requested a review from gilcu3 January 12, 2026 09:29
Comment thread crates/contract/src/tee/tee_state.rs Outdated
Comment thread crates/contract/tests/inprocess/attestation_submission.rs Outdated
Comment thread crates/contract/src/lib.rs Outdated
Comment thread crates/contract/src/lib.rs Outdated
Comment thread crates/contract/src/lib.rs Outdated

@kevindeforth kevindeforth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard blocker right now are the expiry times - we shouldn't need any "margin" there.
Soft blocker is added checks in unit tests, ensuring the resulting state corresponds to the expected state. Comparing number of participants and account id is not enough here, as the resharing does not go through a voting.
We expect all participant details of the remaining participants to match. And we expect some sensible limits for the threshold.

@pbeza
pbeza requested a review from kevindeforth January 12, 2026 18:03
@pbeza

pbeza commented Jan 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Hard blocker right now are the expiry times - we shouldn't need any "margin" there. Soft blocker is added checks in unit tests, ensuring the resulting state corresponds to the expected state. Comparing number of participants and account id is not enough here, as the resharing does not go through a voting. We expect all participant details of the remaining participants to match. And we expect some sensible limits for the threshold.

@kevindeforth could you take a look at whether the asserts look better now, and whether there are any other asserts you’d add? Also, @gilcu3, feel free to re-review. Thanks!

gilcu3
gilcu3 previously approved these changes Jan 13, 2026

@gilcu3 gilcu3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looks good to me, left a few (optional) comments

Comment thread crates/contract/src/tee/tee_state.rs Outdated
Comment thread crates/contract/src/tee/tee_state.rs Outdated
Comment thread crates/contract/src/lib.rs Outdated
kevindeforth
kevindeforth previously approved these changes Jan 13, 2026

@kevindeforth kevindeforth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Only nits.

Comment thread crates/contract/src/tee/tee_state.rs Outdated
Comment thread crates/contract/tests/sandbox/tee.rs
Comment thread pytest/common_lib/contracts.py Outdated
@pbeza
pbeza added this pull request to the merge queue Jan 13, 2026
@kevindeforth
kevindeforth removed this pull request from the merge queue due to a manual request Jan 13, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Jan 13, 2026
@pbeza
pbeza dismissed stale reviews from kevindeforth and gilcu3 via b42e7b3 January 14, 2026 10:43
@kevindeforth
kevindeforth added this pull request to the merge queue Jan 14, 2026
Merged via the queue into main with commit fb611d4 Jan 14, 2026
26 of 27 checks passed
@kevindeforth
kevindeforth deleted the 1144-fix-contract-integration-tests branch January 14, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix contract integration tests

4 participants