@@ -4,7 +4,13 @@ import { allPass, is, isNil, lensPath, not, path, pipe, pipeP, view } from 'ramd
44import { describe } from 'riteway'
55
66import { issuer , privateKey } from '../helpers/Keys'
7- import { ensureBitcoinBalance , bitcoindClients , resetBitcoinServers } from '../helpers/bitcoin'
7+ import {
8+ ensureBitcoinBalance ,
9+ bitcoindClients ,
10+ resetBitcoinServers ,
11+ waitForBlockchainSync ,
12+ waitForBlockchainsToSync ,
13+ } from '../helpers/bitcoin'
814import { delayInSeconds , runtimeId , setUpServerAndDb } from '../helpers/utils'
915import { getWork , postWork } from '../helpers/works'
1016
@@ -32,7 +38,7 @@ const createClaim = pipeP(
3238 signVerifiableClaim ,
3339)
3440
35- const { btcdClientA , btcdClientB } : any = bitcoindClients ( )
41+ const { bitcoinCoreClientA , bitcoinCoreClientB } : any = bitcoindClients ( )
3642
3743const blockHash = lensPath ( [ 'anchor' , 'blockHash' ] )
3844const blockHeight = lensPath ( [ 'anchor' , 'blockHeight' ] )
@@ -48,15 +54,17 @@ const hasValidTxId = allPass([is(String), lengthIsGreaterThan0])
4854
4955describe ( 'Transaction timout will reset the transaction id for the claim' , async assert => {
5056 await resetBitcoinServers ( )
51- await btcdClientB . addNode ( btcdClientA . host , 'add' )
57+ await bitcoinCoreClientB . addNode ( bitcoinCoreClientA . host , 'add' )
5258
5359 await delayInSeconds ( 5 )
5460
5561 const { db, server } = await setUpServerAndDb ( { PREFIX , NODE_PORT , blockchainSettings } )
5662
5763 // Make sure node A has regtest coins to pay for transactions.
58- await ensureBitcoinBalance ( btcdClientA )
59- await btcdClientA . setNetworkActive ( false )
64+ const generatedBlockHeight = 101
65+ await ensureBitcoinBalance ( bitcoinCoreClientA , generatedBlockHeight )
66+ await waitForBlockchainsToSync ( generatedBlockHeight , [ bitcoinCoreClientA , bitcoinCoreClientB ] )
67+ await bitcoinCoreClientA . setNetworkActive ( false )
6068
6169 // Allow everything to finish starting.
6270 await delayInSeconds ( 5 )
@@ -99,10 +107,14 @@ describe('Transaction timout will reset the transaction id for the claim', async
99107 expected : true ,
100108 } )
101109
102- await btcdClientB . generate ( blockchainSettings . MAXIMUM_TRANSACTION_AGE_IN_BLOCKS + 1 )
103- await btcdClientA . setNetworkActive ( true )
110+ await bitcoinCoreClientB . generate ( blockchainSettings . MAXIMUM_TRANSACTION_AGE_IN_BLOCKS + 1 )
111+ const targetHeight = 102 + blockchainSettings . MAXIMUM_TRANSACTION_AGE_IN_BLOCKS
112+ const waitForTargetHeight = waitForBlockchainSync ( targetHeight )
113+ await waitForTargetHeight ( bitcoinCoreClientB )
114+ await bitcoinCoreClientA . setNetworkActive ( true )
115+ await waitForTargetHeight ( bitcoinCoreClientA )
104116
105- await delayInSeconds ( ( blockchainSettings . PURGE_STALE_TRANSACTIONS_INTERVAL_IN_SECONDS + 5 ) * 2 )
117+ await delayInSeconds ( blockchainSettings . PURGE_STALE_TRANSACTIONS_INTERVAL_IN_SECONDS + 5 )
106118
107119 const secondResponse = await getWorkFromNode ( claim . id )
108120 const secondGet = await secondResponse . json ( )
@@ -122,7 +134,7 @@ describe('Transaction timout will reset the transaction id for the claim', async
122134 expected : true ,
123135 } )
124136
125- await btcdClientA . generate ( 1 )
137+ await bitcoinCoreClientA . generate ( 1 )
126138 await delayInSeconds (
127139 blockchainSettings . BATCH_CREATION_INTERVAL_IN_SECONDS +
128140 blockchainSettings . READ_DIRECTORY_INTERVAL_IN_SECONDS ,
0 commit comments