add incoming-base-fee and outgoing-base-fee endpoints

This commit is contained in:
Carsten Otto
2021-11-12 14:58:53 +01:00
parent 6cbced801a
commit 3b28617eb9
7 changed files with 130 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
package de.cotto.lndmanagej.controller;
import de.cotto.lndmanagej.model.ChannelFixtures;
import de.cotto.lndmanagej.model.Coins;
import de.cotto.lndmanagej.model.LocalChannel;
import de.cotto.lndmanagej.service.ChannelService;
import de.cotto.lndmanagej.service.FeeService;
@@ -109,4 +110,16 @@ class LegacyControllerTest {
when(feeService.getOutgoingFeeRate(CHANNEL_ID)).thenReturn(123L);
assertThat(legacyController.getOutgoingFeeRate(CHANNEL_ID)).isEqualTo(123);
}
@Test
void getIncomingBaseFee() {
when(feeService.getIncomingBaseFee(CHANNEL_ID)).thenReturn(Coins.ofMilliSatoshis(10L));
assertThat(legacyController.getIncomingBaseFee(CHANNEL_ID)).isEqualTo(10);
}
@Test
void getOutgoingBaseFee() {
when(feeService.getOutgoingBaseFee(CHANNEL_ID)).thenReturn(Coins.ofMilliSatoshis(10L));
assertThat(legacyController.getOutgoingBaseFee(CHANNEL_ID)).isEqualTo(10);
}
}

View File

@@ -1,6 +1,7 @@
package de.cotto.lndmanagej.service;
import de.cotto.lndmanagej.grpc.GrpcFees;
import de.cotto.lndmanagej.model.Coins;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
@@ -45,4 +46,28 @@ class FeeServiceTest {
when(grpcFees.getOutgoingFeeRate(CHANNEL_ID)).thenReturn(Optional.empty());
assertThatIllegalStateException().isThrownBy(() -> feeService.getOutgoingFeeRate(CHANNEL_ID));
}
@Test
void getIncomingBaseFee() {
when(grpcFees.getIncomingBaseFee(CHANNEL_ID)).thenReturn(Optional.of(Coins.ofMilliSatoshis(123L)));
assertThat(feeService.getIncomingBaseFee(CHANNEL_ID)).isEqualTo(Coins.ofMilliSatoshis(123L));
}
@Test
void getIncomingBaseFee_empty() {
when(grpcFees.getIncomingBaseFee(CHANNEL_ID)).thenReturn(Optional.empty());
assertThatIllegalStateException().isThrownBy(() -> feeService.getIncomingBaseFee(CHANNEL_ID));
}
@Test
void getOutgoingBaseFee() {
when(grpcFees.getOutgoingBaseFee(CHANNEL_ID)).thenReturn(Optional.of(Coins.ofMilliSatoshis(123L)));
assertThat(feeService.getOutgoingBaseFee(CHANNEL_ID)).isEqualTo(Coins.ofMilliSatoshis(123L));
}
@Test
void getOutgoingBaseFee_empty() {
when(grpcFees.getOutgoingBaseFee(CHANNEL_ID)).thenReturn(Optional.empty());
assertThatIllegalStateException().isThrownBy(() -> feeService.getOutgoingBaseFee(CHANNEL_ID));
}
}