Is it possible to specify arguments to an arbitrary function?

I want to test whether claiming rewards will result in tokens increasing. There are multiple functions that claim rewards. I want to specify the inputs to these functions as they are different. Do I have to have a separate rule for each function or can I somehow specify the inputs using a random method?

great question.

It depends on what exactly you’re looking to do, but both of these solutions should work:

  1. Use filter. If you want to call only 3 specific function you can filter these methods in, so that calling f(e, args) will only invoke the functions you specified.
    In a similar manner you can filter functions out, which will invoke all functions beside the methods you specified.
    You can find information that will help you with filters in this thread

  2. You can use f.selector to specify the functions that are of interest to you, calling each of them with the appropriate args.
    If you are looking to call 3 specific functions with specific input args, you actually have to call the methods explicitly.
    You can (and should) still use filter to filter in/out only the methods that you are interested in to reduce run time and focus the rule on what’s important.

A more clean and clever way to use f.selector is by creating a helper function that you call within the rule, i.e. instead of calling f(e, args) you call `claim_functions(e, f, arg1, arg2, …).
The f you send is a general method that you actually filter in/out to posses only the functions that you are interested in.

You can find an example to such function in our verification project on the governance system of OpenZeppelin - here.
You can find more verification project in this thread here.

Try looking at the examples and read the other threads and see if it fulfills your needs.

2 Likes