File tree Expand file tree Collapse file tree
main/java/to/bitkit/models
test/java/to/bitkit/models Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,5 +17,5 @@ data class BalanceState(
1717) {
1818 val totalSats get() = totalOnchainSats + totalLightningSats
1919
20- val totalWithHardwareSats get() = totalSats + totalHardwareSats
20+ val totalWithHardwareSats get() = totalSats.safe() + totalHardwareSats.safe()
2121}
Original file line number Diff line number Diff line change @@ -26,4 +26,10 @@ class BalanceStateTest {
2626 val state = BalanceState (totalOnchainSats = 100uL , totalLightningSats = 50uL )
2727 assertEquals(state.totalSats, state.totalWithHardwareSats)
2828 }
29+
30+ @Test
31+ fun `totalWithHardwareSats saturates instead of overflowing` () {
32+ val state = BalanceState (totalLightningSats = ULong .MAX_VALUE , totalHardwareSats = 10uL )
33+ assertEquals(ULong .MAX_VALUE , state.totalWithHardwareSats)
34+ }
2935}
You can’t perform that action at this time.
0 commit comments