Skip to content

Commit 538e945

Browse files
authored
Use testnet4 for mempool space unit tests (#712)
* Use testnet4 for mempool space unit tests
1 parent eed5998 commit 538e945

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

src/commonMain/kotlin/fr/acinq/lightning/blockchain/mempool/MempoolSpaceClient.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ class MempoolSpaceClient(val mempoolUrl: Url, loggerFactory: LoggerFactory) : IC
115115

116116
companion object {
117117
val OfficialMempoolMainnet = Url("https://mempool.space")
118-
val OfficialMempoolTestnet = Url("https://mempool.space/testnet/")
118+
val OfficialMempoolTestnet3 = Url("https://mempool.space/testnet/")
119+
val OfficialMempoolTestnet4 = Url("https://mempool.space/testnet4/")
119120
}
120121
}
121122

src/commonTest/kotlin/fr/acinq/lightning/blockchain/mempool/MempoolSpaceClientTest.kt

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@ package fr.acinq.lightning.blockchain.mempool
22

33
import fr.acinq.bitcoin.TxId
44
import fr.acinq.lightning.blockchain.mempool.MempoolSpaceClient.Companion.OfficialMempoolMainnet
5-
import fr.acinq.lightning.blockchain.mempool.MempoolSpaceClient.Companion.OfficialMempoolTestnet
5+
import fr.acinq.lightning.blockchain.mempool.MempoolSpaceClient.Companion.OfficialMempoolTestnet4
66
import fr.acinq.lightning.tests.utils.LightningTestSuite
77
import fr.acinq.lightning.tests.utils.runSuspendTest
88
import fr.acinq.lightning.tests.utils.testLoggerFactory
99
import kotlin.test.*
1010

11-
@Ignore
1211
class MempoolSpaceClientTest : LightningTestSuite() {
1312

1413
@Test
15-
fun `retrieve feerates -- testnet`() = runSuspendTest {
16-
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet, testLoggerFactory)
14+
fun `retrieve feerates -- testnet4`() = runSuspendTest {
15+
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet4, testLoggerFactory)
1716
val feerates = client.getFeerates()
1817
assertNotNull(feerates)
1918
}
@@ -26,11 +25,11 @@ class MempoolSpaceClientTest : LightningTestSuite() {
2625
}
2726

2827
@Test
29-
fun `get tx -- testnet`() = runSuspendTest {
30-
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet, testLoggerFactory)
31-
val res = client.getTransaction(TxId("5693d68997abfacb65cc7e6019e8ed2edb3f9f2260ae8d221e8726b8fe870ae0"))
28+
fun `get tx -- testnet4`() = runSuspendTest {
29+
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet4, testLoggerFactory)
30+
val res = client.getTransaction(TxId("002f3246fa012ded792050f4a834e2eccdd772e1c7dc3a6a88cd6acdcbb9a2b2"))
3231
assertNotNull(res)
33-
assertEquals(TxId("5693d68997abfacb65cc7e6019e8ed2edb3f9f2260ae8d221e8726b8fe870ae0"), res.txid)
32+
assertEquals(TxId("002f3246fa012ded792050f4a834e2eccdd772e1c7dc3a6a88cd6acdcbb9a2b2"), res.txid)
3433
}
3534

3635
@Test
@@ -42,9 +41,9 @@ class MempoolSpaceClientTest : LightningTestSuite() {
4241
}
4342

4443
@Test
45-
fun `get tx confirmations -- testnet`() = runSuspendTest {
46-
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet, testLoggerFactory)
47-
val res = client.getConfirmations(TxId("5693d68997abfacb65cc7e6019e8ed2edb3f9f2260ae8d221e8726b8fe870ae0"))
44+
fun `get tx confirmations -- testnet4`() = runSuspendTest {
45+
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet4, testLoggerFactory)
46+
val res = client.getConfirmations(TxId("002f3246fa012ded792050f4a834e2eccdd772e1c7dc3a6a88cd6acdcbb9a2b2"))
4847
assertNotNull(res)
4948
assertTrue(res > 0)
5049
}
@@ -58,15 +57,15 @@ class MempoolSpaceClientTest : LightningTestSuite() {
5857
}
5958

6059
@Test
61-
fun `get spending tx -- testnet`() = runSuspendTest {
62-
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet, testLoggerFactory)
63-
val res = client.getOutspend(TxId("b97167ea09da62daaa1d3198460fc4c204a553cb3e5c80ab48f5b75a870f15c5"), 0)
60+
fun `get spending tx -- testnet4`() = runSuspendTest {
61+
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet4, testLoggerFactory)
62+
val res = client.getOutspend(TxId("002f3246fa012ded792050f4a834e2eccdd772e1c7dc3a6a88cd6acdcbb9a2b2"), 1)
6463
assertNotNull(res)
65-
assertEquals(TxId("5693d68997abfacb65cc7e6019e8ed2edb3f9f2260ae8d221e8726b8fe870ae0"), res.txid)
64+
assertEquals(TxId("8bce727fe08fbb79f02682f71d0b1f33a79039cd7a70623a51945bf2dc86d77c"), res.txid)
6665
}
6766

6867
@Test
69-
fun `get spending tx -- mainnet`() = runSuspendTest {
68+
fun `get spending tx -- mainnet4`() = runSuspendTest {
7069
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolMainnet, testLoggerFactory)
7170
val res = client.getOutspend(TxId("308c09d986000be7f05ba776b38204317bf928b70db65bf175af7f2036951649"), 3)
7271
assertNotNull(res)

src/commonTest/kotlin/fr/acinq/lightning/blockchain/mempool/MempoolSpaceWatcherTest.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import fr.acinq.bitcoin.Transaction
55
import fr.acinq.bitcoin.TxId
66
import fr.acinq.lightning.Lightning.randomBytes32
77
import fr.acinq.lightning.blockchain.*
8-
import fr.acinq.lightning.blockchain.mempool.MempoolSpaceClient.Companion.OfficialMempoolTestnet
8+
import fr.acinq.lightning.blockchain.mempool.MempoolSpaceClient.Companion.OfficialMempoolTestnet4
99
import fr.acinq.lightning.tests.utils.LightningTestSuite
1010
import fr.acinq.lightning.tests.utils.runSuspendTest
1111
import fr.acinq.lightning.tests.utils.testLoggerFactory
@@ -17,26 +17,25 @@ import kotlin.test.assertEquals
1717
import kotlin.test.assertIs
1818
import kotlin.time.Duration.Companion.seconds
1919

20-
@Ignore
2120
class MempoolSpaceWatcherTest : LightningTestSuite() {
2221

2322
@Test
2423
fun `watch-spent on a transaction`() = runSuspendTest {
25-
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet, testLoggerFactory)
24+
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet4, testLoggerFactory)
2625
val watcher = MempoolSpaceWatcher(client, scope = this, testLoggerFactory)
2726

2827
val notifications = watcher.openWatchNotificationsFlow()
2928

3029
val watch = WatchSpent(
3130
channelId = randomBytes32(),
32-
txId = TxId("b97167ea09da62daaa1d3198460fc4c204a553cb3e5c80ab48f5b75a870f15c5"),
33-
outputIndex = 0,
31+
txId = TxId("002f3246fa012ded792050f4a834e2eccdd772e1c7dc3a6a88cd6acdcbb9a2b2"),
32+
outputIndex = 1,
3433
publicKeyScript = ByteVector.empty,
3534
event = BITCOIN_FUNDING_SPENT
3635
)
3736
watcher.watch(watch)
3837
val event = assertIs<WatchEventSpent>(notifications.first())
39-
assertEquals(TxId("5693d68997abfacb65cc7e6019e8ed2edb3f9f2260ae8d221e8726b8fe870ae0"), event.tx.txid)
38+
assertEquals(TxId("8bce727fe08fbb79f02682f71d0b1f33a79039cd7a70623a51945bf2dc86d77c"), event.tx.txid)
4039
// Right after checking whether the watched utxo is spent, a 2nd call is made by the watcher
4140
// to find out whether the spending tx is confirmed, and the watch can be cleaned up. We give
4241
// some time for that call to complete, in order to prevent a coroutine cancellation stack trace.
@@ -45,20 +44,20 @@ class MempoolSpaceWatcherTest : LightningTestSuite() {
4544

4645
@Test
4746
fun `watch-confirmed on a transaction`() = runSuspendTest {
48-
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet, testLoggerFactory)
47+
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet4, testLoggerFactory)
4948
val watcher = MempoolSpaceWatcher(client, scope = this, testLoggerFactory)
5049

5150
val notifications = watcher.openWatchNotificationsFlow()
5251

5352
val watch = WatchConfirmed(
5453
channelId = randomBytes32(),
55-
txId = TxId("5693d68997abfacb65cc7e6019e8ed2edb3f9f2260ae8d221e8726b8fe870ae0"),
54+
txId = TxId("8bce727fe08fbb79f02682f71d0b1f33a79039cd7a70623a51945bf2dc86d77c"),
5655
publicKeyScript = ByteVector.empty,
5756
event = BITCOIN_FUNDING_DEPTHOK,
5857
minDepth = 5
5958
)
6059
watcher.watch(watch)
6160
val event = assertIs<WatchEventConfirmed>(notifications.first())
62-
assertEquals(TxId("5693d68997abfacb65cc7e6019e8ed2edb3f9f2260ae8d221e8726b8fe870ae0"), event.tx.txid)
61+
assertEquals(TxId("8bce727fe08fbb79f02682f71d0b1f33a79039cd7a70623a51945bf2dc86d77c"), event.tx.txid)
6362
}
6463
}

0 commit comments

Comments
 (0)