mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-22 22:36:34 +01:00
Start calling appConfig.stop() in destruction fixture code (#1868)
* Start calling appConfig.stop() in destruction fixture code * Address ben's code review
This commit is contained in:
parent
d187834e1a
commit
adf6da5c5d
5 changed files with 16 additions and 11 deletions
|
@ -152,6 +152,7 @@ trait Node extends NodeApi with ChainQueryApi with P2PLogger {
|
|||
logger.info(s"Stopping node")
|
||||
val disconnectF = for {
|
||||
_ <- nodeAppConfig.stop()
|
||||
_ <- chainAppConfig.stop()
|
||||
p <- peerMsgSenderF
|
||||
disconnect <- p.disconnect()
|
||||
} yield disconnect
|
||||
|
|
|
@ -349,9 +349,10 @@ object NodeUnitTest extends P2PLogger {
|
|||
def destroyNode(node: Node)(implicit
|
||||
config: BitcoinSAppConfig,
|
||||
ec: ExecutionContext): Future[Unit] = {
|
||||
node
|
||||
.stop()
|
||||
.flatMap(_ => ChainUnitTest.destroyAllTables())
|
||||
for {
|
||||
_ <- ChainUnitTest.destroyAllTables()
|
||||
_ <- node.stop()
|
||||
} yield ()
|
||||
}
|
||||
|
||||
def destroyNodeConnectedWithBitcoind(
|
||||
|
@ -445,6 +446,7 @@ object NodeUnitTest extends P2PLogger {
|
|||
val destroyedF = for {
|
||||
_ <- destroyNode(fundedWalletBitcoind.node)
|
||||
_ <- BitcoinSWalletTest.destroyWalletWithBitcoind(walletWithBitcoind)
|
||||
_ <- appConfig.walletConf.stop()
|
||||
} yield ()
|
||||
|
||||
destroyedF
|
||||
|
|
|
@ -660,7 +660,8 @@ object BitcoinSWalletTest extends WalletLogger {
|
|||
|
||||
_ <- wallet.walletConfig.dropTable("flyway_schema_history")
|
||||
_ <- wallet.walletConfig.dropAll()
|
||||
} yield wallet.stop()
|
||||
_ <- wallet.stop()
|
||||
} yield ()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -116,22 +116,23 @@ abstract class Wallet
|
|||
} else FutureUtil.unit
|
||||
} yield ()
|
||||
|
||||
override def start(): Future[Unit] = {
|
||||
override def start(): Future[Wallet] = {
|
||||
for {
|
||||
_ <- walletConfig.start()
|
||||
_ <- downloadMissingUtxos
|
||||
} yield {
|
||||
startWalletThread()
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
override def stop(): Unit = {
|
||||
override def stop(): Future[Wallet] = {
|
||||
for {
|
||||
_ <- walletConfig.stop()
|
||||
} yield {
|
||||
stopWalletThread()
|
||||
this
|
||||
}
|
||||
()
|
||||
}
|
||||
|
||||
override def processCompactFilters(
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.bitcoins.core.protocol.transaction.{
|
|||
TransactionOutPoint,
|
||||
TransactionOutput
|
||||
}
|
||||
import org.bitcoins.core.util.FutureUtil
|
||||
import org.bitcoins.core.util.{FutureUtil, StartStopAsync}
|
||||
import org.bitcoins.core.wallet.fee.FeeUnit
|
||||
import org.bitcoins.core.wallet.utxo._
|
||||
import org.bitcoins.crypto.DoubleSha256DigestBE
|
||||
|
@ -40,7 +40,7 @@ import scala.util.{Failure, Success}
|
|||
*
|
||||
* @see [[https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki BIP44]]
|
||||
*/
|
||||
trait WalletApi extends WalletLogger {
|
||||
trait WalletApi extends WalletLogger with StartStopAsync[WalletApi] {
|
||||
|
||||
val nodeApi: NodeApi
|
||||
val chainQueryApi: ChainQueryApi
|
||||
|
@ -50,9 +50,9 @@ trait WalletApi extends WalletLogger {
|
|||
def broadcastTransaction(transaction: Transaction): Future[Unit] =
|
||||
nodeApi.broadcastTransaction(transaction)
|
||||
|
||||
def start(): Future[Unit]
|
||||
def start(): Future[WalletApi]
|
||||
|
||||
def stop(): Unit
|
||||
def stop(): Future[WalletApi]
|
||||
|
||||
/**
|
||||
* Processes the given transaction, updating our DB state if it's relevant to us.
|
||||
|
|
Loading…
Add table
Reference in a new issue