rpctest: Cleanup resources on failed setup.

This contains the following upstream commits:
- 5e93b1664e
  - This commit originated from downstream so it is a NOOP
- 0ddd10add6
  - This commit has been reverted since it has already been done.
- fb90c334df
This commit is contained in:
Dave Collins 2017-07-21 17:02:42 -05:00
commit 823cbedd15
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2
2 changed files with 14 additions and 0 deletions

View File

@ -118,6 +118,13 @@ func TestMain(m *testing.M) {
// purposes.
if err := primaryHarness.SetUp(true, 25); err != nil {
fmt.Println("unable to setup test chain: ", err)
// Even though the harness was not fully setup, it still needs
// to be torn down to ensure all resources such as temp
// directories are cleaned up. The error is intentionally
// ignored since this is already an error path and nothing else
// could be done about it anyways.
_ = primaryHarness.TearDown()
os.Exit(1)
}

View File

@ -441,6 +441,13 @@ func TestMain(m *testing.M) {
// 25 mature coinbases to allow spending from for testing purposes.
if err = mainHarness.SetUp(true, numMatureOutputs); err != nil {
fmt.Println("unable to setup test chain: ", err)
// Even though the harness was not fully setup, it still needs
// to be torn down to ensure all resources such as temp
// directories are cleaned up. The error is intentionally
// ignored since this is already an error path and nothing else
// could be done about it anyways.
_ = mainHarness.TearDown()
os.Exit(1)
}