<commit_before>package com.wavesplatform.it

import com.wavesplatform.it.TransferSending.Req
import com.wavesplatform.it.api.NodeApi.Transaction
import scorex.account.{Address, AddressScheme}
import scorex.utils.ScorexLogging

import scala.concurrent.Future
import scala.util.Random

object TransferSending {
  case class Req(source: String, targetAddress: String, amount: Long, fee: Long)
}

trait TransferSending extends ScorexLogging {

  import scala.concurrent.ExecutionContext.Implicits.global

  AddressScheme.current = new AddressScheme {
    override val chainId: Byte = 'I'.toByte
  }

  def nodes: Seq[Node]
  private lazy val addressToNode = nodes.map(n => n.address -> n).toMap

  def generateTransfersBetweenAccounts(n: Int, balances: Map[String, Long]): Seq[Req] = {
    val fee = 100000
    val addresses = nodes.map(_.address)
    val sourceAndDest = (1 to n).map { _ =>
      val Seq(src, dest) = Random.shuffle(addresses).take(2)
      (src, dest)
    }
    val requests = sourceAndDest.foldLeft(List.empty[Req]) {
      case (rs, (src, dest)) =>
        val transferAmount = (1e-8 + Random.nextDouble() * 1e-8 * balances(src)).toLong
        rs :+ Req(src, dest, Math.max(transferAmount, 1L), fee)
    }

    requests
  }<commit_msg>NODE-314 Fix for 'negative amount' error in WideStateGenerationSpec<commit_after>package com.wavesplatform.it

import com.wavesplatform.it.TransferSending.Req
import com.wavesplatform.it.api.NodeApi.Transaction
import scorex.account.{Address, AddressScheme}
import scorex.utils.ScorexLogging

import scala.concurrent.Future
import scala.util.Random

object TransferSending {
  case class Req(source: String, targetAddress: String, amount: Long, fee: Long)
}

trait TransferSending extends ScorexLogging {

  import scala.concurrent.ExecutionContext.Implicits.global

  AddressScheme.current = new AddressScheme {
    override val chainId: Byte = 'I'.toByte
  }

  def nodes: Seq[Node]
  private lazy val addressToNode = nodes.map(n => n.address -> n).toMap

  def generateTransfersBetweenAccounts(n: Int, balances: Map[String, Long]): Seq[Req] = {
    val fee = 100000
    val addresses = nodes.map(_.address)
    val sourceAndDest = (1 to n).map { _ =>
      val Seq(src, dest) = Random.shuffle(addresses).take(2)
      (src, dest)
    }
    val requests = sourceAndDest.foldLeft(List.empty[Req]) {
      case (rs, (src, dest)) =>
        val transferAmount = (1e-8 + Random.nextDouble() * 1e-8 * balances(src)).toLong
        rs :+ Req(src, dest, Math.max(transferAmount, 1L), fee), fee)
    }

    requests
  }
{'fraction_non_alphanumeric': 0.11574434918160562, 'fraction_numerical': 0.011301636788776305, 'mean_word_length': 3.917624521072797, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3431737', 'n_tokens_mistral': 852, 'n_tokens_neox': 811, 'n_words': 198}