Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into lnd-partial-payments
Browse files Browse the repository at this point in the history
  • Loading branch information
lollerfirst committed Jan 28, 2025
2 parents b56d956 + e3fb7f9 commit b750cd1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/cdk-integration-tests/src/init_pure_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub async fn create_and_start_test_mint() -> anyhow::Result<Arc<Mint>> {
mint_builder = mint_builder.add_ln_backend(
CurrencyUnit::Sat,
PaymentMethod::Bolt11,
MintMeltLimits::default(),
MintMeltLimits::new(1, 1_000),
ln_fake_backend,
);

Expand Down
13 changes: 13 additions & 0 deletions crates/cdk-integration-tests/tests/regtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use cdk_integration_tests::init_regtest::{
get_cln_dir, get_lnd_cert_file_path, get_lnd_dir, get_lnd_macaroon_path, get_mint_port,
get_mint_url, get_mint_ws_url, LND_RPC_ADDR, LND_TWO_RPC_ADDR,
};
use cdk_integration_tests::wait_for_mint_to_be_paid;
use futures::{join, SinkExt, StreamExt};
use lightning_invoice::Bolt11Invoice;
use ln_regtest_rs::ln_client::{ClnClient, LightningClient, LndClient};
Expand Down Expand Up @@ -95,6 +96,8 @@ async fn test_regtest_mint_melt_round_trip() -> Result<()> {

lnd_client.pay_invoice(mint_quote.request).await.unwrap();

wait_for_mint_to_be_paid(&wallet, &mint_quote.id).await?;

let proofs = wallet
.mint(&mint_quote.id, SplitTarget::default(), None)
.await?;
Expand Down Expand Up @@ -177,6 +180,8 @@ async fn test_regtest_mint_melt() -> Result<()> {

lnd_client.pay_invoice(mint_quote.request).await?;

wait_for_mint_to_be_paid(&wallet, &mint_quote.id).await?;

let proofs = wallet
.mint(&mint_quote.id, SplitTarget::default(), None)
.await?;
Expand Down Expand Up @@ -205,6 +210,8 @@ async fn test_restore() -> Result<()> {

lnd_client.pay_invoice(mint_quote.request).await?;

wait_for_mint_to_be_paid(&wallet, &mint_quote.id).await?;

let _mint_amount = wallet
.mint(&mint_quote.id, SplitTarget::default(), None)
.await?;
Expand Down Expand Up @@ -265,6 +272,8 @@ async fn test_pay_invoice_twice() -> Result<()> {
.await
.expect("Could not pay invoice");

wait_for_mint_to_be_paid(&wallet, &mint_quote.id).await?;

let proofs = wallet
.mint(&mint_quote.id, SplitTarget::default(), None)
.await?;
Expand Down Expand Up @@ -319,6 +328,8 @@ async fn test_internal_payment() -> Result<()> {

lnd_client.pay_invoice(mint_quote.request).await?;

wait_for_mint_to_be_paid(&wallet, &mint_quote.id).await?;

let _mint_amount = wallet
.mint(&mint_quote.id, SplitTarget::default(), None)
.await?;
Expand All @@ -343,6 +354,8 @@ async fn test_internal_payment() -> Result<()> {

let _melted = wallet.melt(&melt.id).await.unwrap();

wait_for_mint_to_be_paid(&wallet, &mint_quote.id).await?;

let _wallet_2_mint = wallet_2
.mint(&mint_quote.id, SplitTarget::default(), None)
.await
Expand Down
6 changes: 3 additions & 3 deletions crates/cdk/src/mint/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ impl MintBuilder {
}
}

/// Mint Melt Limits
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
/// Mint and Melt Limits
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct MintMeltLimits {
/// Min mint amount
pub mint_min: Amount,
Expand All @@ -256,7 +256,7 @@ pub struct MintMeltLimits {
}

impl MintMeltLimits {
/// Create new [`MintMeltLimits`]
/// Create new [`MintMeltLimits`]. The `min` and `max` limits apply to both minting and melting.
pub fn new(min: u64, max: u64) -> Self {
Self {
mint_min: min.into(),
Expand Down
3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ test: build
fi
cargo test --lib
# Run pure integration tests
cargo test -p cdk-integration-tests --test integration_tests_pure

# run `cargo clippy` on everything
clippy *ARGS="--locked --offline --workspace --all-targets":
cargo clippy {{ARGS}}
Expand Down

0 comments on commit b750cd1

Please sign in to comment.