<commit_before>package org.bitcoins.rpc.v21

import org.bitcoins.asyncutil.AsyncUtil
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.WalletFlag
import org.bitcoins.commons.jsonmodels.bitcoind._
import org.bitcoins.core.config.RegTest
import org.bitcoins.core.gcs.{BlockFilter, FilterType}
import org.bitcoins.core.psbt.PSBT
import org.bitcoins.crypto.ECPublicKey
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
import org.bitcoins.rpc.client.v21.BitcoindV21RpcClient
import org.bitcoins.testkit.rpc.BitcoindFixturesFundedCachedV21

import java.io.File
import java.nio.file.Files
import scala.concurrent.Future

class BitcoindV21RpcClientTest extends BitcoindFixturesFundedCachedV21 {

  behavior of "BitcoindV21RpcClient"

  it should "be able to start a V21 bitcoind instance" in {
    client: BitcoindV21RpcClient =>
      assert(client.version == BitcoindVersion.V21)
  }

  it should "be able to get network info" in {
    freshClient: BitcoindV21RpcClient =>
      for {
        info <- freshClient.getNetworkInfo
      } yield {
        assert(info.networkactive)
        assert(info.localrelay)
      }
  }

  it should "get index info" in { client: BitcoindV21RpcClient =>
    def isHeight101(client: BitcoindRpcClient): Future[Boolean] = {
      client.getBlockCount.map(_ == 101)
    }
    for {
      _ <- AsyncUtil.retryUntilSatisfiedF(() => isHeight101(client))
      indexes <- client.getIndexInfo
    } yield {
      val txIndexInfo = indexes("txindex")
      assert(txIndexInfo.synced)<commit_msg>Have BitcoindV21RpcClientTest wait for indexes to sync (#2855)<commit_after>package org.bitcoins.rpc.v21

import org.bitcoins.asyncutil.AsyncUtil
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.WalletFlag
import org.bitcoins.commons.jsonmodels.bitcoind._
import org.bitcoins.core.config.RegTest
import org.bitcoins.core.gcs.{BlockFilter, FilterType}
import org.bitcoins.core.psbt.PSBT
import org.bitcoins.crypto.ECPublicKey
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
import org.bitcoins.rpc.client.v21.BitcoindV21RpcClient
import org.bitcoins.testkit.rpc.BitcoindFixturesFundedCachedV21

import java.io.File
import java.nio.file.Files
import scala.concurrent.Future

class BitcoindV21RpcClientTest extends BitcoindFixturesFundedCachedV21 {

  behavior of "BitcoindV21RpcClient"

  it should "be able to start a V21 bitcoind instance" in {
    client: BitcoindV21RpcClient =>
      assert(client.version == BitcoindVersion.V21)
  }

  it should "be able to get network info" in {
    freshClient: BitcoindV21RpcClient =>
      for {
        info <- freshClient.getNetworkInfo
      } yield {
        assert(info.networkactive)
        assert(info.localrelay)
      }
  }

  it should "get index info" in { client: BitcoindV21RpcClient =>
    def indexSynced(client: BitcoindRpcClient): Future[Boolean] = {
      client.getIndexInfo.map { indexes =>
        indexes("txindex").best_block_height == 101 && indexes(
          "basic block filter index").best_block_height == 101
      }
    }
    for {
      _ <- AsyncUtil.retryUntilSatisfiedF(() => indexSynced(client))
      indexes <- client.getIndexInfo
    } yield {
      val txIndexInfo = indexes("txindex")
      assert(txIndexInfo.synced)
{'fraction_non_alphanumeric': 0.09354052407068861, 'fraction_numerical': 0.02102376599634369, 'mean_word_length': 3.9817905918057663, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6038384', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1071, 'n_words': 200}