Skip to content

Conversation

@orbitalturtle
Copy link
Collaborator

This PR puts a basic test of the server in place, testing that the cli + server can properly make a payment.

To do so required a little refactoring:

  • IIUC initially a RefCell was added to the LndNodeSigner because the original version of tonic_lnd returns a mutable reference to the signer. However I don't think this reference needs to be mutable. For this PR, this was needed so we could spin up the onion messenger and server in a separate thread in the integration tests. But it's a change that could help with future efficiency as well now the onion messenger can be used in a multi-threaded way.
  • Split off the server formation logic from main.rs into a separate function so that we can call it in the integration tests as well.

Initially a RefCell was added to the LndNodeSigner because the original version
of tonic_lnd returns a mutable reference to the signer. However this reference
doesn't need to be mutable:
orbitalturtle/tonic_lnd#4

For this PR, this was needed so we could spin up the onion messenger and server
in a separate thread in the integration tests. But it's a change that could
help with future efficiency as well because the onion messenger can now be used
in a multi-threaded way.
It's just a more suitable location.
@codecov
Copy link

codecov bot commented Sep 6, 2024

Codecov Report

Attention: Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.

Project coverage is 0.00%. Comparing base (1cf2906) to head (63b0bd7).

Files with missing lines Patch % Lines
src/main.rs 0.00% 8 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##           master    #171   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files           1       1           
  Lines         126      92   -34     
======================================
+ Misses        126      92   -34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

pub(crate) struct LndNodeSigner {
pubkey: PublicKey,
secp_ctx: Secp256k1<secp256k1::All>,
signer: RefCell<&'a mut tonic_lnd::SignerClient>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally lol

Copy link
Contributor

@kannapoix kannapoix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still catching up architecture of the project, so my comments may wrong.

Ok(macaroon)
}

pub async fn setup_server(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming it as setup_and_run or just run feels more concrete to me because this function actually runs the server, not just setup.
How about implementing this functions as a method of LNDKServer the same as the run method of LndkOnionMessenger to maintains consistency across projects.

.tls_config(ServerTlsConfig::new().identity(identity))
.expect("couldn't configure tls")
.add_service(OffersServer::new(server))
.serve(addr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it good to use serve instead of serve_with_shutdown, which the original code used?

};
let lnd_cfg = LndCfg::new(self.address.clone(), creds);
let lnd_cfg = LndCfg::new(self.lnd_address.clone(), creds);
let mut client = get_lnd_client(lnd_cfg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about pass this client to LNDKServer?
In each LNDKServer's handler methods such as pay_offer, get_invoice, we initialize lnd client but it seems redundant. It seems this is out of scope of this PR, but I would like to know if there are any reasons for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants