@@ -19,6 +19,7 @@ public class PolarIntegrationTest: XCTestCase {
19
19
// print(help)
20
20
21
21
try await self . ascertainSpareMoney ( rpcInterface: rpcInterface)
22
+ try await rpcInterface. preloadMonitor ( anchorHeight: . chaintip)
22
23
23
24
// let seed: [UInt8] = [UInt8](Data(base64Encoded: "//////////////////////////////////////////8=")!)
24
25
var seed = [ UInt8] ( repeating: 0 , count: 32 )
@@ -34,16 +35,26 @@ public class PolarIntegrationTest: XCTestCase {
34
35
let lightningNetwork = LDKNetwork_Regtest
35
36
let genesisHash = try await rpcInterface. getBlockHash ( height: 0 )
36
37
let reversedGenesisHash = [ UInt8] ( genesisHash. reversed ( ) )
38
+ let chaintipHash = try await rpcInterface. getChaintipHash ( )
39
+ let reversedChaintipHash = [ UInt8] ( chaintipHash. reversed ( ) )
40
+ let chaintipHeight = try await rpcInterface. getChaintipHeight ( )
37
41
let networkGraph = NetworkGraph ( genesis_hash: reversedGenesisHash)
38
42
43
+ print ( " Genesis hash: \( PolarIntegrationTest . bytesToHexString ( bytes: genesisHash) ) " )
44
+ print ( " Genesis hash reversed: \( PolarIntegrationTest . bytesToHexString ( bytes: reversedGenesisHash) ) " )
45
+ print ( " Block 1 hash: \( try await rpcInterface. getBlockHashHex ( height: 1 ) ) " )
46
+ print ( " Block 2 hash: \( try await rpcInterface. getBlockHashHex ( height: 2 ) ) " )
47
+ print ( " Chaintip hash: \( PolarIntegrationTest . bytesToHexString ( bytes: chaintipHash) ) " )
48
+ print ( " Chaintip hash reversed: \( PolarIntegrationTest . bytesToHexString ( bytes: reversedChaintipHash) ) " )
49
+
39
50
let feeEstimator = LDKTraitImplementations . PolarFeeEstimator ( )
40
51
let broadcaster = LDKTraitImplementations . PolarBroadcaster ( rpcInterface: rpcInterface)
41
52
let logger = LDKTraitImplementations . PolarLogger ( )
42
53
let channelMonitorPersister = LDKTraitImplementations . PolarChannelMonitorPersister ( )
43
54
let channelManagerAndNetworkGraphPersisterAndEventHandler = LDKTraitImplementations . PolarChannelManagerAndNetworkGraphPersisterAndEventHandler ( )
44
55
let chainMonitor = ChainMonitor ( chain_source: Option_FilterZ ( value: nil ) , broadcaster: broadcaster, logger: logger, feeest: feeEstimator, persister: channelMonitorPersister)
45
56
46
- let channelManagerConstructor = ChannelManagerConstructor ( network: lightningNetwork, config: config, current_blockchain_tip_hash: reversedGenesisHash , current_blockchain_tip_height: UInt32 ( 0 ) , keys_interface: keysInterface, fee_estimator: feeEstimator, chain_monitor: chainMonitor, net_graph: networkGraph, tx_broadcaster: broadcaster, logger: logger)
57
+ let channelManagerConstructor = ChannelManagerConstructor ( network: lightningNetwork, config: config, current_blockchain_tip_hash: reversedChaintipHash , current_blockchain_tip_height: UInt32 ( chaintipHeight ) , keys_interface: keysInterface, fee_estimator: feeEstimator, chain_monitor: chainMonitor, net_graph: networkGraph, tx_broadcaster: broadcaster, logger: logger)
47
58
let channelManager = channelManagerConstructor. channelManager
48
59
let peerManager = channelManagerConstructor. peerManager
49
60
let tcpPeerHandler = TCPPeerHandler ( peerManager: peerManager)
@@ -71,9 +82,8 @@ public class PolarIntegrationTest: XCTestCase {
71
82
72
83
let listener = Listener ( channelManager: channelManager, chainMonitor: chainMonitor)
73
84
rpcInterface. registerListener ( listener) ;
74
- try await rpcInterface. preloadMonitor ( anchorHeight: . genesis) ;
75
- channelManagerConstructor. chain_sync_completed ( persister: channelManagerAndNetworkGraphPersisterAndEventHandler, scorer: nil ) ;
76
85
async let monitor = try rpcInterface. monitorBlockchain ( )
86
+ channelManagerConstructor. chain_sync_completed ( persister: channelManagerAndNetworkGraphPersisterAndEventHandler, scorer: nil )
77
87
78
88
let lndPubkey = PolarIntegrationTest . hexStringToBytes ( hexString: PolarIntegrationTest . POLAR_LND_PEER_PUBKEY_HEX) !
79
89
let connectionSuccess = tcpPeerHandler. connect ( address: " 127.0.0.1 " , port: 9735 , theirNodeId: lndPubkey)
0 commit comments