mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-13 11:35:40 +01:00
Fix postgres database not clearing after test (#4558)
* fix postgres database not clearing after test * Empty commit to run CI Co-authored-by: Chris Stewart <stewart.chris1234@gmail.com>
This commit is contained in:
parent
f487c1270e
commit
8b646802b3
2 changed files with 29 additions and 20 deletions
|
@ -52,7 +52,7 @@ trait NodeTestWithCachedBitcoind extends BaseNodeTest with CachedTor {
|
|||
makeDependentFixture[NeutrinoNodeConnectedWithBitcoind](
|
||||
build = nodeWithBitcoindBuilder,
|
||||
{ x: NeutrinoNodeConnectedWithBitcoind =>
|
||||
NodeUnitTest.destroyNode(x.node)
|
||||
NodeUnitTest.destroyNode(x.node, appConfig)
|
||||
})(test)
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ trait NodeTestWithCachedBitcoind extends BaseNodeTest with CachedTor {
|
|||
makeDependentFixture[NeutrinoNodeConnectedWithBitcoind](
|
||||
build = nodeWithBitcoindBuilder,
|
||||
{ x: NeutrinoNodeConnectedWithBitcoind =>
|
||||
tearDownNode(x.node)
|
||||
tearDownNode(x.node, appConfig)
|
||||
})(test)
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ trait NodeTestWithCachedBitcoind extends BaseNodeTest with CachedTor {
|
|||
makeDependentFixture[NeutrinoNodeConnectedWithBitcoinds](
|
||||
build = nodeWithBitcoindBuilder,
|
||||
{ x: NeutrinoNodeConnectedWithBitcoinds =>
|
||||
tearDownNode(x.node)
|
||||
tearDownNode(x.node, appConfig)
|
||||
})(test)
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ trait NodeTestWithCachedBitcoind extends BaseNodeTest with CachedTor {
|
|||
makeDependentFixture[NeutrinoNodeConnectedWithBitcoinds](
|
||||
build = nodeWithBitcoindBuilder,
|
||||
{ x: NeutrinoNodeConnectedWithBitcoinds =>
|
||||
tearDownNode(x.node)
|
||||
tearDownNode(x.node, appConfig)
|
||||
})(test)
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ trait NodeTestWithCachedBitcoind extends BaseNodeTest with CachedTor {
|
|||
makeDependentFixture[NeutrinoNodeConnectedWithBitcoind](
|
||||
build = nodeWithBitcoindBuilder,
|
||||
{ x: NeutrinoNodeConnectedWithBitcoind =>
|
||||
tearDownNode(x.node)
|
||||
tearDownNode(x.node, appConfig)
|
||||
})(test)
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ trait NodeTestWithCachedBitcoind extends BaseNodeTest with CachedTor {
|
|||
bitcoind,
|
||||
walletCallbacks = walletCallbacks)(system, appConfig),
|
||||
{ x: NeutrinoNodeFundedWalletBitcoind =>
|
||||
tearDownNodeWithBitcoind(x)
|
||||
tearDownNodeWithBitcoind(x, appConfig)
|
||||
}
|
||||
)(test)
|
||||
}
|
||||
|
@ -180,9 +180,10 @@ trait NodeTestWithCachedBitcoind extends BaseNodeTest with CachedTor {
|
|||
}
|
||||
|
||||
private def tearDownNodeWithBitcoind(
|
||||
nodeWithBitcoind: NodeFundedWalletBitcoind): Future[Unit] = {
|
||||
nodeWithBitcoind: NodeFundedWalletBitcoind,
|
||||
appConfig: BitcoinSAppConfig): Future[Unit] = {
|
||||
val node = nodeWithBitcoind.node
|
||||
val destroyNodeF = tearDownNode(node)
|
||||
val destroyNodeF = tearDownNode(node, appConfig)
|
||||
val destroyWalletF =
|
||||
BitcoinSWalletTest.destroyWallet(nodeWithBitcoind.wallet)
|
||||
for {
|
||||
|
@ -191,8 +192,10 @@ trait NodeTestWithCachedBitcoind extends BaseNodeTest with CachedTor {
|
|||
} yield ()
|
||||
}
|
||||
|
||||
private def tearDownNode(node: Node): Future[Unit] = {
|
||||
val destroyNodeF = NodeUnitTest.destroyNode(node)
|
||||
private def tearDownNode(
|
||||
node: Node,
|
||||
appConfig: BitcoinSAppConfig): Future[Unit] = {
|
||||
val destroyNodeF = NodeUnitTest.destroyNode(node, appConfig)
|
||||
for {
|
||||
_ <- destroyNodeF
|
||||
//need to stop chainAppConfig too since this is a test
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.bitcoins.testkit.node
|
||||
|
||||
import akka.actor.ActorSystem
|
||||
import org.bitcoins.asyncutil.AsyncUtil
|
||||
import org.bitcoins.chain.blockchain.ChainHandlerCached
|
||||
import org.bitcoins.chain.config.ChainAppConfig
|
||||
import org.bitcoins.chain.models._
|
||||
|
@ -29,6 +30,7 @@ import org.scalatest.FutureOutcome
|
|||
|
||||
import java.net.InetSocketAddress
|
||||
import java.time.Instant
|
||||
import scala.concurrent.duration.DurationInt
|
||||
import scala.concurrent.{ExecutionContext, Future}
|
||||
|
||||
trait NodeUnitTest extends BaseNodeTest {
|
||||
|
@ -234,13 +236,15 @@ object NodeUnitTest extends P2PLogger {
|
|||
|
||||
}
|
||||
|
||||
def destroyNode(node: Node)(implicit ec: ExecutionContext): Future[Unit] = {
|
||||
def destroyNode(node: Node, appConfig: BitcoinSAppConfig)(implicit
|
||||
ec: ExecutionContext): Future[Unit] = {
|
||||
|
||||
for {
|
||||
_ <- node.stop()
|
||||
_ <- node.nodeAppConfig.stop()
|
||||
_ <- node.chainAppConfig.stop()
|
||||
} yield {
|
||||
()
|
||||
cleanTables(appConfig)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,9 +257,8 @@ object NodeUnitTest extends P2PLogger {
|
|||
val node = nodeConnectedWithBitcoind.node
|
||||
val bitcoind = nodeConnectedWithBitcoind.bitcoind
|
||||
val resultF = for {
|
||||
_ <- destroyNode(node)
|
||||
_ <- destroyNode(node, appConfig)
|
||||
_ <- ChainUnitTest.destroyBitcoind(bitcoind)
|
||||
_ = cleanTables(appConfig)
|
||||
_ <- appConfig.stop()
|
||||
} yield {
|
||||
logger.debug(s"Done with teardown of node connected with bitcoind!")
|
||||
|
@ -274,8 +277,7 @@ object NodeUnitTest extends P2PLogger {
|
|||
import system.dispatcher
|
||||
val node = nodeConnectedWithBitcoind.node
|
||||
val resultF = for {
|
||||
_ <- destroyNode(node)
|
||||
_ = cleanTables(appConfig)
|
||||
_ <- destroyNode(node, appConfig)
|
||||
_ <- appConfig.stop()
|
||||
} yield {
|
||||
logger.debug(s"Done with teardown of node connected with bitcoind!")
|
||||
|
@ -513,9 +515,13 @@ object NodeUnitTest extends P2PLogger {
|
|||
_ <- NodeTestUtil.awaitSync(node, bitcoind)
|
||||
_ <- NodeTestUtil.awaitCompactFilterHeadersSync(node, bitcoind)
|
||||
_ <- NodeTestUtil.awaitCompactFiltersSync(node, bitcoind)
|
||||
syncing <- node.chainApiFromDb().flatMap(_.isSyncing())
|
||||
_ = assert(!syncing)
|
||||
|
||||
_ <- AsyncUtil.retryUntilSatisfiedF(
|
||||
() => {
|
||||
val syncingF = node.chainApiFromDb().flatMap(_.isSyncing())
|
||||
syncingF.map(!_)
|
||||
},
|
||||
interval = 1.second,
|
||||
maxTries = 5)
|
||||
} yield node
|
||||
}
|
||||
|
||||
|
@ -527,7 +533,7 @@ object NodeUnitTest extends P2PLogger {
|
|||
*/
|
||||
private def cleanTables(appConfig: BitcoinSAppConfig): Unit = {
|
||||
appConfig.nodeConf.clean()
|
||||
//appConfig.walletConf.clean()
|
||||
appConfig.walletConf.clean()
|
||||
appConfig.chainConf.clean()
|
||||
()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue