Skip to content
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

Contract runtime testing. #214

Closed
g-r-a-n-t opened this issue Jan 30, 2021 · 0 comments · Fixed by #243
Closed

Contract runtime testing. #214

g-r-a-n-t opened this issue Jan 30, 2021 · 0 comments · Fixed by #243

Comments

@g-r-a-n-t
Copy link
Member

What is wrong?

We're currently limited to only testing the public interface of a contract. This can make debugging features that rely on multiple new runtime functions difficult. We should be able to test the runtime directly within our contracts test suite.

How can it be fixed

Create a new testing function that takes the following: an executor, contract fixture path, contract name, and a set of Yul statements to inject into the runtime.

It should look something like this:

test_runtime(
  &executor,
  "my_module.fe",
  "MyContract",
  statements! {
    (if (eq(add(1, 1), 2)) {
    (revert(0, 0))
  }
)

What we ultimately want to do is build a Yul object similar to an actual contract, but it only contains the runtime (no constructor) and the test statements. We would then compile this object to bytecode and execute it. If we hit a revert, the test has failed.

We should be able to create a function similar to runtime::build_with_abi_dispatcher, but named build_with_test_statements that simply inserts test statements into the runtime object. We then compile and execute.

@g-r-a-n-t g-r-a-n-t mentioned this issue Feb 12, 2021
3 tasks
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 a pull request may close this issue.

1 participant