Automated Testing using bitcoind in regtest mode, problems due to race condition

1

So I have multiple instances of bitcoind in regtest mode. 1 instance is for the app wallet and one stimulates a wallet of a possible user.

I want to perform various functional and integration tests of the app.

Basic example, if user sends bitcoin from his wallet is that bitcoin correctly received by the app.

The problem though is that there is a time delay before that receiving node notices the transaction (even when both instances are on same machine). This screws up my tests, I tried putting in a sleep(10) function in my test code and that increases the success, but sometimes they still fail and I cant have my automated tests taking so long. (plus its seems very inelegant).

I'm wondering how others deal with this.

Cyrus

Posted 2016-06-10T06:08:21.390

Reputation: 77

Answers

1

I would separate out the unit tests and the integration tests.

If the function needs to go out to the internet or wait for the blockchain, I make them integration tests which I can run less frequently like every five minutes. The functions that are fast I like to run every 10 seconds.

Linking the errors to sensible time stamped logs like pm2 and key-metrics allows you to see what has been going on while you were sleeping.

Will-In-China

Posted 2016-06-10T06:08:21.390

Reputation: 408