mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-19 18:02:54 +01:00
Add TX generator for non-empty output TXs
This commit is contained in:
parent
6ffd505946
commit
f8e5ac19ba
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user