Get rest of codebase compiling with -Xsource:3 (#5592)

This commit is contained in:
Chris Stewart 2024-05-11 14:13:36 -05:00 committed by GitHub
parent 0af58483f2
commit a6b7fada50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 64 additions and 47 deletions

View File

@ -15,7 +15,7 @@ case class CommonRoutes(datadir: Path) extends ServerRoute {
case ServerCommand("getversion", _) =>
complete {
val version =
Option(EnvUtil.getVersion).map(ujson.Str).getOrElse(ujson.Null)
Option(EnvUtil.getVersion).map(ujson.Str.apply).getOrElse(ujson.Null)
val vec = Vector(("version", version))
val obj = ujson.Obj.from(vec)
Server.httpSuccess(obj)

View File

@ -24,7 +24,7 @@ class BitcoinSServerMainBitcoindTest
behavior of "BitcoinSServerMain"
it must "start our app server with bitcoind as a backend" in {
config: BitcoinSAppConfig =>
(config: BitcoinSAppConfig) =>
val server = new BitcoinSServerMain(ServerArgParser.empty)(system, config)
val cliConfig = Config(
@ -50,7 +50,7 @@ class BitcoinSServerMainBitcoindTest
}
}
it must "load wallet" in { config: BitcoinSAppConfig =>
it must "load wallet" in { (config: BitcoinSAppConfig) =>
val alice = None
val bob = Some("bob")
@ -125,7 +125,7 @@ class BitcoinSServerMainBitcoindTest
}
it must "fail to send requests to the app server if the password is bad" in {
config: BitcoinSAppConfig =>
(config: BitcoinSAppConfig) =>
val server = new BitcoinSServerMain(ServerArgParser.empty)(system, config)
val cliConfig =

View File

@ -18,7 +18,7 @@ class BitcoinSServerMainBitcoindTorTest
behavior of "BitcoinSServerMain"
it must "start our app server with bitcoind as a backend with tor" in {
config: BitcoinSAppConfig =>
(config: BitcoinSAppConfig) =>
val server = new BitcoinSServerMain(ServerArgParser.empty)(system, config)
val cliConfig = Config(

View File

@ -241,7 +241,7 @@ object BitcoindRpcBackendUtil extends BitcoinSLogger {
val rawTxSub = zmqConfig.rawTx.map { zmq =>
val rawTxListener: Option[Transaction => Unit] = Some {
{ tx: Transaction =>
{ (tx: Transaction) =>
logger.debug(s"Received tx ${tx.txIdBE.hex}, processing")
val f = wallet.processTransaction(tx, None)
f.failed.foreach { err =>
@ -262,7 +262,7 @@ object BitcoindRpcBackendUtil extends BitcoinSLogger {
val rawBlockSub = zmqConfig.rawBlock.map { zmq =>
val rawBlockListener: Option[Block => Unit] = Some {
{ block: Block =>
{ (block: Block) =>
logger.info(
s"Received block ${block.blockHeader.hashBE.hex}, processing"
)
@ -546,7 +546,7 @@ object BitcoindRpcBackendUtil extends BitcoinSLogger {
}
val (queue, doneF) = queueSource
.mapAsync(parallelism = numParallelism) { height: Int =>
.mapAsync(parallelism = numParallelism) { (height: Int) =>
bitcoind.getBlockHash(height)
}
.map { hash =>

View File

@ -81,8 +81,8 @@ case class DLCRoutes(dlcNode: DLCNodeApi)(implicit system: ActorSystem)
Obj(
"hash" -> io.hash.hex,
"receivedAt" -> Num(io.receivedAt.getEpochSecond.toDouble),
"peer" -> io.peer.map(Str).getOrElse(Null),
"message" -> io.message.map(Str).getOrElse(Null),
"peer" -> io.peer.map(Str.apply).getOrElse(Null),
"message" -> io.message.map(Str.apply).getOrElse(Null),
"offerTLV" -> io.offerTLV.hex
)
}

View File

@ -50,7 +50,7 @@ object CallbackUtil extends BitcoinSLogger {
}
val onHeaderSink = {
Sink.foreachAsync(1) { headers: Vector[BlockHeader] =>
Sink.foreachAsync(1) { (headers: Vector[BlockHeader]) =>
logger.debug(
s"Executing block header with header count=${headers.length}"
)

View File

@ -270,19 +270,19 @@ object WebsocketUtil extends BitcoinSLogger {
walletQueue: SourceQueueWithComplete[WsNotification[_]]
)(implicit system: ActorSystem): DLCWalletCallbackStreamManager = {
import system.dispatcher
val onStateChange: OnDLCStateChange = { status: DLCStatus =>
val onStateChange: OnDLCStateChange = { (status: DLCStatus) =>
val notification = WalletNotification.DLCStateChangeNotification(status)
val offerF = walletQueue.offer(notification)
offerF.map(_ => ())
}
val onOfferAdd: OnDLCOfferAdd = { offerDb: IncomingDLCOfferDb =>
val onOfferAdd: OnDLCOfferAdd = { (offerDb: IncomingDLCOfferDb) =>
val notification = WalletNotification.DLCOfferAddNotification(offerDb)
val offerF = walletQueue.offer(notification)
offerF.map(_ => ())
}
val onOfferRemove: OnDLCOfferRemove = { offerHash: Sha256Digest =>
val onOfferRemove: OnDLCOfferRemove = { (offerHash: Sha256Digest) =>
val notification =
WalletNotification.DLCOfferRemoveNotification(offerHash)
val offerF = walletQueue.offer(notification)

View File

@ -152,12 +152,14 @@ lazy val clightningRpc = project
lazy val lnurl = project
.in(file("lnurl"))
.settings(scalacOptions += "-Xsource:3")
.settings(name := "bitcoin-s-lnurl")
.settings(CommonSettings.prodSettings: _*)
.dependsOn(appCommons, asyncUtilsJVM, tor)
lazy val lnurlTest = project
.in(file("lnurl-test"))
.settings(scalacOptions += "-Xsource:3")
.settings(name := "bitcoin-s-lnurl-test")
.settings(CommonSettings.testSettings: _*)
.dependsOn(lnurl, testkit)
@ -315,6 +317,7 @@ lazy val `bitcoin-s` = project
lazy val secp256k1jni = project
.in(file("secp256k1jni"))
.settings(scalacOptions += "-Xsource:3")
.settings(CommonSettings.prodSettings: _*)
.settings(
libraryDependencies ++= Deps.secp256k1jni,
@ -389,6 +392,7 @@ lazy val appCommonsTest = project
lazy val oracleServer = project
.in(file("app/oracle-server"))
.settings(scalacOptions += "-Xsource:3")
.settings(CommonSettings.appSettings: _*)
.settings(CommonSettings.dockerSettings: _*)
.settings(CommonSettings.dockerBuildxSettings: _*)
@ -407,6 +411,7 @@ lazy val oracleServer = project
lazy val oracleServerTest = project
.in(file("app/oracle-server-test"))
.settings(scalacOptions += "-Xsource:3")
.settings(CommonSettings.testSettings: _*)
.settings(libraryDependencies ++= Deps.walletServerTest)
.dependsOn(
@ -416,6 +421,7 @@ lazy val oracleServerTest = project
lazy val serverRoutes = project
.in(file("app/server-routes"))
.settings(scalacOptions += "-Xsource:3")
.settings(CommonSettings.prodSettings: _*)
.settings(name := "bitcoin-s-server-routes")
.settings(libraryDependencies ++= Deps.serverRoutes)
@ -423,6 +429,7 @@ lazy val serverRoutes = project
lazy val appServer = project
.in(file("app/server"))
.settings(scalacOptions += "-Xsource:3")
.settings(CommonSettings.appSettings: _*)
.settings(CommonSettings.dockerSettings: _*)
.settings(CommonSettings.dockerBuildxSettings: _*)
@ -449,6 +456,7 @@ lazy val appServer = project
lazy val appServerTest = project
.in(file("app/server-test"))
.settings(scalacOptions += "-Xsource:3")
.settings(CommonSettings.testSettings: _*)
.settings(libraryDependencies ++= Deps.walletServerTest)
.dependsOn(
@ -460,6 +468,7 @@ lazy val appServerTest = project
lazy val cli = project
.in(file("app/cli"))
.settings(CommonSettings.prodSettings: _*)
.settings(scalacOptions += "-Xsource:3")
.settings(
name := "bitcoin-s-cli"
)
@ -473,6 +482,7 @@ lazy val cli = project
lazy val cliTest = project
.in(file("app/cli-test"))
.settings(scalacOptions += "-Xsource:3")
.settings(CommonSettings.testSettings: _*)
.dependsOn(
cli,
@ -520,6 +530,7 @@ lazy val dbCommonsTest = project
lazy val esplora = project
.in(file("esplora"))
.settings(scalacOptions += "-Xsource:3")
.settings(CommonSettings.prodSettings: _*)
.settings(
name := "bitcoin-s-esplora",
@ -529,6 +540,7 @@ lazy val esplora = project
lazy val esploraTest = project
.in(file("esplora-test"))
.settings(scalacOptions += "-Xsource:3")
.settings(CommonSettings.testSettings: _*)
.settings(
name := "bitcoin-s-esplora-test",
@ -538,6 +550,7 @@ lazy val esploraTest = project
lazy val feeProvider = project
.in(file("fee-provider"))
.settings(scalacOptions += "-Xsource:3")
.settings(CommonSettings.prodSettings: _*)
.settings(
name := "bitcoin-s-fee-provider",
@ -547,6 +560,7 @@ lazy val feeProvider = project
lazy val feeProviderTest = project
.in(file("fee-provider-test"))
.settings(scalacOptions += "-Xsource:3")
.settings(CommonSettings.testSettings: _*)
.settings(
name := "bitcoin-s-fee-provider-test",
@ -667,6 +681,7 @@ lazy val nodeTest =
lazy val testkit = project
.in(file("testkit"))
.settings(CommonSettings.prodSettings: _*)
.settings(scalacOptions += "-Xsource:3")
.settings(
name := "bitcoin-s-testkit",
libraryDependencies ++= Deps.testkit.value

View File

@ -46,6 +46,7 @@ case class BitGoFeeRateProvider(
feeRanges: Map[Int, SatoshisPerKiloByte],
blockTarget: Int
): SatoshisPerKiloByte = {
import org.bitcoins.core.satoshisPerKiloByteOrdering
// first we keep only fee ranges with a max block delay below the limit
val belowLimit = feeRanges.filter(_._1 <= blockTarget)
// out of all the remaining fee ranges, we select the one with the minimum higher bound

View File

@ -54,7 +54,7 @@ object TestAsyncUtil extends TestAsyncUtil {
val line = stackElement.getLineNumber
val pos = org.scalactic.source.Position(file, path, line)
val newErr = new TestFailedException(
{ _: StackDepthException =>
{ (_: StackDepthException) =>
Some(retryErr.message)
},
None,
@ -68,7 +68,7 @@ object TestAsyncUtil extends TestAsyncUtil {
}
fut.transform(
{ elem: T =>
{ (elem: T) =>
elem
},
transformRetry

View File

@ -100,10 +100,10 @@ trait ChainUnitTest
]]
)(implicit pos: org.scalactic.source.Position): Unit = {
val testFun: FixtureParam => Future[compatible.Assertion] = {
fixture: FixtureParam =>
(fixture: FixtureParam) =>
partialTestFun.applyOrElse[FixtureParam, Future[Assertion]](
fixture,
{ _: FixtureParam =>
{ (_: FixtureParam) =>
Future(fail("Incorrect tag/fixture for this test"))
}
)
@ -131,10 +131,10 @@ trait ChainUnitTest
]]
)(implicit pos: org.scalactic.source.Position): Unit = {
val testFun: FixtureParam => Future[compatible.Assertion] = {
fixture: FixtureParam =>
(fixture: FixtureParam) =>
partialTestFun.applyOrElse[FixtureParam, Future[Assertion]](
fixture,
{ _: FixtureParam =>
{ (_: FixtureParam) =>
Future(fail("Incorrect tag/fixture for this test"))
}
)
@ -281,7 +281,7 @@ trait ChainUnitTest
): Future[(ChainHandler, ZMQSubscriber)] = {
val zmqRawBlockUriOpt: Option[InetSocketAddress] =
bitcoind.instance.zmqConfig.rawBlock
val handleRawBlock: Block => Unit = { block: Block =>
val handleRawBlock: Block => Unit = { (block: Block) =>
val chainApiF =
ChainHandler.fromDatabase()(executionContext, chainAppConfig)
@ -368,7 +368,7 @@ trait ChainUnitTest
val builder: () => Future[BitcoindChainHandlerViaZmq] =
BitcoinSFixture.composeBuildersAndWrap(
builder = () => BitcoinSFixture.createBitcoind(),
dependentBuilder = { rpc: BitcoindRpcClient =>
dependentBuilder = { (rpc: BitcoindRpcClient) =>
createChainHandlerWithBitcoindZmq(rpc)(chainAppConfig)
},
wrap = BitcoindChainHandlerViaZmq.apply
@ -772,7 +772,7 @@ object ChainUnitTest extends ChainVerificationLogger {
bitcoind.getBestBlockHash()
}
val getBlockHeaderFunc = { hash: DoubleSha256DigestBE =>
val getBlockHeaderFunc = { (hash: DoubleSha256DigestBE) =>
bitcoind.getBlockHeader(hash).map(_.blockHeader)
}

View File

@ -41,7 +41,7 @@ abstract class SyncUtil extends BitcoinSLogger {
def getBlockHeaderFunc(bitcoind: BitcoindRpcClient)(implicit
ec: ExecutionContext
): DoubleSha256DigestBE => Future[BlockHeader] = {
hash: DoubleSha256DigestBE =>
(hash: DoubleSha256DigestBE) =>
bitcoind.getBlockHeader(hash).map(_.blockHeader)
}

View File

@ -157,7 +157,7 @@ trait CLightningRpcTestUtil extends BitcoinSLogger {
"Successfully shutdown clightning and it's corresponding bitcoind"
)
}
shutdownF.failed.foreach { err: Throwable =>
shutdownF.failed.foreach { (err: Throwable) =>
logger.info(
s"Killed a bitcoind instance, but could not find an clightning process to kill"
)

View File

@ -58,7 +58,7 @@ trait BitcoinSDLCNodeTest extends BitcoinSWalletTest with CachedTor {
_ <- nodeB.start()
} yield (nodeA, nodeB)
},
destroy = { nodes: (DLCNode, DLCNode) =>
destroy = { (nodes: (DLCNode, DLCNode)) =>
for {
_ <- destroyDLCWallet(nodes._1.wallet.asInstanceOf[DLCWallet])
_ <- destroyDLCWallet(nodes._2.wallet.asInstanceOf[DLCWallet])

View File

@ -814,7 +814,7 @@ trait EclairRpcTestUtil extends BitcoinSLogger {
"Successfully shutdown eclair"
)
}
shutdownF.failed.foreach { err: Throwable =>
shutdownF.failed.foreach { (err: Throwable) =>
logger.error(
s"Could kill eclair process",
err

View File

@ -173,7 +173,7 @@ trait LndRpcTestUtil extends BitcoinSLogger {
} yield {
logger.debug("Successfully shutdown lnd and it's corresponding bitcoind")
}
shutdownF.failed.foreach { err: Throwable =>
shutdownF.failed.foreach { (err: Throwable) =>
logger.info(
s"Killed a bitcoind instance, but could not find an lnd process to kill"
)

View File

@ -56,7 +56,7 @@ trait NodeTestWithCachedBitcoind extends BaseNodeTest with CachedTor {
makeDependentFixture[NeutrinoNodeConnectedWithBitcoind](
build = nodeWithBitcoindBuilder,
{ x: NeutrinoNodeConnectedWithBitcoind =>
{ (x: NeutrinoNodeConnectedWithBitcoind) =>
NodeUnitTest.destroyNode(x.node, appConfig)
}
)(test)
@ -83,7 +83,7 @@ trait NodeTestWithCachedBitcoind extends BaseNodeTest with CachedTor {
}
makeDependentFixture[NeutrinoNodeConnectedWithBitcoind](
build = nodeWithBitcoindBuilder,
{ x: NeutrinoNodeConnectedWithBitcoind =>
{ (x: NeutrinoNodeConnectedWithBitcoind) =>
tearDownNode(x.node, appConfig)
}
)(test)
@ -115,7 +115,7 @@ trait NodeTestWithCachedBitcoind extends BaseNodeTest with CachedTor {
}
makeDependentFixture[NeutrinoNodeConnectedWithBitcoinds](
build = nodeWithBitcoindBuilder,
{ x: NeutrinoNodeConnectedWithBitcoinds =>
{ (x: NeutrinoNodeConnectedWithBitcoinds) =>
tearDownNode(x.node, appConfig)
}
)(test)
@ -144,7 +144,7 @@ trait NodeTestWithCachedBitcoind extends BaseNodeTest with CachedTor {
}
makeDependentFixture[NeutrinoNodeConnectedWithBitcoinds](
build = nodeWithBitcoindBuilder,
{ x: NeutrinoNodeConnectedWithBitcoinds =>
{ (x: NeutrinoNodeConnectedWithBitcoinds) =>
tearDownNode(x.node, appConfig)
}
)(test)
@ -173,7 +173,7 @@ trait NodeTestWithCachedBitcoind extends BaseNodeTest with CachedTor {
}
makeDependentFixture[NeutrinoNodeConnectedWithBitcoind](
build = nodeWithBitcoindBuilder,
{ x: NeutrinoNodeConnectedWithBitcoind =>
{ (x: NeutrinoNodeConnectedWithBitcoind) =>
tearDownNode(x.node, appConfig)
}
)(test)
@ -194,7 +194,7 @@ trait NodeTestWithCachedBitcoind extends BaseNodeTest with CachedTor {
bitcoind,
walletCallbacks = walletCallbacks
)(system, appConfig),
{ x: NeutrinoNodeFundedWalletBitcoind =>
{ (x: NeutrinoNodeFundedWalletBitcoind) =>
tearDownNodeWithBitcoind(x, appConfig)
}
)(test)

View File

@ -73,7 +73,7 @@ trait BitcoinSDualWalletTest extends BitcoinSWalletTest {
walletB <- FundWalletUtil
.createFundedDLCWallet(nodeApi, chainQueryApi)(config2, system)
} yield (walletA, walletB),
destroy = { fundedWallets: (FundedDLCWallet, FundedDLCWallet) =>
destroy = { (fundedWallets: (FundedDLCWallet, FundedDLCWallet)) =>
for {
_ <- destroyDLCWallet(fundedWallets._1.wallet)
_ <- destroyDLCWallet(fundedWallets._2.wallet)
@ -91,7 +91,7 @@ trait BitcoinSDualWalletTest extends BitcoinSWalletTest {
build = () => {
createDualFundedDLCWallet(nodeApi = bitcoind, chainQueryApi = bitcoind)
},
destroy = { fundedWallets: (FundedDLCWallet, FundedDLCWallet) =>
destroy = { (fundedWallets: (FundedDLCWallet, FundedDLCWallet)) =>
destroyDLCWallets(
dlcWallet1 = fundedWallets._1.wallet,
dlcWallet2 = fundedWallets._2.wallet
@ -143,7 +143,7 @@ trait BitcoinSDualWalletTest extends BitcoinSWalletTest {
chainQueryApi = chainQueryApi
)
},
destroy = { dlcWallets: (InitializedDLCWallet, InitializedDLCWallet) =>
destroy = { (dlcWallets: (InitializedDLCWallet, InitializedDLCWallet)) =>
destroyDLCWallets(
dlcWallet1 = dlcWallets._1.wallet,
dlcWallet2 = dlcWallets._2.wallet
@ -164,7 +164,7 @@ trait BitcoinSDualWalletTest extends BitcoinSWalletTest {
bitcoind = bitcoind
)
},
destroy = { dlcWallets: (InitializedDLCWallet, InitializedDLCWallet) =>
destroy = { (dlcWallets: (InitializedDLCWallet, InitializedDLCWallet)) =>
destroyDLCWallets(
dlcWallet1 = dlcWallets._1.wallet,
dlcWallet2 = dlcWallets._2.wallet

View File

@ -94,7 +94,7 @@ trait BitcoinSWalletTest
)(implicit walletAppConfig: WalletAppConfig): FutureOutcome = {
makeDependentFixture(
build = () => FundWalletUtil.createFundedWallet(nodeApi, chainQueryApi),
destroy = { funded: FundedWallet =>
destroy = { (funded: FundedWallet) =>
for {
_ <- destroyWallet(funded.wallet)
_ <- destroyWalletAppConfig(walletAppConfig)
@ -108,7 +108,7 @@ trait BitcoinSWalletTest
)(implicit walletAppConfig: WalletAppConfig): FutureOutcome = {
makeDependentFixture(
build = () => FundWalletUtil.createFundedWallet(nodeApi, chainQueryApi),
destroy = { funded: FundedWallet =>
destroy = { (funded: FundedWallet) =>
for {
_ <- destroyWallet(funded.wallet)
_ <- destroyWalletAppConfig(walletAppConfig)
@ -127,7 +127,7 @@ trait BitcoinSWalletTest
makeDependentFixture(
build =
() => FundWalletUtil.createFundedDLCWallet(nodeApi, chainQueryApi),
destroy = { funded: FundedDLCWallet =>
destroy = { (funded: FundedDLCWallet) =>
for {
_ <- destroyDLCWallet(funded.wallet)
} yield ()

View File

@ -65,7 +65,7 @@ trait DualWalletTestCachedBitcoind
bitcoind
)(config2, system)
} yield (walletA, walletB, bitcoind),
destroy = { fundedWallets: (FundedDLCWallet, FundedDLCWallet, _) =>
destroy = { (fundedWallets: (FundedDLCWallet, FundedDLCWallet, _)) =>
for {
_ <- destroyDLCWallet(fundedWallets._1.wallet)
_ <- destroyDLCWallet(fundedWallets._2.wallet)
@ -107,11 +107,12 @@ trait DualWalletTestCachedBitcoind
bitcoind <- bitcoindF
} yield (dlcWalletA, dlcWalletB, bitcoind)
},
destroy = { dlcWallets: (InitializedDLCWallet, InitializedDLCWallet, _) =>
for {
_ <- destroyDLCWallet(dlcWallets._1.wallet)
_ <- destroyDLCWallet(dlcWallets._2.wallet)
} yield ()
destroy = {
(dlcWallets: (InitializedDLCWallet, InitializedDLCWallet, _)) =>
for {
_ <- destroyDLCWallet(dlcWallets._1.wallet)
_ <- destroyDLCWallet(dlcWallets._2.wallet)
} yield ()
}
)(test)
}