mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-03 10:46:42 +01:00
Deprecate generate (#728)
This commit is contained in:
parent
8a58d7dde8
commit
e0a5646258
19 changed files with 127 additions and 100 deletions
|
@ -133,7 +133,7 @@ class BitcoindInstanceTest extends BitcoindRpcTest {
|
|||
|
||||
for {
|
||||
_ <- client.start()
|
||||
_ <- client.generate(101)
|
||||
_ <- client.getNewAddress.flatMap(client.generateToAddress(101, _))
|
||||
balance <- client.getBalance
|
||||
_ <- BitcoindRpcTestUtil.stopServers(Vector(client))
|
||||
_ <- client.getBalance
|
||||
|
|
|
@ -26,7 +26,8 @@ class BlockchainRpcTest extends BitcoindRpcTest {
|
|||
|
||||
for {
|
||||
_ <- pruneClient.start()
|
||||
_ <- pruneClient.generate(1000)
|
||||
_ <- pruneClient.getNewAddress.flatMap(
|
||||
pruneClient.generateToAddress(1000, _))
|
||||
} yield pruneClient
|
||||
}
|
||||
|
||||
|
@ -90,14 +91,14 @@ class BlockchainRpcTest extends BitcoindRpcTest {
|
|||
address <- otherClient.getNewAddress(addressType = AddressType.P2SHSegwit)
|
||||
txid <- BitcoindRpcTestUtil
|
||||
.fundMemPoolTransaction(client, address, Bitcoins(1))
|
||||
blocks <- client.generate(1)
|
||||
blocks <- client.getNewAddress.flatMap(client.generateToAddress(1, _))
|
||||
mostRecentBlock <- client.getBlock(blocks.head)
|
||||
_ <- client.invalidateBlock(blocks.head)
|
||||
mempool <- client.getRawMemPool
|
||||
count1 <- client.getBlockCount
|
||||
count2 <- otherClient.getBlockCount
|
||||
|
||||
_ <- client.generate(2) // Ensure client and otherClient have the same blockchain
|
||||
_ <- client.getNewAddress.flatMap(client.generateToAddress(2, _)) // Ensure client and otherClient have the same blockchain
|
||||
} yield {
|
||||
assert(mostRecentBlock.tx.contains(txid))
|
||||
assert(mempool.contains(txid))
|
||||
|
@ -108,7 +109,7 @@ class BlockchainRpcTest extends BitcoindRpcTest {
|
|||
it should "be able to get block hash by height" in {
|
||||
for {
|
||||
(client, _) <- clientsF
|
||||
blocks <- client.generate(2)
|
||||
blocks <- client.getNewAddress.flatMap(client.generateToAddress(2, _))
|
||||
count <- client.getBlockCount
|
||||
hash <- client.getBlockHash(count)
|
||||
prevhash <- client.getBlockHash(count - 1)
|
||||
|
@ -125,8 +126,10 @@ class BlockchainRpcTest extends BitcoindRpcTest {
|
|||
_ <- freshClient.disconnectNode(otherFreshClient.getDaemon.uri)
|
||||
_ <- BitcoindRpcTestUtil.awaitDisconnected(freshClient, otherFreshClient)
|
||||
|
||||
blocks1 <- freshClient.generate(1)
|
||||
blocks2 <- otherFreshClient.generate(1)
|
||||
blocks1 <- freshClient.getNewAddress.flatMap(
|
||||
freshClient.generateToAddress(1, _))
|
||||
blocks2 <- otherFreshClient.getNewAddress.flatMap(
|
||||
otherFreshClient.generateToAddress(1, _))
|
||||
|
||||
bestHash1 <- freshClient.getBestBlockHash
|
||||
_ = assert(bestHash1 == blocks1.head)
|
||||
|
@ -182,7 +185,7 @@ class BlockchainRpcTest extends BitcoindRpcTest {
|
|||
it should "be able to get a raw block" in {
|
||||
for {
|
||||
(client, _) <- clientsF
|
||||
blocks <- client.generate(1)
|
||||
blocks <- client.getNewAddress.flatMap(client.generateToAddress(1, _))
|
||||
block <- client.getBlockRaw(blocks.head)
|
||||
blockHeader <- client.getBlockHeaderRaw(blocks.head)
|
||||
} yield assert(block.blockHeader == blockHeader)
|
||||
|
@ -191,7 +194,7 @@ class BlockchainRpcTest extends BitcoindRpcTest {
|
|||
it should "be able to get a block" in {
|
||||
for {
|
||||
(client, _) <- clientsF
|
||||
blocks <- client.generate(1)
|
||||
blocks <- client.getNewAddress.flatMap(client.generateToAddress(1, _))
|
||||
block <- client.getBlock(blocks.head)
|
||||
} yield {
|
||||
assert(block.hash == blocks(0))
|
||||
|
@ -222,7 +225,7 @@ class BlockchainRpcTest extends BitcoindRpcTest {
|
|||
it should "be able to get a block with verbose transactions" in {
|
||||
for {
|
||||
(client, _) <- clientsF
|
||||
blocks <- client.generate(2)
|
||||
blocks <- client.getNewAddress.flatMap(client.generateToAddress(2, _))
|
||||
block <- client.getBlockWithTransactions(blocks(1))
|
||||
} yield {
|
||||
assert(block.hash == blocks(1))
|
||||
|
@ -249,7 +252,7 @@ class BlockchainRpcTest extends BitcoindRpcTest {
|
|||
it should "be able to list all blocks since a given block" in {
|
||||
for {
|
||||
(client, _) <- clientsF
|
||||
blocks <- client.generate(3)
|
||||
blocks <- client.getNewAddress.flatMap(client.generateToAddress(3, _))
|
||||
list <- client.listSinceBlock(blocks(0))
|
||||
} yield {
|
||||
assert(list.transactions.length >= 2)
|
||||
|
|
|
@ -91,7 +91,7 @@ class MempoolRpcTest extends BitcoindRpcTest {
|
|||
it should "be able to get mem pool info" in {
|
||||
for {
|
||||
(client, otherClient) <- clientsF
|
||||
_ <- client.generate(1)
|
||||
_ <- client.getNewAddress.flatMap(client.generateToAddress(1, _))
|
||||
info <- client.getMemPoolInfo
|
||||
_ <- BitcoindRpcTestUtil
|
||||
.sendCoinbaseTransaction(client, otherClient)
|
||||
|
@ -122,7 +122,7 @@ class MempoolRpcTest extends BitcoindRpcTest {
|
|||
it should "be able to find mem pool ancestors and descendants" in {
|
||||
for {
|
||||
(client, _) <- clientsF
|
||||
_ <- client.generate(1)
|
||||
_ <- client.getNewAddress.flatMap(client.generateToAddress(1, _))
|
||||
address1 <- client.getNewAddress
|
||||
txid1 <- BitcoindRpcTestUtil.fundMemPoolTransaction(client,
|
||||
address1,
|
||||
|
|
|
@ -31,7 +31,7 @@ class MiningRpcTest extends BitcoindRpcTest {
|
|||
it should "be able to generate blocks" in {
|
||||
for {
|
||||
(client, _) <- clientsF
|
||||
blocks <- client.generate(3)
|
||||
blocks <- client.getNewAddress.flatMap(client.generateToAddress(3, _))
|
||||
} yield assert(blocks.length == 3)
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ class MiningRpcTest extends BitcoindRpcTest {
|
|||
it should "be able to generate blocks and then get their serialized headers" in {
|
||||
for {
|
||||
(client, _) <- clientsF
|
||||
blocks <- client.generate(2)
|
||||
blocks <- client.getNewAddress.flatMap(client.generateToAddress(2, _))
|
||||
header <- client.getBlockHeaderRaw(blocks(1))
|
||||
} yield assert(header.previousBlockHashBE == blocks(0))
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ class MiningRpcTest extends BitcoindRpcTest {
|
|||
it should "be able to generate blocks and then get their headers" in {
|
||||
for {
|
||||
(client, _) <- clientsF
|
||||
blocks <- client.generate(2)
|
||||
blocks <- client.getNewAddress.flatMap(client.generateToAddress(2, _))
|
||||
firstHeader <- client.getBlockHeader(blocks(0))
|
||||
secondHeader <- client.getBlockHeader(blocks(1))
|
||||
} yield {
|
||||
|
|
|
@ -17,7 +17,9 @@ class NodeRpcTest extends BitcoindRpcTest {
|
|||
it should "be able to abort a rescan of the blockchain" in {
|
||||
clientF.flatMap { client =>
|
||||
// generate some extra blocks so rescan isn't too quick
|
||||
client.generate(3000).flatMap { _ =>
|
||||
client.getNewAddress
|
||||
.flatMap(client.generateToAddress(3000, _))
|
||||
.flatMap { _ =>
|
||||
val rescanFailedF =
|
||||
recoverToSucceededIf[MiscError](client.rescanBlockChain())
|
||||
client.abortRescan().flatMap { _ =>
|
||||
|
|
|
@ -187,7 +187,7 @@ class P2PRpcTest extends BitcoindRpcTest {
|
|||
|
||||
(client1, client2) <- BitcoindRpcTestUtil.createUnconnectedNodePair(
|
||||
clientAccum = clientAccum)
|
||||
hash <- client2.generate(1)
|
||||
hash <- client2.getNewAddress.flatMap(client2.generateToAddress(1, _))
|
||||
block <- client2.getBlockRaw(hash.head)
|
||||
preCount1 <- client1.getBlockCount
|
||||
preCount2 <- client2.getBlockCount
|
||||
|
|
|
@ -88,7 +88,7 @@ class RawTransactionRpcTest extends BitcoindRpcTest {
|
|||
it should "be able to create a raw transaction" in {
|
||||
for {
|
||||
(client, otherClient) <- clientsF
|
||||
blocks <- client.generate(2)
|
||||
blocks <- client.getNewAddress.flatMap(client.generateToAddress(2, _))
|
||||
firstBlock <- client.getBlock(blocks(0))
|
||||
transaction0 <- client.getTransaction(firstBlock.tx(0))
|
||||
secondBlock <- client.getBlock(blocks(1))
|
||||
|
@ -123,7 +123,7 @@ class RawTransactionRpcTest extends BitcoindRpcTest {
|
|||
otherClient)
|
||||
signedTransaction <- BitcoindRpcTestUtil.signRawTransaction(client, rawTx)
|
||||
|
||||
_ <- client.generate(100) // Can't spend coinbase until depth 100
|
||||
_ <- client.getNewAddress.flatMap(client.generateToAddress(100, _)) // Can't spend coinbase until depth 100
|
||||
|
||||
_ <- client.sendRawTransaction(signedTransaction.hex,
|
||||
allowHighFees = true)
|
||||
|
|
|
@ -40,7 +40,8 @@ class WalletRpcTest extends BitcoindRpcTest {
|
|||
|
||||
for {
|
||||
_ <- walletClient.start()
|
||||
_ <- walletClient.generate(200)
|
||||
_ <- walletClient.getNewAddress.flatMap(
|
||||
walletClient.generateToAddress(200, _))
|
||||
_ <- walletClient.encryptWallet(password)
|
||||
_ <- walletClient.stop()
|
||||
_ <- RpcUtil.awaitServerShutdown(walletClient)
|
||||
|
@ -220,7 +221,7 @@ class WalletRpcTest extends BitcoindRpcTest {
|
|||
.fundBlockChainTransaction(client, address, Bitcoins(1.5))
|
||||
val txid = await(txidF)
|
||||
|
||||
await(client.generate(1))
|
||||
await(client.getNewAddress.flatMap(client.generateToAddress(1, _)))
|
||||
|
||||
val tx = await(client.getTransaction(txid))
|
||||
|
||||
|
@ -344,7 +345,7 @@ class WalletRpcTest extends BitcoindRpcTest {
|
|||
for {
|
||||
(client, _, _) <- clientsF
|
||||
balance <- client.getBalance
|
||||
_ <- client.generate(1)
|
||||
_ <- client.getNewAddress.flatMap(client.generateToAddress(1, _))
|
||||
newBalance <- client.getBalance
|
||||
} yield {
|
||||
assert(balance.toBigDecimal > 0)
|
||||
|
|
|
@ -42,7 +42,8 @@ class BitcoindV16RpcClientTest extends BitcoindRpcTest {
|
|||
(client, otherClient) <- clientsF
|
||||
addr <- client.getNewAddress
|
||||
_ <- otherClient.sendToAddress(addr, Bitcoins.one)
|
||||
_ <- otherClient.generate(6)
|
||||
_ <- otherClient.getNewAddress.flatMap(
|
||||
otherClient.generateToAddress(6, _))
|
||||
peers <- client.getPeerInfo
|
||||
_ = assert(peers.exists(_.networkInfo.addr == otherClient.getDaemon.uri))
|
||||
|
||||
|
|
|
@ -213,7 +213,8 @@ class BitcoindV17RpcClientTest extends BitcoindRpcTest {
|
|||
addressNoLabel <- client.getNewAddress
|
||||
_ <- otherClient.sendToAddress(addressNoLabel, Bitcoins.one)
|
||||
_ <- otherClient.sendToAddress(addressWithLabel, Bitcoins.one)
|
||||
newBlock +: _ <- otherClient.generate(1)
|
||||
newBlock +: _ <- client.getNewAddress.flatMap(
|
||||
otherClient.generateToAddress(1, _))
|
||||
_ <- AsyncUtil.retryUntilSatisfiedF(() =>
|
||||
BitcoindRpcTestUtil.hasSeenBlock(client, newBlock))
|
||||
list <- client.listReceivedByLabel()
|
||||
|
|
|
@ -15,6 +15,7 @@ import scala.concurrent.Future
|
|||
*/
|
||||
trait MiningRpc { self: Client =>
|
||||
|
||||
@deprecated("use generateToAddress instead", since = "0.18.0")
|
||||
def generate(
|
||||
blocks: Int,
|
||||
maxTries: Int = 1000000): Future[Vector[DoubleSha256DigestBE]] = {
|
||||
|
|
|
@ -12,7 +12,7 @@ class BitcoindChainHandlerViaZmqTest extends ChainUnitTest {
|
|||
|
||||
override type FixtureParam = BitcoindChainHandlerViaZmq
|
||||
|
||||
override implicit val system: ActorSystem = ActorSystem("ChainUnitTest")
|
||||
implicit override val system: ActorSystem = ActorSystem("ChainUnitTest")
|
||||
|
||||
override def withFixture(test: OneArgAsyncTest): FutureOutcome =
|
||||
withBitcoindChainHandlerViaZmq(test)
|
||||
|
@ -25,27 +25,23 @@ class BitcoindChainHandlerViaZmqTest extends ChainUnitTest {
|
|||
|
||||
val chainHandler = bitcoindChainHandler.chainHandler
|
||||
|
||||
val assert1F = chainHandler.getBlockCount
|
||||
for {
|
||||
_ <- chainHandler.getBlockCount
|
||||
.map(count => assert(count == 0))
|
||||
|
||||
//mine a block on bitcoind
|
||||
val generatedF = assert1F.flatMap(_ => bitcoind.generate(1))
|
||||
|
||||
generatedF.flatMap { headers =>
|
||||
val hash = headers.head
|
||||
val foundHeaderF: Future[Unit] = {
|
||||
address <- bitcoind.getNewAddress
|
||||
hash +: _ <- bitcoind.generateToAddress(1, address)
|
||||
_ <- {
|
||||
//test case is totally async since we
|
||||
//can't monitor processing flow for zmq
|
||||
//so we just need to await until we
|
||||
//have fully processed the header
|
||||
RpcUtil.awaitConditionF(() =>
|
||||
chainHandler.getHeader(hash).map(_.isDefined))
|
||||
RpcUtil.awaitConditionF(
|
||||
() => chainHandler.getHeader(hash).map(_.isDefined)
|
||||
)
|
||||
}
|
||||
|
||||
for {
|
||||
_ <- foundHeaderF
|
||||
header <- chainHandler.getHeader(hash)
|
||||
} yield assert(header.get.hashBE == hash)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import scala.concurrent.Future
|
|||
class ChainSyncTest extends ChainUnitTest {
|
||||
override type FixtureParam = BitcoindChainHandlerViaRpc
|
||||
|
||||
override implicit val system = ActorSystem(
|
||||
implicit override val system = ActorSystem(
|
||||
s"chain-sync-test-${System.currentTimeMillis()}")
|
||||
|
||||
override def withFixture(test: OneArgAsyncTest): FutureOutcome = {
|
||||
|
@ -35,7 +35,8 @@ class ChainSyncTest extends ChainUnitTest {
|
|||
}
|
||||
|
||||
//let's generate a block on bitcoind
|
||||
val block1F = bitcoind.generate(1)
|
||||
val block1F =
|
||||
bitcoind.getNewAddress.flatMap(bitcoind.generateToAddress(1, _))
|
||||
val newChainHandlerF: Future[ChainApi] = block1F.flatMap { hashes =>
|
||||
ChainSync.sync(chainHandler = chainHandler,
|
||||
getBlockHeaderFunc = getBlockHeaderFunc,
|
||||
|
|
|
@ -68,12 +68,12 @@ class EclairRpcClientTest extends AsyncFlatSpec with BeforeAndAfterAll {
|
|||
val logger: Logger = BitcoinSLogger.logger
|
||||
|
||||
lazy val bitcoindRpcClientF: Future[BitcoindRpcClient] = {
|
||||
val cliF = EclairRpcTestUtil.startedBitcoindRpcClient()
|
||||
// make sure we have enough money open channels
|
||||
//not async safe
|
||||
val blocksF = cliF.flatMap(_.generate(200))
|
||||
|
||||
blocksF.flatMap(_ => cliF)
|
||||
for {
|
||||
cli <- EclairRpcTestUtil.startedBitcoindRpcClient()
|
||||
// make sure we have enough money to open channels
|
||||
address <- cli.getNewAddress
|
||||
_ <- cli.generateToAddress(200, address)
|
||||
} yield cli
|
||||
}
|
||||
|
||||
lazy val eclairNodesF: Future[EclairNodes4] = {
|
||||
|
@ -383,15 +383,16 @@ class EclairRpcClientTest extends AsyncFlatSpec with BeforeAndAfterAll {
|
|||
val getIsConfirmed = { (client: EclairRpcClient, _: EclairRpcClient) =>
|
||||
isOpenedF.flatMap {
|
||||
case (chanId, assertion) =>
|
||||
val generatedF = bitcoindRpcClientF.flatMap(_.generate(6))
|
||||
val normalF = generatedF.flatMap { _ =>
|
||||
EclairRpcTestUtil.awaitUntilChannelNormal(
|
||||
for {
|
||||
bitcoind <- bitcoindRpcClientF
|
||||
address <- bitcoind.getNewAddress
|
||||
_ <- bitcoind.generateToAddress(6, address)
|
||||
_ <- EclairRpcTestUtil.awaitUntilChannelNormal(
|
||||
client = client,
|
||||
chanId = chanId
|
||||
)
|
||||
}
|
||||
|
||||
normalF.map(_ => (chanId, assertion))
|
||||
} yield (chanId, assertion)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -545,7 +546,9 @@ class EclairRpcClientTest extends AsyncFlatSpec with BeforeAndAfterAll {
|
|||
_ <- EclairRpcTestUtil.awaitUntilPaymentSucceeded(client, paymentId)
|
||||
succeeded <- client.getSentInfo(invoice.lnTags.paymentHash.hash)
|
||||
_ <- client.close(channelId)
|
||||
_ <- bitcoindRpcClientF.flatMap(_.generate(6))
|
||||
bitcoind <- bitcoindRpcClientF
|
||||
address <- bitcoind.getNewAddress
|
||||
_ <- bitcoind.generateToAddress(6, address)
|
||||
} yield {
|
||||
assert(succeeded.nonEmpty)
|
||||
|
||||
|
@ -578,7 +581,9 @@ class EclairRpcClientTest extends AsyncFlatSpec with BeforeAndAfterAll {
|
|||
_ <- EclairRpcTestUtil.awaitUntilChannelClosing(otherClient,
|
||||
channelId)
|
||||
channel <- otherClient.channel(channelId)
|
||||
_ <- bitcoindRpcClientF.flatMap(_.generate(6))
|
||||
bitcoind <- bitcoindRpcClientF
|
||||
address <- bitcoind.getNewAddress
|
||||
_ <- bitcoind.generateToAddress(6, address)
|
||||
} yield {
|
||||
assert(succeeded.nonEmpty)
|
||||
|
||||
|
@ -610,7 +615,9 @@ class EclairRpcClientTest extends AsyncFlatSpec with BeforeAndAfterAll {
|
|||
_ <- EclairRpcTestUtil.awaitUntilPaymentSucceeded(client, paymentId)
|
||||
succeeded <- client.getSentInfo(invoice.lnTags.paymentHash.hash)
|
||||
_ <- client.close(channelId)
|
||||
_ <- bitcoindRpcClientF.flatMap(_.generate(6))
|
||||
bitcoind <- bitcoindRpcClientF
|
||||
address <- bitcoind.getNewAddress
|
||||
_ <- bitcoind.generateToAddress(6, address)
|
||||
} yield {
|
||||
assert(succeeded.nonEmpty)
|
||||
|
||||
|
@ -811,7 +818,12 @@ class EclairRpcClientTest extends AsyncFlatSpec with BeforeAndAfterAll {
|
|||
}
|
||||
|
||||
val gen10F =
|
||||
openedChannelsF.flatMap(_ => bitcoindRpcClientF.flatMap(_.generate(10)))
|
||||
for {
|
||||
_ <- openedChannelsF
|
||||
bitcoind <- bitcoindRpcClientF
|
||||
address <- bitcoind.getNewAddress
|
||||
hashes <- bitcoind.generateToAddress(10, address)
|
||||
} yield hashes
|
||||
|
||||
val nodesReadyForPayments = gen10F.flatMap(_ => connectedClientsF)
|
||||
|
||||
|
@ -1122,9 +1134,12 @@ class EclairRpcClientTest extends AsyncFlatSpec with BeforeAndAfterAll {
|
|||
}
|
||||
|
||||
//confirm the funding tx
|
||||
val genF = channelIdF.flatMap { _ =>
|
||||
bitcoindRpcF.flatMap(_.generate(6))
|
||||
}
|
||||
val genF = for {
|
||||
_ <- channelIdF
|
||||
bitcoind <- bitcoindRpcF
|
||||
address <- bitcoind.getNewAddress
|
||||
headers <- bitcoind.generateToAddress(6, address)
|
||||
} yield headers
|
||||
|
||||
channelIdF.flatMap { cid =>
|
||||
genF.flatMap { _ =>
|
||||
|
|
|
@ -12,11 +12,12 @@ class EclairRpcTestUtilTest extends AsyncFlatSpec with BeforeAndAfterAll {
|
|||
implicit private val actorSystem: ActorSystem =
|
||||
ActorSystem("EclairRpcTestUtilTest", BitcoindRpcTestUtil.AKKA_CONFIG)
|
||||
|
||||
private lazy val bitcoindRpcF = {
|
||||
val cliF = EclairRpcTestUtil.startedBitcoindRpcClient()
|
||||
val blocksF = cliF.flatMap(_.generate(200))
|
||||
blocksF.flatMap(_ => cliF)
|
||||
}
|
||||
private lazy val bitcoindRpcF =
|
||||
for {
|
||||
cli <- EclairRpcTestUtil.startedBitcoindRpcClient()
|
||||
address <- cli.getNewAddress
|
||||
blocks <- cli.generateToAddress(200, address)
|
||||
} yield cli
|
||||
|
||||
private val clients =
|
||||
Vector.newBuilder[EclairRpcClient]
|
||||
|
|
|
@ -32,9 +32,9 @@ class SpvNodeTest extends NodeUnitTest {
|
|||
a2 <- spvNode.isInitialized.map(assert(_))
|
||||
} yield a2
|
||||
|
||||
val hashF: Future[DoubleSha256DigestBE] = {
|
||||
bitcoind.generate(1).map(_.head)
|
||||
}
|
||||
val hashF: Future[DoubleSha256DigestBE] = bitcoind.getNewAddress
|
||||
.flatMap(bitcoind.generateToAddress(1, _))
|
||||
.map(_.head)
|
||||
|
||||
//sync our spv node expecting to get that generated hash
|
||||
val spvSyncF = for {
|
||||
|
@ -58,7 +58,8 @@ class SpvNodeTest extends NodeUnitTest {
|
|||
//we need to generate 1 block for bitcoind to consider
|
||||
//itself out of IBD. bitcoind will not sendheaders
|
||||
//when it believes itself, or it's peer is in IBD
|
||||
val gen1F = bitcoind.generate(1)
|
||||
val gen1F =
|
||||
bitcoind.getNewAddress.flatMap(bitcoind.generateToAddress(1, _))
|
||||
|
||||
//this needs to be called to get our peer to send us headers
|
||||
//as they happen with the 'sendheaders' message
|
||||
|
@ -103,7 +104,7 @@ class SpvNodeTest extends NodeUnitTest {
|
|||
val genBlock = new Runnable {
|
||||
override def run(): Unit = {
|
||||
if (counter < desiredBlocks) {
|
||||
bitcoind.generate(1)
|
||||
bitcoind.getNewAddress.flatMap(bitcoind.generateToAddress(1, _))
|
||||
counter = counter + 1
|
||||
} else {
|
||||
//do nothing
|
||||
|
|
|
@ -29,8 +29,6 @@ import scala.concurrent.duration.{DurationInt, FiniteDuration}
|
|||
import scala.concurrent.{ExecutionContext, Future}
|
||||
import scala.util.{Failure, Success}
|
||||
import org.bitcoins.rpc.config.BitcoindAuthCredentials
|
||||
import java.nio.file.Paths
|
||||
import scala.util.Properties
|
||||
import java.nio.file.Files
|
||||
|
||||
/**
|
||||
|
@ -48,16 +46,8 @@ trait EclairRpcTestUtil extends BitcoinSLogger {
|
|||
import org.bitcoins.core.compat.JavaConverters._
|
||||
|
||||
/** Directory where sbt downloads Eclair binaries */
|
||||
private[bitcoins] lazy val binaryDirectory = {
|
||||
val baseDirectory = {
|
||||
val cwd = Paths.get(Properties.userDir)
|
||||
if (cwd.endsWith("eclair-rpc-test") || cwd.endsWith("bitcoind-rpc-test")) {
|
||||
cwd.getParent()
|
||||
} else cwd
|
||||
}
|
||||
|
||||
baseDirectory.resolve("binaries").resolve("eclair")
|
||||
}
|
||||
private[bitcoins] val binaryDirectory =
|
||||
BitcoindRpcTestUtil.baseBinaryDirectory.resolve("eclair")
|
||||
|
||||
/** Path to Jar downloaded by Eclair, if it exists */
|
||||
private[bitcoins] lazy val binary: Option[File] = {
|
||||
|
@ -389,7 +379,8 @@ trait EclairRpcTestUtil extends BitcoinSLogger {
|
|||
}
|
||||
|
||||
val genBlocksF = openChannelsF.flatMap { _ =>
|
||||
internalBitcoindF.flatMap(_.generate(3))
|
||||
internalBitcoindF.flatMap(client =>
|
||||
client.getNewAddress.flatMap(client.generateToAddress(3, _)))
|
||||
}
|
||||
|
||||
genBlocksF.flatMap { _ =>
|
||||
|
@ -595,7 +586,11 @@ trait EclairRpcTestUtil extends BitcoinSLogger {
|
|||
}
|
||||
}
|
||||
|
||||
val gen = fundedChannelIdF.flatMap(_ => bitcoindRpcClient.generate(6))
|
||||
val gen = for {
|
||||
_ <- fundedChannelIdF
|
||||
address <- bitcoindRpcClient.getNewAddress
|
||||
blocks <- bitcoindRpcClient.generateToAddress(6, address)
|
||||
} yield blocks
|
||||
|
||||
val openedF = {
|
||||
gen.flatMap { _ =>
|
||||
|
|
|
@ -147,16 +147,25 @@ trait BitcoindRpcTestUtil extends BitcoinSLogger {
|
|||
|
||||
lazy val network: RegTest.type = RegTest
|
||||
|
||||
/** The directory that sbt downloads bitcoind binaries into */
|
||||
private[bitcoins] val binaryDirectory = {
|
||||
val baseDirectory = {
|
||||
/** The base directory where binaries needed in tests
|
||||
* are located. */
|
||||
private[bitcoins] val baseBinaryDirectory = {
|
||||
val cwd = Paths.get(Properties.userDir)
|
||||
if (cwd.endsWith("bitcoind-rpc-test") || cwd.endsWith("eclair-rpc-test")) {
|
||||
val pathsToGoBackFrom = List("eclair-rpc-test",
|
||||
"bitcoind-rpc-test",
|
||||
"node-test",
|
||||
"wallet-test",
|
||||
"chain-test")
|
||||
|
||||
val rootDir = if (pathsToGoBackFrom.exists(cwd.endsWith)) {
|
||||
cwd.getParent()
|
||||
} else cwd
|
||||
rootDir.resolve("binaries")
|
||||
}
|
||||
|
||||
baseDirectory.resolve("binaries").resolve("bitcoind")
|
||||
/** The directory that sbt downloads bitcoind binaries into */
|
||||
private[bitcoins] val binaryDirectory = {
|
||||
baseBinaryDirectory.resolve("bitcoind")
|
||||
}
|
||||
|
||||
private def getBinary(version: BitcoindVersion): File = version match {
|
||||
|
|
|
@ -101,7 +101,7 @@ class WalletIntegrationTest extends BitcoinSWalletTest {
|
|||
}
|
||||
|
||||
txid <- bitcoind.sendRawTransaction(signedTx)
|
||||
_ <- bitcoind.generate(1)
|
||||
_ <- bitcoind.getNewAddress.flatMap(bitcoind.generateToAddress(1, _))
|
||||
tx <- bitcoind.getRawTransaction(txid)
|
||||
|
||||
_ <- wallet.listUtxos().map {
|
||||
|
|
Loading…
Add table
Reference in a new issue