Add TX generator for non-empty output TXs

This commit is contained in:
Torkel Rogstad 2019-06-27 11:57:09 +02:00
parent 6ffd505946
commit f8e5ac19ba
2 changed files with 5 additions and 9 deletions

View File

@ -135,6 +135,10 @@ object TransactionGenerators extends BitcoinSLogger {
def transactionTo(spk: ScriptPubKey) =
Gen.oneOf(baseTransactionTo(spk), witnessTransactionTo(spk))
/** Generates a transaction with at least one output */
def nonEmptyOutputTransaction: Gen[Transaction] =
TransactionGenerators.transaction.suchThat(_.outputs.nonEmpty)
def baseTransaction: Gen[BaseTransaction] =
for {
version <- NumberGenerator.int32s

View File

@ -16,7 +16,6 @@ import scodec.bits.HexStringSyntax
import org.bitcoins.core.hd._
import org.bitcoins.core.protocol.script.ScriptWitness
import org.bitcoins.core.protocol.script.P2WPKHWitnessV0
import org.bitcoins.core.protocol.transaction.Transaction
import org.bitcoins.testkit.core.gen.TransactionGenerators
import scala.concurrent.Future
import org.bitcoins.wallet.models.AddressDb
@ -117,13 +116,6 @@ object WalletTestUtil {
val WalletDAOs(accountDAO, addressDAO, txoDAO, _, utxoDAO) = daos
/** Get a TX with outputs */
def getTx: Transaction =
TransactionGenerators.transaction
.suchThat(_.outputs.nonEmpty)
.sample
.getOrElse(getTx)
val account = WalletTestUtil.firstAccountDb
val address = {
@ -137,7 +129,7 @@ object WalletTestUtil {
AddressDbHelper.getAddress(pub, path, RegTest)
}
val tx = getTx
val tx = TransactionGenerators.nonEmptyOutputTransaction.sampleSome
val txoDb = IncomingWalletTXO(confirmations = 3,
txid = tx.txIdBE,
spent = false,