mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-26 01:29:20 +01:00
tests: Make NeutrinoNodeWalletTest
more robust against spurious failures (#5784)
* tests: Make NeutrinoNodeWalletTest more robust against spurious failures * Revert things
This commit is contained in:
parent
f6f01f333a
commit
dbe1e7b686
1 changed files with 12 additions and 9 deletions
|
@ -74,9 +74,9 @@ class NeutrinoNodeWithWalletTest extends NodeTestWithCachedBitcoindNewest {
|
|||
// the 3BTC utxo to spend, so we should have
|
||||
// confirmed = 2BTC + 1BTC
|
||||
// unconfirmed = 3 BTC - TestAmount - TestFees
|
||||
val condition1 = () => {
|
||||
def condition1(fee: CurrencyUnit): () => Future[Boolean] = () => {
|
||||
condition(
|
||||
expectedBalance = 6.bitcoin - TestAmount - TestFees,
|
||||
expectedBalance = 6.bitcoin - TestAmount - fee,
|
||||
expectedUtxos = 3,
|
||||
expectedAddresses = 7
|
||||
)
|
||||
|
@ -86,9 +86,9 @@ class NeutrinoNodeWithWalletTest extends NodeTestWithCachedBitcoindNewest {
|
|||
// so everything should stay the same as above
|
||||
// expected we should have received TestAmount back
|
||||
// and have 1 more address/utxo
|
||||
val condition2 = { () =>
|
||||
def condition2(firstTxFee: CurrencyUnit): () => Future[Boolean] = { () =>
|
||||
condition(
|
||||
expectedBalance = (6.bitcoin - TestAmount - TestFees) + TestAmount,
|
||||
expectedBalance = (6.bitcoin - TestAmount - firstTxFee) + TestAmount,
|
||||
expectedUtxos = 4,
|
||||
expectedAddresses = 8
|
||||
)
|
||||
|
@ -97,9 +97,10 @@ class NeutrinoNodeWithWalletTest extends NodeTestWithCachedBitcoindNewest {
|
|||
for {
|
||||
// send
|
||||
addr <- bitcoind.getNewAddress
|
||||
_ <- wallet.sendFundsHandling.sendToAddress(addr,
|
||||
TestAmount,
|
||||
Some(FeeRate))
|
||||
tx <- wallet.sendFundsHandling.sendToAddress(addr,
|
||||
TestAmount,
|
||||
Some(FeeRate))
|
||||
fee = FeeRate.calc(tx)
|
||||
|
||||
_ <- wallet.getConfirmedBalance()
|
||||
_ <- wallet.getUnconfirmedBalance()
|
||||
|
@ -108,7 +109,9 @@ class NeutrinoNodeWithWalletTest extends NodeTestWithCachedBitcoindNewest {
|
|||
bitcoind.getNewAddress
|
||||
.flatMap(bitcoind.generateToAddress(1, _))
|
||||
_ <- NodeTestUtil.awaitSync(node, bitcoind)
|
||||
_ <- AsyncUtil.awaitConditionF(condition1, maxTries = 100) // 10 seconds
|
||||
_ <- AsyncUtil.awaitConditionF(condition1(fee),
|
||||
maxTries = 100
|
||||
) // 10 seconds
|
||||
// receive
|
||||
address <- wallet.addressHandling.getNewAddress()
|
||||
txId <- bitcoind.sendToAddress(address, TestAmount)
|
||||
|
@ -119,7 +122,7 @@ class NeutrinoNodeWithWalletTest extends NodeTestWithCachedBitcoindNewest {
|
|||
.flatMap(bitcoind.generateToAddress(1, _))
|
||||
_ <- NodeTestUtil.awaitSync(node, bitcoind)
|
||||
_ <- TestAsyncUtil.awaitConditionF(
|
||||
condition2,
|
||||
condition2(fee),
|
||||
interval = 1.second,
|
||||
maxTries = 30
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue