refactor/build: shared test helper, admin reader, migration guard, pinned toolchain (#291, #292, #293, #294) - #328
Merged
Conversation
…inned toolchain - zintarh#292: move duplicated `sign_payload` into `src/test_utils.rs` and use it in both `test.rs` and `security_test.rs` - zintarh#294: add `admin::read_admin` helper that panics with `NotInitialized`, used by all admin-only paths - zintarh#291: add `DataKey::MigrationVersion` plus admin-only `migrate(version)` / `migration_version()` so a migration can only run once; document upgrade compatibility in the README - zintarh#293: add `rust-toolchain.toml` pinning Rust 1.94.1 with the wasm target, align the Dockerfile, and update the README quickstart Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
@Samuel1-ona 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! 🚀 |
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 #291, closes #292, closes #293, closes #294.
Four small, independent changes in one branch:
#292 — shared test signing helper
sign_payloadwas duplicated insrc/test.rsandsrc/security_test.rs. It now lives in a test-onlysrc/test_utils.rsand both files import it. No test behavior changed.#294 — admin reader helper
Added
admin::read_admin(&Env) -> Address, which panics withNotInitializedwhen the admin key is absent.update_admin(and the newmigrate) use it. Public behavior is unchanged —update_adminbefore init still panics withError(Contract, #2).#291 — migration guard
DataKey::MigrationVersionholding the highest applied migration version (0before any migration).migrate(version: u32): requires admin auth and only accepts a version strictly greater than the stored one, so a migration cannot be replayed. Replay panics with the newMigrationAlreadyApplied(Implement mint_wrap Core Logic #7).migration_version() -> u32.#293 — pinned toolchain
rust-toolchain.tomlpinning Rust1.94.1with thewasm32-unknown-unknowntarget (and rustfmt/clippy).Dockerfilebumped fromrust:1.77-slimto match. Note: with the current dependency graph the crate no longer builds on 1.77/1.85 — transitive deps (darling,serde_with) require rustc ≥ 1.88 — so the pin also unbreaks the Docker build.One extra fix required to build:
#[cfg(test)] extern crate std;insrc/lib.rs. Without it the#[contracttype]types insrc/storage_types.rsfail to compile undercargo test, because the SDK's testutilsArbitraryderive emitsstdpaths at the definition site. This failure exists onmaintoo (there is no committedCargo.lock).Verification
cargo test— 34 passed, 0 failed, no warnings.cargo build --release --target wasm32-unknown-unknown— succeeds.🤖 Generated with Claude Code