Skip to content

Add support for user friendly testing#85

Draft
smiasojed wants to merge 2 commits into
mainfrom
sm/testing
Draft

Add support for user friendly testing#85
smiasojed wants to merge 2 commits into
mainfrom
sm/testing

Conversation

@smiasojed
Copy link
Copy Markdown
Collaborator

Goals:

  1. Enable contract authors to write unit tests in the same file as the contract.
// src/lib.rs
#![cfg_attr(not(feature = "std"), no_std, no_main)]

#[pvm_contract_sdk::contract]
pub mod flipper {
    pub struct Flipper { /* ... */ }
    impl Flipper {
        #[constructor] pub fn new(&mut self) { /* ... */ }
        #[method] pub fn flip(&mut self) { /* ... */ }
    }
}

#[cfg(all(test, feature = "std"))]
mod tests {
    use super::flipper::Flipper;
    use pvm_contract_sdk::MockHostBuilder;

    #[test]
    fn test_flip() {
        let mut f = Flipper::with_host(MockHostBuilder::new().build());
        f.flip();
        assert!(f.get());
    }
}
  1. Allow to write e2e tests

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 27, 2026

Benchmark Size Comparison (vs main)

Artifact Baseline Current Delta Status
fibonacci_builder-dsl.debug.polkavm 37345 37345 +0.00% OK
fibonacci_builder-dsl.release.polkavm 638 638 +0.00% OK
fibonacci_no-alloc.debug.polkavm 35967 35967 +0.00% OK
fibonacci_no-alloc.release.polkavm 595 595 +0.00% OK
fibonacci_with-alloc.debug.polkavm 46357 46357 +0.00% OK
fibonacci_with-alloc.release.polkavm 600 600 +0.00% OK
multi_builder-dsl.debug.polkavm 57629 57629 +0.00% OK
multi_builder-dsl.release.polkavm 3024 3024 +0.00% OK
multi_no-alloc.debug.polkavm 60352 60351 -0.00% OK
multi_no-alloc.release.polkavm 2919 2919 +0.00% OK
multi_with-alloc.debug.polkavm 71533 71532 -0.00% OK
multi_with-alloc.release.polkavm 3076 3076 +0.00% OK
mytoken_builder-dsl.debug.polkavm 55510 55510 +0.00% OK
mytoken_builder-dsl.release.polkavm 3683 3683 +0.00% OK
mytoken_no-alloc.debug.polkavm 59676 59678 +0.00% OK
mytoken_no-alloc.release.polkavm 2922 2922 +0.00% OK
mytoken_storage.debug.polkavm 63450 63458 +0.01% OK
mytoken_storage.release.polkavm 3017 3017 +0.00% OK
mytoken_with-alloc.debug.polkavm 73336 73343 +0.01% OK
mytoken_with-alloc.release.polkavm 3943 3943 +0.00% OK
---------------------------------------------------- ------------ ------------ ---------- --------
Total 585572 585587 +0.00%

OK: All artifacts within 5% regression threshold

Run 26532801152 | ffa6b16 | 2026-05-27 19:22 UTC

@pkhry pkhry self-assigned this May 27, 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

Development

Successfully merging this pull request may close these issues.

2 participants