File tree Expand file tree Collapse file tree
cashu-gateway-phoenixd/src
main/java/xyz/tcheeric/gateway/phoenixd/service
test/java/xyz/tcheeric/gateway/phoenixd/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package xyz .tcheeric .gateway .phoenixd .service ;
2+
3+ import xyz .tcheeric .phoenixd .mock .MockLnServer ;
4+
5+ import java .io .IOException ;
6+
7+ /**
8+ * PhoenixdService implementation that starts a {@link MockLnServer}
9+ * and delegates requests to the mock gateway endpoints.
10+ */
11+ public class PhoenixdMockServiceImpl extends PhoenixdServiceImpl {
12+
13+ private final MockLnServer server ;
14+
15+ public PhoenixdMockServiceImpl () {
16+ this (9740 );
17+ }
18+
19+ public PhoenixdMockServiceImpl (int port ) {
20+ server = new MockLnServer (port );
21+ System .setProperty ("phoenixd.base_url" , "http://localhost:" + port );
22+ try {
23+ server .start ();
24+ } catch (IOException e ) {
25+ throw new IllegalStateException ("Unable to start MockLnServer" , e );
26+ }
27+ }
28+
29+ public void stop () {
30+ server .stop ();
31+ }
32+ }
33+
Original file line number Diff line number Diff line change 1+ package xyz .tcheeric .gateway .phoenixd .service ;
2+
3+ import org .junit .jupiter .api .Assertions ;
4+ import org .junit .jupiter .api .Test ;
5+ import xyz .tcheeric .phoenixd .model .param .CreateInvoiceParam ;
6+ import xyz .tcheeric .phoenixd .model .response .CreateInvoiceResponse ;
7+
8+ /**
9+ * Verifies that PhoenixdMockServiceImpl can create an invoice using the mock server.
10+ */
11+ public class PhoenixdMockServiceImplTest {
12+
13+ /**
14+ * Starts the mock server and ensures a non-null response when creating an invoice.
15+ */
16+ @ Test
17+ public void testCreateInvoice () {
18+ PhoenixdMockServiceImpl service = new PhoenixdMockServiceImpl ();
19+ CreateInvoiceParam param = new CreateInvoiceParam ();
20+ param .setAmountSat (1 );
21+ param .setDescription ("test" );
22+ CreateInvoiceResponse response = service .createInvoice (param );
23+ Assertions .assertNotNull (response );
24+ service .stop ();
25+ }
26+ }
27+
You can’t perform that action at this time.
0 commit comments