Clean up fixture shutdown code a bit to try and see if this resolves … (#2498)

* Clean up fixture shutdown code a bit to try and see if this resolves issue on CI

* Rework fixtures so we aren't starting app configs in multiple places

* Fix scaladoc
This commit is contained in:
Chris Stewart 2021-01-09 17:07:26 -06:00 committed by GitHub
parent bcfc0d51a8
commit 68af9760b3
3 changed files with 28 additions and 9 deletions

View file

@ -119,6 +119,7 @@ trait Node extends NodeApi with ChainQueryApi with P2PLogger {
val start = System.currentTimeMillis()
for {
_ <- chainAppConfig.start()
_ <- nodeAppConfig.start()
// get chainApi so we don't need to call chainApiFromDb on every call
chainApi <- chainApiFromDb()

View file

@ -2,6 +2,11 @@ package org.bitcoins.testkit.node
import org.bitcoins.node.{NeutrinoNode, Node, SpvNode}
import org.bitcoins.rpc.client.common.BitcoindRpcClient
import org.bitcoins.testkit.node.fixture.{
NeutrinoNodeConnectedWithBitcoind,
NodeConnectedWithBitcoind,
SpvNodeConnectedWithBitcoind
}
import org.bitcoins.wallet.Wallet
/**
@ -16,6 +21,9 @@ trait NodeFundedWalletBitcoind {
def wallet: Wallet
def bitcoindRpc: BitcoindRpcClient
def bip39PasswordOpt: Option[String]
/** Helper method to convert from this to a [[NodeConnectedWithBitcoind]] */
def toNodeConnectedWithBitcoind: NodeConnectedWithBitcoind
}
case class SpvNodeFundedWalletBitcoind(
@ -23,11 +31,21 @@ case class SpvNodeFundedWalletBitcoind(
wallet: Wallet,
bitcoindRpc: BitcoindRpcClient,
bip39PasswordOpt: Option[String])
extends NodeFundedWalletBitcoind
extends NodeFundedWalletBitcoind {
override def toNodeConnectedWithBitcoind: SpvNodeConnectedWithBitcoind = {
SpvNodeConnectedWithBitcoind(node, bitcoindRpc)
}
}
case class NeutrinoNodeFundedWalletBitcoind(
node: NeutrinoNode,
wallet: Wallet,
bitcoindRpc: BitcoindRpcClient,
bip39PasswordOpt: Option[String])
extends NodeFundedWalletBitcoind
extends NodeFundedWalletBitcoind {
override def toNodeConnectedWithBitcoind: NeutrinoNodeConnectedWithBitcoind = {
NeutrinoNodeConnectedWithBitcoind(node, bitcoindRpc)
}
}

View file

@ -176,7 +176,10 @@ trait NodeUnitTest extends BitcoinSFixture with EmbeddedPg {
node <- NodeUnitTest.createSpvNode(emptyPeer)(system,
appConfig.chainConf,
appConfig.nodeConf)
//we aren't calling node.start(), but we need to call appConfig.start()
//to make sure migrations are run
_ <- node.chainConfig.start()
_ <- node.nodeConfig.start()
} yield node
}
@ -474,10 +477,9 @@ object NodeUnitTest extends P2PLogger {
//these need to be done in order, as the spv node needs to be
//stopped before the bitcoind node is stopped
val destroyedF = for {
_ <- destroyNode(fundedWalletBitcoind.node)
_ <- BitcoinSWalletTest.destroyWalletWithBitcoind(walletWithBitcoind)
_ = cleanTables(appConfig)
_ <- appConfig.stop()
_ <- BitcoinSWalletTest.destroyWallet(walletWithBitcoind.wallet)
_ <- destroyNodeConnectedWithBitcoind(
fundedWalletBitcoind.toNodeConnectedWithBitcoind)
} yield ()
destroyedF
@ -524,8 +526,6 @@ object NodeUnitTest extends P2PLogger {
}
val chainApiF = for {
_ <- checkConfigF
_ = chainAppConfig.migrate()
_ = nodeAppConfig.start()
chainHandler <- ChainUnitTest.createChainHandler()
} yield chainHandler
val nodeF = for {