Snapshot example services' GraphQL schemas as insta tests (backport of #6542)#6545
Closed
ma2bd wants to merge 3 commits into
Closed
Snapshot example services' GraphQL schemas as insta tests (backport of #6542)#6545ma2bd wants to merge 3 commits into
ma2bd wants to merge 3 commits into
Conversation
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.
Motivation
Backport of #6542 to
testnet_conway.We record each application's serde/BCS formats as an
instasnapshot (viaBcsApplication) so that unintended changes to operation/message/event encodings show up as a reviewable diff. This adds the equivalent guard for the GraphQL schema exposed by each application's service.Proposal
For every example that implements
BcsApplicationand exposes a GraphQL service, add a#[cfg(test)]schema_sdltest inservice.rsthat snapshots the service's GraphQL SDL. Most services extract a privatefn schema(&self) -> Schema<…>and havehandle_querydelegate to it, so the snapshotted SDL cannot drift from what is served; the test builds the service against aMockServiceRuntimeand snapshotsschema().sdl().The snapshot tests are gated
#[cfg(not(target_arch = "wasm32"))](mirroring the existingtests/format.rsconvention), becauseinstais a non-wasm dev-dependency and the example services are also compiled forwasm32with--all-targets.Notes specific to this backport
This is not a clean cherry-pick of #6542 —
testnet_conwaydiffers frommainin several examples, so the following were adapted and the affected SDL snapshots regenerated againsttestnet_conway:// ANCHORmarkers andQueryRoot/MutationRootstructs, so itshandle_queryis left intact and the test builds the schema directly (in a separate gatedschema_testsmodule).NativeFungibleOperationhere (vsFungibleOperationonmain).root_view_storage_context()here (itsParametershas noprice_decimalsfield), so the test uses the simple load path.OwnerSpenderfrom a different module here.instanon-wasm dev-dependency (it was already present on the other examples).wasmer-featuredlinera-sdkdev-dependency (needed by the mockServiceRuntime).new()downloads model weights), so its test builds the schema directly; this does not affect the SDL.Test Plan
cargo test -p <example> --bin <example>_service schema_sdlpasses for all 16 services; re-running withoutINSTA_UPDATEconfirms the SDL is deterministic.cargo fmt -- --check(pinned nightly) is clean across the examples workspace.cargo clippy --all-targets --all-features --target wasm32-unknown-unknowncompiles (the schema tests are excluded from wasm).gen-nftandllmneedRUSTFLAGS=-C target-feature=+fullfp16to build candle; irrelevant on x86 CI.Release Plan
Links