2

So I am currently building up a test suite for a project, and I have quite a few tests at this point. I am running into a problem however that truffle seems to run tests later in its execution much slower than it does if I run that test file first. Are some of my contract objects staying around and clogging up my environment as I run more tests? Has anyone experienced something similar to this?

With lots of test beforehand

    PoolManager deployment
      ✓ has correct owner (2928ms)
      ✓ has correct region name (301ms)
      ✓ does accounts[0] deploy contract (278ms)
      ✓ renounce ownership works (462ms)
      ✓ transfer region owner legit (352ms)
      ✓ transfer region owner malicious 1 (584ms)
    Pool Interaction
      ✓ can approve a pool (1562ms)
      ✓ non regionOwner cannot approve pool (1817ms)
      ✓ strategy controler able to deploy strategy (with 0 for timelock) (4915ms)
      ✓ can deposit fund to pool after setting strategy first time (14449ms)
      ✓ can withdraw funds after depositing into pool, setting strategy only once, no old strategy (8547ms)
      ✓ deposit, change strategy, then withdraw. No money should be lost. 1 user only in this test (13232ms)
      ✓ deposit, change strategy, then withdraw. No money should be lost. 3 users in this test (20736ms)
    Strategy interaction
      ✓ deposit, change strategy, then withdraw. 3 users, 1:.5 strategy value ratio (18233ms)
      ✓ deposit, change strategy, then withdraw. 3 users, 1:.2 on first strat, 1:.5 on second strat value ratio to staking token, bigger ratio to smaller ratio test (14736ms)
      ✓ deposit withdraw 1/2 withdraw 1/2 from 4 accounts, with two movetoNewPool called between deposit, and between the 2 withdraw blocks (29290ms)
      ✓ deposit, change strategy, then withdraw. 3 users, 1:.5 to 1:.2 strat, smaller ratio to bigger ratio test (22301ms)
      ✓ users withdraw when funds are halfway between pools. No money should be lost (28385ms)
      ✓ make sure deposit is properly reject while pool is locked to move funds, and withdraw works normally and all funds can still be emptied, region manager cannot lock peoples funds forever with move (25677ms)

  Contract: token
    token deployment
      ✓ has correct name (18812ms)
      ✓ has correct symbol (5832ms)

Take note of the tests under the xxx contract section at the bottom. Here is their execution time if I dont run the pool manager contract tests.

Contract: token
    token deployment
      ✓ has correct name (2849ms)
      ✓ has correct symbol (304ms)

Its much faster. This added delay is causing my testing to run super slow as I add more and more tests to cover more possible scenarios. I would think that truffle would unload all the objects from one file once it is done running the tests in that file, but I'm not sure it thats actually the case. Any help or thoughts would be greatly appreciated!

1

I still dont know what is causing the problem, but I found a work around. I made a bash script that tests each file individually, so that the truffle environment hard resets each time. Here it is.

#!/bin/bash
for filename in ./test/*.test.js; do
   echo "$filename"
   truffle test "$filename" --compile-none
  done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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