Coder Social home page Coder Social logo

Improve func tests about toncli HOT 4 CLOSED

disintar avatar disintar commented on July 21, 2024
Improve func tests

from toncli.

Comments (4)

bminaiev avatar bminaiev commented on July 21, 2024

List of things we don't like and (ideally) want to fix:

  1. Currently developers need to manually specify method_id for each test following some rules (they should start from 0, corresponding "check" function needs to have method_id equal to "prepare" function method_id + 1). We want to fully remove the necessity of manual method_ids.
  2. Developers need to manually find function selectors of smart contract's tested methods. Ideally we want to just specify names of tested functions instead of their ids.
  3. Currently each test runs only one smart contract function. Would be great to be able to run several (possibly different) functions inside one test. Persistent data (c4) during each function call should be equal to what was saved during the previous call. Ideally we want to "dynamically" generate a list of functions to be called (e.g. via loops). But even if we require a number of function calls known at compile time, it will already be a huge improvement.
  4. Improve stack corruption error reporting. Currently if tests or smart contract functions do not behave nicely with stack (e.g. consume or add more/less entries from stack), some strange situations could happen, which is hard to debug.
  5. Something else?

from toncli.

bminaiev avatar bminaiev commented on July 21, 2024

Some ideas (they are all theoretical, and potentially could not work) about how to improve things.

  1. We need to know which functions are tests, and need to be run. Currently this is done by using specific method_ids. We can use different conventions, and use function names instead. Say, if the function name starts with "__test", we consider it as a test, and will run it. There is also a question about how to find the corresponding "checker" function. We can return a reference to the checker function (e.g. as continuation) together with other test parameters (stack, data, c7, ...) from the test function.
  2. As in the previous point, we can just return the tested function as continuation, not a function selector. This will require a compiling test together with the contract's code. It could lead to some problems (e.g. developers will not be able to use the same function names and global variables inside test and contracts code). But also it makes it possible to run some helper contracts functions inside tests.
  3. This part is the most questionable. We can generate a list of functions to be called (together with corresponding stack, c7, checker functions ...) from each test, and then run each function separately (providing c4 from previous call). We need to think about how to return this list from the test function. Also this way all function calls should be known in advance, which means they can't depend on responses from smart contracts.

from toncli.

tvorogme avatar tvorogme commented on July 21, 2024

Thanks ❤

https://github.com/disintar/toncli/blob/master/docs/advanced/func_tests_new.md

from toncli.

tvorogme avatar tvorogme commented on July 21, 2024

Thanks ❤

https://github.com/disintar/toncli/blob/master/docs/advanced/func_tests_new.md

from toncli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.