Upgrade RescanHandlingTest to use the newest release of bitcoind (#4151)

This commit is contained in:
Chris Stewart 2022-03-02 09:59:25 -06:00 committed by GitHub
parent d1fc32758b
commit 374c1d7b9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 13 deletions

View file

@ -137,6 +137,18 @@ trait BitcoinSWalletTestCachedBitcoindNewest
extends BitcoinSWalletTestCachedBitcoind extends BitcoinSWalletTestCachedBitcoind
with CachedBitcoindNewest { with CachedBitcoindNewest {
override def withFixture(test: OneArgAsyncTest): FutureOutcome = {
val f: Future[Outcome] = for {
bitcoind <- cachedBitcoindWithFundsF
futOutcome = withFundedWalletAndBitcoindCached(
test,
getBIP39PasswordOpt(),
bitcoind)(getFreshWalletAppConfig)
fut <- futOutcome.toFuture
} yield fut
new FutureOutcome(f)
}
override def afterAll(): Unit = { override def afterAll(): Unit = {
super[CachedBitcoindNewest].afterAll() super[CachedBitcoindNewest].afterAll()
super[BitcoinSWalletTestCachedBitcoind].afterAll() super[BitcoinSWalletTestCachedBitcoind].afterAll()

View file

@ -11,15 +11,15 @@ import org.bitcoins.core.wallet.utxo.TxoState
import org.bitcoins.server.BitcoinSAppConfig import org.bitcoins.server.BitcoinSAppConfig
import org.bitcoins.testkit.BitcoinSTestAppConfig import org.bitcoins.testkit.BitcoinSTestAppConfig
import org.bitcoins.testkit.wallet.{ import org.bitcoins.testkit.wallet.{
BitcoinSWalletTestCachedBitcoinV19, BitcoinSWalletTestCachedBitcoindNewest,
WalletWithBitcoind, WalletWithBitcoind,
WalletWithBitcoindV19 WalletWithBitcoindRpc
} }
import scala.concurrent.Future import scala.concurrent.Future
import scala.concurrent.duration.DurationInt import scala.concurrent.duration.DurationInt
class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoinV19 { class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
/** Wallet config with data directory set to user temp directory */ /** Wallet config with data directory set to user temp directory */
override protected def getFreshConfig: BitcoinSAppConfig = override protected def getFreshConfig: BitcoinSAppConfig =
@ -78,7 +78,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoinV19 {
val DEFAULT_ADDR_BATCH_SIZE = 10 val DEFAULT_ADDR_BATCH_SIZE = 10
it must "be able to discover funds that belong to the wallet using WalletApi.rescanNeutrinoWallet" in { it must "be able to discover funds that belong to the wallet using WalletApi.rescanNeutrinoWallet" in {
fixture: WalletWithBitcoind => fixture: WalletWithBitcoind =>
val WalletWithBitcoindV19(wallet, _) = fixture val WalletWithBitcoindRpc(wallet, _) = fixture
val initBalanceF = wallet.getBalance() val initBalanceF = wallet.getBalance()
@ -98,7 +98,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoinV19 {
it must "be able to discover funds that occurred within a certain range" in { it must "be able to discover funds that occurred within a certain range" in {
fixture: WalletWithBitcoind => fixture: WalletWithBitcoind =>
val WalletWithBitcoindV19(wallet, bitcoind) = fixture val WalletWithBitcoindRpc(wallet, bitcoind) = fixture
val amt = Bitcoins.one val amt = Bitcoins.one
val numBlocks = 1 val numBlocks = 1
@ -152,7 +152,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoinV19 {
it must "be able to discover funds using multiple batches" in { it must "be able to discover funds using multiple batches" in {
fixture: WalletWithBitcoind => fixture: WalletWithBitcoind =>
val WalletWithBitcoindV19(wallet, bitcoind) = fixture val WalletWithBitcoindRpc(wallet, bitcoind) = fixture
val amt = Bitcoins.one val amt = Bitcoins.one
val numBlocks = 1 val numBlocks = 1
@ -215,7 +215,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoinV19 {
it must "be able to discover funds that occurred from the wallet creation time" in { it must "be able to discover funds that occurred from the wallet creation time" in {
fixture: WalletWithBitcoind => fixture: WalletWithBitcoind =>
val WalletWithBitcoindV19(wallet, bitcoind) = fixture val WalletWithBitcoindRpc(wallet, bitcoind) = fixture
val amt = Bitcoins.one val amt = Bitcoins.one
val numBlocks = 1 val numBlocks = 1
@ -260,7 +260,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoinV19 {
it must "NOT discover funds that happened OUTSIDE of a certain range of block hashes" in { it must "NOT discover funds that happened OUTSIDE of a certain range of block hashes" in {
fixture: WalletWithBitcoind => fixture: WalletWithBitcoind =>
val WalletWithBitcoindV19(wallet, _) = fixture val WalletWithBitcoindRpc(wallet, _) = fixture
val initBalanceF = wallet.getBalance() val initBalanceF = wallet.getBalance()
@ -299,13 +299,13 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoinV19 {
it must "acknowledge that a rescan is already in progress" in { it must "acknowledge that a rescan is already in progress" in {
fixture: WalletWithBitcoind => fixture: WalletWithBitcoind =>
val WalletWithBitcoindV19(wallet, _) = fixture val WalletWithBitcoindRpc(wallet, _) = fixture
//do these in parallel on purpose to simulate multiple threads calling rescan //do these in parallel on purpose to simulate multiple threads calling rescan
val startF = wallet.rescanNeutrinoWallet(startOpt = None, val startF = wallet.rescanNeutrinoWallet(startOpt = None,
endOpt = None, endOpt = None,
addressBatchSize = addressBatchSize =
DEFAULT_ADDR_BATCH_SIZE, DEFAULT_ADDR_BATCH_SIZE,
useCreationTime = false) useCreationTime = true)
//slight delay to make sure other rescan is started //slight delay to make sure other rescan is started
val alreadyStartedF = val alreadyStartedF =
@ -314,7 +314,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoinV19 {
endOpt = None, endOpt = None,
addressBatchSize = addressBatchSize =
DEFAULT_ADDR_BATCH_SIZE, DEFAULT_ADDR_BATCH_SIZE,
useCreationTime = false) useCreationTime = true)
} }
for { for {
start <- startF start <- startF
@ -328,7 +328,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoinV19 {
it must "still receive payments to addresses generated pre-rescan" in { it must "still receive payments to addresses generated pre-rescan" in {
fixture: WalletWithBitcoind => fixture: WalletWithBitcoind =>
val WalletWithBitcoindV19(wallet, bitcoind) = fixture val WalletWithBitcoindRpc(wallet, bitcoind) = fixture
val addressNoFundsF = wallet.getNewAddress() val addressNoFundsF = wallet.getNewAddress()
//start a rescan without sending payment to that address //start a rescan without sending payment to that address
@ -337,7 +337,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoinV19 {
_ <- wallet.rescanNeutrinoWallet(startOpt = None, _ <- wallet.rescanNeutrinoWallet(startOpt = None,
endOpt = None, endOpt = None,
addressBatchSize = 10, addressBatchSize = 10,
useCreationTime = false) useCreationTime = true)
usedAddresses <- wallet.listFundedAddresses() usedAddresses <- wallet.listFundedAddresses()