Repository navigation
Fix: 4 issues (#942, #943, #944, #945) - #1016
Merged
Merged
Conversation
Co-authored-by: Simple Agent <agent@simple.dev>
|
@Emmyt24 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #942
Closes #943
Closes #944
Closes #945
Issues
#942 Contract: test remove_delegate requires recipient auth
#943 Contract: test remove_delegate when no delegate is set
#944 Contract: assert bump_stream emits StreamBumpedEvent
#945 Contract: document bump_stream behaviour while paused
Summary
All changes are test-only; do not modify
contracts/streaming/src/lib.rs. For the auth test intest_security.rs, follow the existingMockAuth/MockAuthInvokepattern used by other auth tests (e.g.test_auth_attacker_cannot_cancel), usingfn_name: "remove_delegate"and args(id,).into_val(&ctx.env). For event assertions, useenv.events().all()and decode the event body; theStreamBumpedEventandDelegateRemovedEventstructs are defined inlib.rs. Runcargo test,cargo clippy --all-targets -- -D warnings, andcargo fmt --checkfromcontracts/before submitting.Changes
test_remove_delegate_requires_recipient_auth(or similar) tocontracts/streaming/src/test_security.rsusing the existingCtxfixture. Create a stream, set a delegate, then mock auths for a non-recipient (e.g.ctx.attacker) invokingremove_delegatewith args(id,)and assert the call panics (use#[should_panic]ortry_remove_delegatereturning an auth error). Then add a positive test (or extend the same test) mocking the recipient's auth forremove_delegateand assert success andget_delegate(&id) == None. Ensurecargo test,cargo clippy --all-targets -- -D warnings, andcargo fmt --checkpass fromcontracts/. (contracts/streaming/src/test_security.rs)contracts/streaming/src/test.rs, strengthen the existingtest_remove_delegate_is_safe_noop_when_never_set(or add a new test) to assert thatremove_delegateon a stream that never had a delegate: (1) succeeds, (2) emits aDelegateRemovedEventwith the correctstream_idand recipient (inspectt.env.events().all()and match the event payload), and (3) leavesget_delegate(&stream_id) == None. Keep using the existingTestEnvfixture. Ensurecargo test,cargo clippy --all-targets -- -D warnings, andcargo fmt --checkpass fromcontracts/. (contracts/streaming/src/test.rs)contracts/streaming/src/test_features.rs, add tests forbump_stream: (1)test_bump_stream_emits_event— create a stream, callbump_stream, capturet.env.events().all(), and assert aStreamBumpedEventis emitted with the expectedstream_idand the current ledger timestamp; (2)test_bump_stream_works_while_paused— initialize with admin, create a stream, callclient.pause(), then callclient.bump_stream(&stream_id)and assert it succeeds (and optionally that theStreamBumpedEventis emitted), with a comment documenting that this is intentional so TTL upkeep works while paused (or flag it in the PR). Use the existingTestEnvfixture. Ensurecargo test,cargo clippy --all-targets -- -D warnings, andcargo fmt --checkpass fromcontracts/. (contracts/streaming/src/test_features.rs)