Skip to content

Commit 5f66560

Browse files
committed
Move url const as payjoin_test_utils import
Use `EXAMPLE_URL` as import intead of new defintion in integration tests.
1 parent 69fa7d5 commit 5f66560

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

payjoin/tests/integration.rs

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
mod integration {
2-
#[cfg(feature = "v1")]
3-
const EXAMPLE_URL: &str = "https://example.com";
42
#[cfg(feature = "v1")]
53
mod v1 {
64
use std::collections::HashMap;
@@ -16,13 +14,11 @@ mod integration {
1614
use payjoin_test_utils::corepc_node::vtype::ListUnspentItem;
1715
use payjoin_test_utils::corepc_node::AddressType;
1816
use payjoin_test_utils::{
19-
corepc_node, init_bitcoind_sender_receiver, init_tracing, BoxError,
17+
corepc_node, init_bitcoind_sender_receiver, init_tracing, BoxError, EXAMPLE_URL,
2018
};
2119
use serde_json::json;
2220
use tracing::debug;
2321

24-
use super::*;
25-
2622
/// Transaction weight components for fee calculation
2723
/// Useful resource: https://bitcoin.stackexchange.com/a/84006
2824
const TX_HEADER_LEGACY_WEIGHT: u64 = 40;
@@ -101,8 +97,11 @@ mod integration {
10197
) -> Result<(), BoxError> {
10298
// Receiver creates the payjoin URI
10399
let pj_receiver_address = receiver.new_address()?;
104-
let mut pj_uri =
105-
build_v1_pj_uri(&pj_receiver_address, EXAMPLE_URL, OutputSubstitution::Enabled)?;
100+
let mut pj_uri = build_v1_pj_uri(
101+
&pj_receiver_address,
102+
EXAMPLE_URL.clone(),
103+
OutputSubstitution::Enabled,
104+
)?;
106105
pj_uri.amount = Some(Amount::ONE_BTC);
107106

108107
// **********************
@@ -160,8 +159,11 @@ mod integration {
160159

161160
// Receiver creates the payjoin URI
162161
let pj_receiver_address = receiver.new_address()?;
163-
let mut pj_uri =
164-
build_v1_pj_uri(&pj_receiver_address, EXAMPLE_URL, OutputSubstitution::Enabled)?;
162+
let mut pj_uri = build_v1_pj_uri(
163+
&pj_receiver_address,
164+
EXAMPLE_URL.clone(),
165+
OutputSubstitution::Enabled,
166+
)?;
165167
pj_uri.amount = Some(Amount::ONE_BTC);
166168

167169
// **********************
@@ -410,13 +412,12 @@ mod integration {
410412
};
411413
use payjoin_test_utils::{
412414
corepc_node, init_bitcoind_sender_receiver, init_tracing, BoxError, BoxSendSyncError,
413-
InMemoryTestPersister, TestServices,
415+
InMemoryTestPersister, TestServices, EXAMPLE_URL,
414416
};
415417
use reqwest::{Client, Response};
416418
use serde_json::json;
417419

418420
use super::v1::*;
419-
use super::*;
420421

421422
#[tokio::test]
422423
async fn test_bad_ohttp_keys() -> Result<(), BoxSendSyncError> {
@@ -785,8 +786,11 @@ mod integration {
785786
let (_bitcoind, sender, receiver) = init_bitcoind_sender_receiver(None, None)?;
786787
// Receiver creates the payjoin URI
787788
let pj_receiver_address = receiver.new_address()?;
788-
let mut pj_uri =
789-
build_v1_pj_uri(&pj_receiver_address, EXAMPLE_URL, OutputSubstitution::Enabled)?;
789+
let mut pj_uri = build_v1_pj_uri(
790+
&pj_receiver_address,
791+
EXAMPLE_URL.clone(),
792+
OutputSubstitution::Enabled,
793+
)?;
790794
pj_uri.amount = Some(Amount::ONE_BTC);
791795

792796
// **********************
@@ -1132,10 +1136,11 @@ mod integration {
11321136
use payjoin::send::v1::SenderBuilder;
11331137
use payjoin::{OutputSubstitution, Uri, UriExt};
11341138
use payjoin_test_utils::corepc_node::AddressType;
1135-
use payjoin_test_utils::{init_bitcoind_sender_receiver, init_tracing, BoxError};
1139+
use payjoin_test_utils::{
1140+
init_bitcoind_sender_receiver, init_tracing, BoxError, EXAMPLE_URL,
1141+
};
11361142

11371143
use super::v1::*;
1138-
use super::*;
11391144

11401145
// In this test the receiver consolidates a bunch of UTXOs into the destination output
11411146
#[test]
@@ -1155,8 +1160,11 @@ mod integration {
11551160

11561161
// Receiver creates the payjoin URI
11571162
let pj_receiver_address = receiver.new_address()?;
1158-
let mut pj_uri =
1159-
build_v1_pj_uri(&pj_receiver_address, EXAMPLE_URL, OutputSubstitution::Enabled)?;
1163+
let mut pj_uri = build_v1_pj_uri(
1164+
&pj_receiver_address,
1165+
EXAMPLE_URL.clone(),
1166+
OutputSubstitution::Enabled,
1167+
)?;
11601168
pj_uri.amount = Some(Amount::ONE_BTC);
11611169

11621170
// **********************
@@ -1235,8 +1243,11 @@ mod integration {
12351243

12361244
// Receiver creates the payjoin URI
12371245
let pj_receiver_address = receiver.new_address()?;
1238-
let mut pj_uri =
1239-
build_v1_pj_uri(&pj_receiver_address, EXAMPLE_URL, OutputSubstitution::Enabled)?;
1246+
let mut pj_uri = build_v1_pj_uri(
1247+
&pj_receiver_address,
1248+
EXAMPLE_URL.clone(),
1249+
OutputSubstitution::Enabled,
1250+
)?;
12401251
pj_uri.amount = Some(Amount::ONE_BTC);
12411252

12421253
// **********************

0 commit comments

Comments
 (0)