2

I am trying to create an Integrated test (to test multiple smartContracts working together). I re-initialize them inside beforeEach() function. So I get the clean test for each test case. I have done the same things in other integrated tests,(using the same contracts), but here I get this errors.

Error screenshot

As you can see, there was no issues in IntegrationTestWhitelist (all 4 sub-tests passed)

However, TransactionTests failed

Error2

While troubleshooting I figured out that, the TransactionTests works only if I initialize two or less smartContracts in beforeEach().

Any more than that and I get "out of gas" error. I tried to initialize/comment them in different combinations too, and it is always fine as long as I do not initialize more than two. There seems to be nothing wrong with contracts individually. Rather it looks like the are "too" expensive when combined.

So I wonder if anyone had a similar issue?

The Code:

pragma solidity >=0.4.21 <0.7.0;
pragma experimental ABIEncoderV2;


import "../../../contracts/Whitelist.sol";
import "../../../contracts/Blacklist.sol";
import "../../../contracts/dgE.sol";
import "../../../contracts/ECB.sol";
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";

contract TransactionTests {

    //Contracts
    dgE public DGE;
    ECB public ecb;
    Whitelist public WHITELIST;
    Blacklist public BLACKLIST;


    // Run before every test function (Only works if I comment out any two of them)
    function beforeEach() public {
        DGE = new dgE();
        ecb= new ECB();
        WHITELIST = new Whitelist();
        BLACKLIST = new Blacklist();
    }

    /**
    * The function should always return the same value. (Just an initial test)
    */
    function testSender() public {
        Assert.equal(msg.sender,msg.sender,"Values should be Equal");
    }
5
  • Did you solve your problem bro? Commented Jan 19, 2022 at 9:45
  • You have the same issue??
    – Sky
    Commented Jan 19, 2022 at 10:54
  • Yes :(((((((((( Commented Jan 19, 2022 at 12:16
  • I guess maybe its depends of contract count, im also try to use 2 contracts but got same errors Commented Jan 19, 2022 at 12:18
  • I did some tests, and it 100% isn't the contract count (I used 3-4 no problem). It seems to be related to contract size, or maybe some conflict in contract inheritance. (As some of my Contracts import a bunch of other contracts) Would love to contact you over Zoom/Discord or something to see your issue to compare our issues and get at the bottom of it.
    – Sky
    Commented Jan 19, 2022 at 13:34

1 Answer 1

0

I had this error because of the solidity contract size issue, if your compiler is throwing an error about exceeding the maximum ~24kb size, fix the contract size issue first and the error will go away. This is what solved my similar problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.