Solidity: Refactor interactive tests

Created on 1 Apr 2019  路  12Comments  路  Source: ethereum/solidity

Many interactive tests share common functionality and functionslike printIndented. They should be pulled into a common base class.

Also, a "simple" interactive test that just has an input and an output (and comparison is string comparison) could profit from a simple combined base class.

bounty worthy medium good first issue help wanted

All 12 comments

It might even make sense to combine this with allowing multiple expectation blocks per test already - then a common class would split the input into source and multiple expectation blocks, determine which kind of test each expectation block is (and parse common settings) and then let the specific test case handle the rest.

@ekpyron I think we should first clean up the mess and then make it more complicated again :)

I think really cleaning it up would basically mean rewriting quite some parts of it and then one might as well split into multiple expectation blocks right away, since otherwise we'll probably rewrite things once more later on anyways :-). But yeah - both would be fine and I would say whoever actually does this can decide which seems better and easier.

I would like to work on it. I have some experience in C++. This seems to look like something interesting to work on.

@maharsh312 That sounds great! Do you need some guidance on where to start or a more detailed explanation of what has been discussed in this issue? Just let us know what's needed to get you started on this. We're more than happy to help!

One piece of code you could look out for is

    if (m_expectation != m_obtainedResult)
    {
        string nextIndentLevel = _linePrefix + "  ";
        AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::CYAN}) << _linePrefix << "Expected result:" << endl;
        printIndented(_stream, m_expectation, nextIndentLevel);
        AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::CYAN}) << _linePrefix << "Obtained result:" << endl;
        printIndented(_stream, m_obtainedResult, nextIndentLevel);
        return TestResult::Failure;
    }

This is shared in quite some files. Especially if m_expectation and m_obtainedResult is a string, it can be pulled into a common base class, which could be named something like SimpleTestCase that itself inherits from TestCase.

I think I don't need help as of now. Do you guys have an IRC?

I think I don't need help as of now. Do you guys have an IRC?

Never Mind. Found It!

Is this issue still open? I'm trying to find good first issues to start contributing to open source.

@kennycastro007 We thought this one might be a good issue for you to start on, if you like. If you need help you can talk to us in our gitter channel https://gitter.im/ethereum/solidity-dev. When you start working on this, please assign the issue to you.

I believe ppl not part of the team can't assign issues. Just let us now if that is the case and we'll assign it for you.

I think after #9059 this looks good now!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hiqua picture hiqua  路  4Comments

axic picture axic  路  3Comments

area picture area  路  3Comments

AnthonyAkentiev picture AnthonyAkentiev  路  3Comments

chriseth picture chriseth  路  4Comments