New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Eclair 0.3.3 #1097
Merged
Merged
Support for Eclair 0.3.3 #1097
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package org.bitcoins.eclair.rpc | ||
|
||
import java.nio.file.Files | ||
import java.time.Instant | ||
|
||
import org.bitcoins.core.currency.{CurrencyUnit, CurrencyUnits, Satoshis} | ||
import org.bitcoins.core.number.UInt64 | ||
|
@@ -31,7 +32,6 @@ import org.scalatest.Assertion | |
|
||
import scala.concurrent._ | ||
import scala.concurrent.duration.{DurationInt, _} | ||
import scala.reflect.ClassTag | ||
|
||
class EclairRpcClientTest extends BitcoinSAsyncTest { | ||
|
||
|
@@ -153,6 +153,10 @@ class EclairRpcClientTest extends BitcoinSAsyncTest { | |
invoice <- client4.createInvoice("foo", 1000.msats) | ||
info <- client4.getInfo | ||
_ = assert(info.nodeId == invoice.nodeId) | ||
_ = assert( | ||
info.publicAddresses | ||
.map(_.getHostString) | ||
.exists(_.endsWith(".onion"))) | ||
route <- client1.findRoute(invoice, None) | ||
} yield { | ||
route.size == 4 | ||
|
@@ -533,12 +537,20 @@ class EclairRpcClientTest extends BitcoinSAsyncTest { | |
preimage = PaymentPreimage.random | ||
invoice <- otherClient.createInvoice("foo", amt, preimage) | ||
route <- client.findRoute(otherClientNodeId, amt) | ||
paymentId <- client.sendToRoute(route, | ||
amt, | ||
invoice.lnTags.paymentHash.hash, | ||
144, | ||
Some("ext_id")) | ||
_ <- EclairRpcTestUtil.awaitUntilPaymentSucceeded(client, paymentId) | ||
result <- client.sendToRoute(invoice, | ||
route, | ||
amt, | ||
invoice.lnTags.paymentHash.hash, | ||
finalCltvExpiry = 144, | ||
recipientAmountMsat = None, | ||
parentId = None, | ||
externalId = Some("ext_id")) | ||
_ <- EclairRpcTestUtil | ||
.awaitUntilIncomingPaymentStatus[IncomingPaymentStatus.Received]( | ||
otherClient, | ||
invoice.lnTags.paymentHash.hash) | ||
_ <- EclairRpcTestUtil.awaitUntilPaymentSucceeded(client, | ||
result.parentId) | ||
succeeded <- client.getSentInfo(invoice.lnTags.paymentHash.hash) | ||
} yield { | ||
assert(otherClientNodeId == invoice.nodeId) | ||
|
@@ -937,11 +949,11 @@ class EclairRpcClientTest extends BitcoinSAsyncTest { | |
|
||
// allupdates for a single node is broken in Eclair 0.3.2 | ||
// TODO remove recoverToPendingIf when https://github.com/ACINQ/eclair/issues/1179 is fixed | ||
recoverToPendingIf[RuntimeException](sendPaymentsF.flatMap { _ => | ||
sendPaymentsF.flatMap { _ => | ||
executeSpecificClients(clientF = client1F, | ||
otherClientF = client2F, | ||
test = getChannelUpdates) | ||
}) | ||
} | ||
|
||
} | ||
|
||
|
@@ -1034,31 +1046,16 @@ class EclairRpcClientTest extends BitcoinSAsyncTest { | |
}) | ||
} | ||
|
||
def recoverToPendingIf[T <: AnyRef](future: Future[Any])( | ||
implicit classTag: ClassTag[T]): Future[Assertion] = { | ||
|
||
val clazz = classTag.runtimeClass | ||
future.failed.transform( | ||
ex => | ||
if (!clazz.isAssignableFrom(ex.getClass)) | ||
fail(s"Unknown exception ${ex}") | ||
else pending, | ||
ex => { | ||
fail(s"Unexpected exception ${ex}") | ||
} | ||
) | ||
} | ||
|
||
it should "get updates for a single node" in { | ||
// allupdates for a single node is broken in Eclair 0.3.2 | ||
// TODO remove recoverToPendingIf when https://github.com/ACINQ/eclair/issues/1179 is fixed | ||
recoverToPendingIf[RuntimeException](for { | ||
for { | ||
client <- clientF | ||
nodeInfo <- client.getInfo | ||
updates <- client.allUpdates(nodeInfo.nodeId) | ||
} yield { | ||
assert(updates.nonEmpty) | ||
}) | ||
} | ||
} | ||
|
||
it must "receive gossip messages about channel updates for nodes we do not have a direct channel with" in { | ||
|
@@ -1100,12 +1097,11 @@ class EclairRpcClientTest extends BitcoinSAsyncTest { | |
//which is why i am choosing to use them for this test | ||
// allupdates for a single node is broken in Eclair 0.3.2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this got fixed, can we remove it? |
||
// TODO remove pendingUntilFixed when https://github.com/ACINQ/eclair/issues/1179 is fixed | ||
recoverToPendingIf[RuntimeException]( | ||
executeSpecificClients( | ||
clientF = secondClientF, | ||
otherClientF = fourthClientF, | ||
test = gossipFromPeerWithNoChannel | ||
)) | ||
executeSpecificClients( | ||
clientF = secondClientF, | ||
otherClientF = fourthClientF, | ||
test = gossipFromPeerWithNoChannel | ||
) | ||
} | ||
|
||
it should "detect what network we are on" in { | ||
|
@@ -1152,12 +1148,15 @@ class EclairRpcClientTest extends BitcoinSAsyncTest { | |
} | ||
} | ||
|
||
it should "list invoice" in { | ||
it should "list invoices" in { | ||
for { | ||
c <- clientF | ||
res <- c.listInvoices(from = None, to = None) | ||
res <- c.listInvoices(from = None, to = Some(Instant.now())) | ||
i <- c.createInvoice(description = "abc") | ||
pending <- c.listPendingInvoices(from = None, to = None) | ||
} yield { | ||
assert(res.nonEmpty) | ||
assert(pending.exists(_ == i)) | ||
} | ||
} | ||
|
||
|
@@ -1170,6 +1169,15 @@ class EclairRpcClientTest extends BitcoinSAsyncTest { | |
} | ||
} | ||
|
||
it should "get new address" in { | ||
for { | ||
c <- clientF | ||
res <- c.getNewAddress() | ||
} yield { | ||
assert(res.toString.nonEmpty) | ||
} | ||
} | ||
|
||
it should "disconnect node" in { | ||
for { | ||
c1 <- clientF | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is fixed, can we remove it?