mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-03 10:46:42 +01:00
Generalize DAO fixture for wallet
This commit is contained in:
parent
ff5b1c25f1
commit
b630cfbf5c
3 changed files with 12 additions and 9 deletions
|
@ -1,12 +1,13 @@
|
||||||
package org.bitcoins.wallet.models
|
package org.bitcoins.wallet.models
|
||||||
|
|
||||||
import org.bitcoins.testkit.core.gen.CryptoGenerators
|
import org.bitcoins.testkit.core.gen.CryptoGenerators
|
||||||
import org.bitcoins.wallet.fixtures.AccountDAOFixture
|
import org.bitcoins.wallet.fixtures.WalletDAOFixture
|
||||||
import org.bitcoins.testkit.wallet.{BitcoinSWalletTest, WalletTestUtil}
|
import org.bitcoins.testkit.wallet.{BitcoinSWalletTest, WalletTestUtil}
|
||||||
|
|
||||||
class AccountDAOTest extends BitcoinSWalletTest with AccountDAOFixture {
|
class AccountDAOTest extends BitcoinSWalletTest with WalletDAOFixture {
|
||||||
|
|
||||||
it should "insert and read an account into the database" in { accountDAO =>
|
it should "insert and read an account into the database" in { daos =>
|
||||||
|
val accountDAO = daos.accountDAO
|
||||||
for {
|
for {
|
||||||
created <- {
|
created <- {
|
||||||
val account = WalletTestUtil.firstAccount
|
val account = WalletTestUtil.firstAccount
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.bitcoins.core.crypto.ECPublicKey
|
||||||
import org.bitcoins.core.protocol.P2SHAddress
|
import org.bitcoins.core.protocol.P2SHAddress
|
||||||
import org.bitcoins.core.script.ScriptType
|
import org.bitcoins.core.script.ScriptType
|
||||||
import org.bitcoins.core.util.CryptoUtil
|
import org.bitcoins.core.util.CryptoUtil
|
||||||
import org.bitcoins.wallet.fixtures.AddressDAOFixture
|
import org.bitcoins.wallet.fixtures.WalletDAOFixture
|
||||||
import org.bitcoins.testkit.wallet.{BitcoinSWalletTest, WalletTestUtil}
|
import org.bitcoins.testkit.wallet.{BitcoinSWalletTest, WalletTestUtil}
|
||||||
import org.bitcoins.core.hd.HDChainType
|
import org.bitcoins.core.hd.HDChainType
|
||||||
import org.bitcoins.core.hd.SegWitHDPath
|
import org.bitcoins.core.hd.SegWitHDPath
|
||||||
|
@ -18,7 +18,7 @@ import org.bitcoins.core.protocol.script.ScriptPubKey
|
||||||
import org.bitcoins.core.protocol.Bech32Address
|
import org.bitcoins.core.protocol.Bech32Address
|
||||||
import org.bitcoins.core.protocol.script.P2WPKHWitnessV0
|
import org.bitcoins.core.protocol.script.P2WPKHWitnessV0
|
||||||
|
|
||||||
class AddressDAOTest extends BitcoinSWalletTest with AddressDAOFixture {
|
class AddressDAOTest extends BitcoinSWalletTest with WalletDAOFixture {
|
||||||
|
|
||||||
// todo: do this with an actual working address
|
// todo: do this with an actual working address
|
||||||
// todo: with script witness + redeem script
|
// todo: with script witness + redeem script
|
||||||
|
@ -45,7 +45,7 @@ class AddressDAOTest extends BitcoinSWalletTest with AddressDAOFixture {
|
||||||
|
|
||||||
it should "fail to insert and read an address into the database without a corresponding account" in {
|
it should "fail to insert and read an address into the database without a corresponding account" in {
|
||||||
daos =>
|
daos =>
|
||||||
val (_, addressDAO) = daos
|
val addressDAO = daos.addressDAO
|
||||||
val readF = {
|
val readF = {
|
||||||
val addressDb = getAddressDb(WalletTestUtil.firstAccountDb)
|
val addressDb = getAddressDb(WalletTestUtil.firstAccountDb)
|
||||||
addressDAO.create(addressDb)
|
addressDAO.create(addressDb)
|
||||||
|
@ -56,7 +56,8 @@ class AddressDAOTest extends BitcoinSWalletTest with AddressDAOFixture {
|
||||||
|
|
||||||
it should "insert and read an address into the database with a corresponding account" in {
|
it should "insert and read an address into the database with a corresponding account" in {
|
||||||
daos =>
|
daos =>
|
||||||
val (accountDAO, addressDAO) = daos
|
val accountDAO = daos.accountDAO
|
||||||
|
val addressDAO = daos.addressDAO
|
||||||
for {
|
for {
|
||||||
createdAccount <- {
|
createdAccount <- {
|
||||||
val account = WalletTestUtil.firstAccountDb
|
val account = WalletTestUtil.firstAccountDb
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.bitcoins.core.hd.LegacyHDPath
|
||||||
|
|
||||||
class IncomingTransactionDAOTest
|
class IncomingTransactionDAOTest
|
||||||
extends BitcoinSWalletTest
|
extends BitcoinSWalletTest
|
||||||
with IncomingTransactionDAOFixture {
|
with WalletDAOFixture {
|
||||||
private def getTx: Transaction =
|
private def getTx: Transaction =
|
||||||
TransactionGenerators.transaction
|
TransactionGenerators.transaction
|
||||||
.suchThat(_.outputs.nonEmpty)
|
.suchThat(_.outputs.nonEmpty)
|
||||||
|
@ -23,7 +23,8 @@ class IncomingTransactionDAOTest
|
||||||
|
|
||||||
it must "insert a incoming transaction and read it back with its address" in {
|
it must "insert a incoming transaction and read it back with its address" in {
|
||||||
daos =>
|
daos =>
|
||||||
val (txDao, addrDao) = daos
|
val txDao = daos.incomingTxDAO
|
||||||
|
val addrDao = daos.addressDAO
|
||||||
implicit val walletconf: WalletAppConfig = config
|
implicit val walletconf: WalletAppConfig = config
|
||||||
val accountDAO = AccountDAO()
|
val accountDAO = AccountDAO()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue