Skip to content

Commit

Permalink
Use testnet4 for mempool space unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sstone committed Oct 9, 2024
1 parent e16e7f5 commit e7e15bf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class MempoolSpaceClient(val mempoolUrl: Url, loggerFactory: LoggerFactory) : IC
companion object {
val OfficialMempoolMainnet = Url("https://mempool.space")
val OfficialMempoolTestnet = Url("https://mempool.space/testnet/")
val OfficialMempoolTestnet4 = Url("https://mempool.space/testnet4/")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package fr.acinq.lightning.blockchain.mempool

import fr.acinq.bitcoin.TxId
import fr.acinq.lightning.blockchain.mempool.MempoolSpaceClient.Companion.OfficialMempoolMainnet
import fr.acinq.lightning.blockchain.mempool.MempoolSpaceClient.Companion.OfficialMempoolTestnet
import fr.acinq.lightning.blockchain.mempool.MempoolSpaceClient.Companion.OfficialMempoolTestnet4
import fr.acinq.lightning.tests.utils.LightningTestSuite
import fr.acinq.lightning.tests.utils.runSuspendTest
import fr.acinq.lightning.tests.utils.testLoggerFactory
Expand All @@ -14,8 +14,8 @@ import kotlin.test.assertTrue
class MempoolSpaceClientTest : LightningTestSuite() {

@Test
fun `retrieve feerates -- testnet`() = runSuspendTest {
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet, testLoggerFactory)
fun `retrieve feerates -- testnet4`() = runSuspendTest {
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet4, testLoggerFactory)
val feerates = client.getFeerates()
assertNotNull(feerates)
}
Expand All @@ -28,11 +28,11 @@ class MempoolSpaceClientTest : LightningTestSuite() {
}

@Test
fun `get tx -- testnet`() = runSuspendTest {
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet, testLoggerFactory)
val res = client.getTransaction(TxId("5693d68997abfacb65cc7e6019e8ed2edb3f9f2260ae8d221e8726b8fe870ae0"))
fun `get tx -- testnet4`() = runSuspendTest {
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet4, testLoggerFactory)
val res = client.getTransaction(TxId("002f3246fa012ded792050f4a834e2eccdd772e1c7dc3a6a88cd6acdcbb9a2b2"))
assertNotNull(res)
assertEquals(TxId("5693d68997abfacb65cc7e6019e8ed2edb3f9f2260ae8d221e8726b8fe870ae0"), res.txid)
assertEquals(TxId("002f3246fa012ded792050f4a834e2eccdd772e1c7dc3a6a88cd6acdcbb9a2b2"), res.txid)
}

@Test
Expand All @@ -44,9 +44,9 @@ class MempoolSpaceClientTest : LightningTestSuite() {
}

@Test
fun `get tx confirmations -- testnet`() = runSuspendTest {
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet, testLoggerFactory)
val res = client.getConfirmations(TxId("5693d68997abfacb65cc7e6019e8ed2edb3f9f2260ae8d221e8726b8fe870ae0"))
fun `get tx confirmations -- testnet4`() = runSuspendTest {
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet4, testLoggerFactory)
val res = client.getConfirmations(TxId("002f3246fa012ded792050f4a834e2eccdd772e1c7dc3a6a88cd6acdcbb9a2b2"))
assertNotNull(res)
assertTrue(res > 0)
}
Expand All @@ -60,15 +60,15 @@ class MempoolSpaceClientTest : LightningTestSuite() {
}

@Test
fun `get spending tx -- testnet`() = runSuspendTest {
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet, testLoggerFactory)
val res = client.getOutspend(TxId("b97167ea09da62daaa1d3198460fc4c204a553cb3e5c80ab48f5b75a870f15c5"), 0)
fun `get spending tx -- testnet4`() = runSuspendTest {
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet4, testLoggerFactory)
val res = client.getOutspend(TxId("002f3246fa012ded792050f4a834e2eccdd772e1c7dc3a6a88cd6acdcbb9a2b2"), 1)
assertNotNull(res)
assertEquals(TxId("5693d68997abfacb65cc7e6019e8ed2edb3f9f2260ae8d221e8726b8fe870ae0"), res.txid)
assertEquals(TxId("8bce727fe08fbb79f02682f71d0b1f33a79039cd7a70623a51945bf2dc86d77c"), res.txid)
}

@Test
fun `get spending tx -- mainnet`() = runSuspendTest {
fun `get spending tx -- mainnet4`() = runSuspendTest {
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolMainnet, testLoggerFactory)
val res = client.getOutspend(TxId("308c09d986000be7f05ba776b38204317bf928b70db65bf175af7f2036951649"), 3)
assertNotNull(res)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import fr.acinq.bitcoin.Transaction
import fr.acinq.bitcoin.TxId
import fr.acinq.lightning.Lightning.randomBytes32
import fr.acinq.lightning.blockchain.*
import fr.acinq.lightning.blockchain.mempool.MempoolSpaceClient.Companion.OfficialMempoolTestnet
import fr.acinq.lightning.blockchain.mempool.MempoolSpaceClient.Companion.OfficialMempoolTestnet4
import fr.acinq.lightning.tests.utils.LightningTestSuite
import fr.acinq.lightning.tests.utils.runSuspendTest
import fr.acinq.lightning.tests.utils.testLoggerFactory
Expand All @@ -20,7 +20,7 @@ class MempoolSpaceWatcherTest : LightningTestSuite() {

@Test
fun `watch-spent on a transaction`() = runSuspendTest {
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet, testLoggerFactory)
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet4, testLoggerFactory)
val watcher = MempoolSpaceWatcher(client, scope = this, testLoggerFactory)

val notifications = watcher.openWatchNotificationsFlow()
Expand All @@ -43,7 +43,7 @@ class MempoolSpaceWatcherTest : LightningTestSuite() {

@Test
fun `watch-confirmed on a transaction`() = runSuspendTest {
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet, testLoggerFactory)
val client = MempoolSpaceClient(mempoolUrl = OfficialMempoolTestnet4, testLoggerFactory)
val watcher = MempoolSpaceWatcher(client, scope = this, testLoggerFactory)

val notifications = watcher.openWatchNotificationsFlow()
Expand Down

0 comments on commit e7e15bf

Please sign in to comment.