question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use `given` in `__setup__` function

See original GitHub issue

As a StarkNet smart contract developer, I want to use given in the __setup__ function to run a suite of tests on a contract that’s been initiated by fuzzed parameters.

In particular, I need to initiate random contract state using fuzzing, however, this initialization is by far the most expensive action in my contract suite. I would like to ideally run it in advance of tests rather than run it separately for each test where I need to use fuzzing.

Is there a way to hack this or do I have to just rely on individual setup functions to use fuzzing?

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mkaputcommented, Nov 15, 2022

Oh, now I understand what’s going on. Unfortunately, this idea is quite contradictory to the way how Protostar’s test runner works under the hood (fuzzer is spun for each test_* function separately, and it wraps single function, setups are running in their own context which is different from test cases ones). Therefore, I don’t think we will ever support such use case in Protostar, at least not in this shape of the codebase (the only solution that comes to my mind is adding something like sub-test-cases, which sounds strange?).

As a workaround, I wonder if it wouldn’t work for you if you stick with a single test case and eventually chop it into multiple subroutines. Yes, I know this is suboptimal, because you have single test, which runs sequentially and failure in one subroutine stops executing others, but it should still be helpful in successful case.

0reactions
Pet3riscommented, Nov 15, 2022

Thanks @mkaput - yeah I’ll consider that, no worries. Completely understand the limitation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue.js 3 Composition API: the SetUp Function - Medium
Vue 3 introduced the setUp function. It enables us to extract repeatable parts of components into reusable pieces of code.
Read more >
What is the role and usage of the setup function provided by ...
setup sets up an instance and returns properties that it should have. The purpose of Composition API, which setup is a part of, ......
Read more >
Composition API: setup() - Vue.js
The setup() hook serves as the entry point for Composition API usage in components in ... The first argument in the setup function...
Read more >
When i use setup function in vue2 project i get some error in ...
When i use setup function in vue2 project i get some error in console ... The code you provided relies heavily on code...
Read more >
p5.js | setup() Function - GeeksforGeeks
The setup() function runs when the program starts. It is used to set the initial environment properties such as text-color, screen size, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found