Skip to content

refactor/build: shared test helper, admin reader, migration guard, pinned toolchain (#291, #292, #293, #294) - #328

Merged
Calebux merged 1 commit into
zintarh:mainfrom
Samuel1-ona:chore/issues-291-294
Jul 29, 2026
Merged

refactor/build: shared test helper, admin reader, migration guard, pinned toolchain (#291, #292, #293, #294)#328
Calebux merged 1 commit into
zintarh:mainfrom
Samuel1-ona:chore/issues-291-294

Conversation

@Samuel1-ona

Copy link
Copy Markdown
Contributor

Closes #291, closes #292, closes #293, closes #294.

Four small, independent changes in one branch:

#292 — shared test signing helper
sign_payload was duplicated in src/test.rs and src/security_test.rs. It now lives in a test-only src/test_utils.rs and both files import it. No test behavior changed.

#294 — admin reader helper
Added admin::read_admin(&Env) -> Address, which panics with NotInitialized when the admin key is absent. update_admin (and the new migrate) use it. Public behavior is unchanged — update_admin before init still panics with Error(Contract, #2).

#291 — migration guard

  • New storage key DataKey::MigrationVersion holding the highest applied migration version (0 before any migration).
  • New admin-only 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 new MigrationAlreadyApplied (Implement mint_wrap Core Logic #7).
  • New read method migration_version() -> u32.
  • README gains an "Upgrade compatibility" section describing when a migration is required and how to run one alongside an upgrade.
  • Tests: forward-only application, replay rejection, and calling before initialization.

#293 — pinned toolchain

  • rust-toolchain.toml pinning Rust 1.94.1 with the wasm32-unknown-unknown target (and rustfmt/clippy).
  • Dockerfile bumped from rust:1.77-slim to 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.
  • README quickstart documents the pin and the WASM build command.

One extra fix required to build: #[cfg(test)] extern crate std; in src/lib.rs. Without it the #[contracttype] types in src/storage_types.rs fail to compile under cargo test, because the SDK's testutils Arbitrary derive emits std paths at the definition site. This failure exists on main too (there is no committed Cargo.lock).

Verification

  • cargo test — 34 passed, 0 failed, no warnings.
  • cargo build --release --target wasm32-unknown-unknown — succeeds.

🤖 Generated with Claude Code

…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>
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@Calebux
Calebux merged commit 61be292 into zintarh:main Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants