简体   繁体   中英

Mocha tests hang after completion when working with web3 smart contracts

I wrote some integration tests for a node app that works with Ethereum smart contracts (and thus use the contracts' state as a data storage). I am instantiating some smart contracts interfaces using web3 and in the assertion parts of the tests I am using them to check that valid information has been written to the blockchain.

However after the tests pass the mocha process is still running and I have to shut it down manually. I suspect this happens because the smart contract interfaces are basically open connections and they are not closed, I know it happens when you do the same with normal database connections (see here: Mocha hangs after execution when connecting with Mongoose ).

I didn't find any disconnect or similar web3 api methods though, anyone had any similar experience with this?

有人指出我有一个--exit标志,您可以将其传递给mocha,它会在所有测试完成运行后--exit进程,这可能是目前足够好的解决方案。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM