clarinet icon indicating copy to clipboard operation
clarinet copied to clipboard

Call read-only function in block

Open friedger opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. As a developer, I want to mine a block where read-only functions are call next to public functions. This is to simplify the flow of tests

Describe the solution you'd like Have a function tx.callReadOnlyFn that returns a Tx

Describe alternatives you've considered Call read-only functions outside of blocks and have different test structure for read-only functions and public functions.

Additional context Currently, upgrading from clarinet 1.0 to the SDK.

friedger avatar Nov 22 '23 10:11 friedger

Hey @friedger Thanks for opening this issue. Do you think it would be necessary because it was possible before and it would ease the migration of existing projects, or do you think it's useful even for new projects and as a feature in general?

I always thought it was a bit odd that we could do mineBlock([callReadOnlyFunc]), but maybe it does make sense 🤔

hugoclrd avatar Nov 22 '23 11:11 hugoclrd

Having mineBlock([callReadOnlyFunc]) has two aspects:

  • During development/integration testing, it makes it easier to validate all calls in a stacks explorer.
  • During unit testing, it makes it easier to write the same boiler plate code for both types of functions

When the read-only calls are expensive the node might reject the call due to lower resource limits.

Maybe there are better solutions to overcome these issues.

friedger avatar Nov 23 '23 09:11 friedger