test: cover register_service_with_metadata atomicity and svc_reg event#143
Merged
mikewheeleer merged 1 commit intoJun 29, 2026
Conversation
Contributor
|
solid — merging now |
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 #100
test: cover
register_service_with_metadataatomicity andsvc_regeventSummary
Adds the missing
register_service_with_metadataentrypoint and comprehensivetest coverage for the atomic registration-plus-metadata operation.
Changes
contracts/escrow/src/lib.rs— new entrypointCreated
register_service_with_metadata(env, service_id, description, owner):ensure_not_paused— rejects calls while paused (panics Emit structured events on admin, price, and registration state changes #4).require_admin— only the contract admin may call.ServiceRegistered(service_id) = true.ServiceMetadata(service_id)with the provided description and owner.svc_reg(service_id, owner)for indexers.Also applied
cargo fmtfixes toresolve_dispute(pre-existing formatting drift).contracts/escrow/src/test.rs— 7 new teststest_register_service_with_metadata_sets_both_slotsis_service_registeredis true andget_service_metadatareturns the exact description + owner.test_register_service_with_metadata_emits_svc_reg_eventsvc_reg(service_id, owner)event is emitted viaenv.events().all().test_register_service_with_metadata_idempotent_overwritetest_register_service_with_metadata_empty_descriptionStringdescription is accepted.test_register_service_with_metadata_rejects_non_admin#[should_panic]— non-admin caller is rejected.test_register_service_with_metadata_panics_when_paused#[should_panic(expected = "Error(Contract, #4)")]— pause gate honoured.test_register_service_with_metadata_equivalent_to_separate_callsregister_service+set_service_metadatasequence.Also fixed 17 pre-existing
client.settle(&admin, &agent, &svc)calls — theSoroban SDK 22.0 client generator strips
envfrom entrypoint arguments, sosettle(env, agent, service_id)produces a 2-arg client methodsettle(&self, agent, service_id).Test output
Security notes
ServiceRegisteredandServiceMetadataare written in a single call; there is no window wherea service is registered but has no metadata (or vice versa).
require_admingates the entrypoint; non-admincallers are rejected with a panic.
ensure_not_pausedis checked before any statemutation, preventing calls while the contract is paused.
without side effects; empty descriptions are accepted.