---
# System prepended metadata

title: Random failing tests analysis

---

# Random failing tests analysis

This documents describe the analysis of the random failing tests on marketplace-storage repo. The work was done on [this PR](https://github.com/rsksmart/rif-marketplace-storage/pull/277)

Firstly, I muted the warning for the contract upgrades to be shown only at the beginning, it was being shown on every test case (@openzeppelin/truffle-upgrades.silenceWarnings()) in this commit 

So test are failing randomly with ```Could not connect to your Ethereum client.```. It seems to be related to these truffle issues [#1461](https://github.com/trufflesuite/truffle/issues/1461) and [#729](https://github.com/trufflesuite/truffle/issues/729). So in order to fix it I bumped the truffle version `@5.4.1`, did `npm ls truffle` and saw there was an unmet peer dependency with `@typechain/truffle-v4` dep. I removed that one as we have `@typechain/truffle-v5` already and it's using the truffle v5 dep.

It kept failing randomly. I saw that the tests were failing only when both StakingTest and StorageTest were running (and it took much more time to run StorageManagerTests when StakingTests was run previously).  So it could be related to [this issue](https://forum.openzeppelin.com/t/renaming-of-incompatible-type/6102) in OZ. So, I bumped that version as well to @openzeppelin/truffle-upgrades @1.8.0. Got an error that when upgrading we should keep internal vars, so I added time var to the test contract upgrade in this [commit]( https://github.com/rsksmart/rif-marketplace-storage/pull/277/commits/59d5101f22c58c514e8239babdbd31da1c4b7320). And it kept failing randomly.

Then I increased the timeout of truffle tests and grouped some of the test by the need of clean deploy to optimize the execution, without changing the logic of them (otherwise they would need to be rewritten) in this [commit](https://github.com/rsksmart/rif-marketplace-storage/pull/277/commits/99811f4148036cb74c525a4c0c4c2d66fa4d58fb). If we want to optimize the rest we would need to re-write all test structure and logic, as they rely on a clean deployment of the contract when checking the offers, agreements, utilized capacity, etc...

It keeps failing randomly. I couldn't make it fail when we run the test separatedly so my guess is that it's related to this open issue in truffle [#1785](https://github.com/trufflesuite/truffle/issues/1785).

*Note: this is also happenning in marketplace-notifier*

Other possible solutions or things to try:
- ask for support in truffle
- re-write tests
- migrate to hardhat?
- ?