-
Notifications
You must be signed in to change notification settings - Fork 610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify contract runtime tests #6921
Labels
A-testing
Area: Unit testing / integration testing
C-housekeeping
Category: Refactoring, cleanups, code quality
T-contract-runtime
Team: issues relevant to the contract runtime team
Comments
matklad
added
C-housekeeping
Category: Refactoring, cleanups, code quality
A-testing
Area: Unit testing / integration testing
T-contract-runtime
Team: issues relevant to the contract runtime team
labels
May 31, 2022
Good point from jakob: with unified infra, we can have a loop over vm_kinds and protocol versions, making sure that old protocol versions preseve behavior. |
near-bulldozer bot
pushed a commit
that referenced
this issue
Jun 9, 2022
…6922) RFC solution for #6921 Vision: * remove `make_simple_call` family of functions completely in favor of unified `test_builde()` * use snapshot/expect testing rather than relying on `Error: Eq`. I'd love to use `insta` as that's what we are using elsewhere, but I don't think insta can do what I want here (packaging "snapshot" as a value), so I plugged my `expect_test`. * pull the `with_vm_kinds` loop inside
nikurt
pushed a commit
that referenced
this issue
Jun 13, 2022
…6922) RFC solution for #6921 Vision: * remove `make_simple_call` family of functions completely in favor of unified `test_builde()` * use snapshot/expect testing rather than relying on `Error: Eq`. I'd love to use `insta` as that's what we are using elsewhere, but I don't think insta can do what I want here (packaging "snapshot" as a value), so I plugged my `expect_test`. * pull the `with_vm_kinds` loop inside
near-bulldozer bot
pushed a commit
that referenced
this issue
Jun 20, 2022
* reduce syntactic fluff and use idiomatic wat * name the entry point consistently (`main`) * reduce gas allocated for testing "out-of-gas" conditions, to speed up slow tests * add a new test for re-exporting import * move feature-gating tests from rs-contract to a simpler `wat` closes #6921
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-testing
Area: Unit testing / integration testing
C-housekeeping
Category: Refactoring, cleanups, code quality
T-contract-runtime
Team: issues relevant to the contract runtime team
Our average test looks like this:
fn simple_contract() -> Vec { wat::parse_str( r#" (module (type (;0![](/images/icons/emoticons/wink.png) (func)) (func (;0![](/images/icons/emoticons/wink.png) (type 0)) (export "hello" (func 0)) )"#, ) .unwrap() } #[test] fn test_simple_contract() { with_vm_variants(|vm_kind: VMKind| { gas_and_error_match( make_simple_contract_call_vm(&simple_contract(), "hello", vm_kind), Some(43032213), None, ); } ); }
I find this OK, but I am not entirely satisfied with it. I think we can benefit long-term from spending some cycles on cleaning up this. Specific things I don't like here:
(;0![](/images/icons/emoticons/wink.png)
comments, we should use$name
and(func (export))
shortcutshello
as an entry point. We should usemain
, and make it conventional (so that we don't have to specify it)with_vm_variants
and lambda are a boilerplate we repeat in every testVmError: Eq
make_simple_contract_call_vm
familiy of functions is inconventient when you want to tweak some aspect of the codewat::parse-str
calls repeatedIdeally, I'd love the tests to be less API-denpendent and more data-driven, and to look like this:
#[test] fn test_simple_contract() { test_builder() .wat( r#" (module (func (export "main"))) "#, ) .expect(expect![[r#" VMOutcome: balance 4 storage_usage 12 return data None burnt gas 42815463 used gas 42815463 "#]]); }
The text was updated successfully, but these errors were encountered: