-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use indexing operator instead of get call added tests
- Loading branch information
Showing
2 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
app/src/test/kotlin/net/primal/android/wallet/utils/LnInvoiceUtilsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package net.primal.android.wallet.utils | ||
|
||
import io.kotest.matchers.shouldBe | ||
import org.junit.Test | ||
|
||
class LnInvoiceUtilsTest { | ||
|
||
private val validLnInvoice = "lnbc123450n1pj7welppp53umfyxp6jn9uvkt463hydtq2zpfvz78hxhpfv9wqx6v4uwdw2rnqdzqg3hkuct5v56zu" + | ||
"3n4dcsxgmmwv96xjmmwyp6x7gzqgpc8ymmrv4h8ghmrwfuhqar0cqzpgxqrrsssp5tntqjpngx6l8y9va9tzd7fmtemtyp5vvsqphw8f8yqjjr" + | ||
"r26x5qs9qyyssqyyv7tqp5kpsmv6s5825kcq8fxsn4ag2h5uj2j6lnsnclyyq6844khayzqrl7yue46nwlukfr4uftqcwzxzh8krqg9rqsg9tg6x" + | ||
"ggszcp0gyjcd" | ||
|
||
private val invoiceInvalidCharacter = "lnbc123450n1pj7welpp 53umfyxp6jn9uvkt463hydtq2zpfvz78hxhpfv9wqx6v4uwdw2rnqdzqg3hkuct5v56zu" + | ||
"3n4dcsxgmmwv96xjmmwyp6x7gzqgpc8ymmrv4h8ghmrwfuhqar0cqzpgxqrrsssp5tntqjpngx6l8y9va9tzd7fmtemtyp5vvsqphw8f8yqjjr" + | ||
"r26x5qs9qyyssqyyv7tqp5kpsmv6s5825kcq8fxsn4ag2h5uj2j6lnsnclyyq6844khayzqrl7yue46nwlukfr4uftqcwzxzh8krqg9rqsg9tg6x" + | ||
"ggszcp0gyjcd" | ||
|
||
private val invalidLnInvoice = "lnbc123450n1pj7welppp53umfyxp6jn9uvkt463hydtq2zpfvz78hxhpfv9wqx6v4uwdw2rnqdzqg3hkuct5v56zu" + | ||
"3n4dcsxgmmwv96xjmmwyp6x7gzqgpc8ymmrv4h8ghmrwXuhqar0cqzpgxqrrsssp5tntqjpngx6l8y9va9tzd7fmtemtyp5vvsqphw8f8yqjjr" + | ||
"r26x5qs9qyyssqyyv7tqp5kpsmv6s5825kcq8fxsn4ag2h5uj2j6lnsnclyyq6844khayzqrl7yue46nwlukfr4uftqcwzxzh8krqg9rqsg9tg6x" + | ||
"ggszcp0gyjcd" | ||
|
||
private val validLnInvoiceNoAmount = "lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqy" + | ||
"pqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d73gafn" + | ||
"h3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ecky03ylcqca784w" | ||
|
||
@Test | ||
fun getAmountInSatsValidInvoice() { | ||
val expectedValue = 12345 | ||
|
||
val amount = LnInvoiceUtils.getAmountInSats(validLnInvoice) | ||
|
||
amount.toInt() shouldBe expectedValue | ||
|
||
} | ||
|
||
@Test | ||
fun getAmountInSatsValidInvoiceNoAmount() { | ||
val expectedValue = 0 | ||
|
||
val amount = LnInvoiceUtils.getAmountInSats(validLnInvoiceNoAmount) | ||
|
||
amount.toInt() shouldBe expectedValue | ||
|
||
} | ||
|
||
@Test(expected = IllegalArgumentException::class) | ||
fun getAmountInSatsInvalidInvoice() { | ||
|
||
LnInvoiceUtils.getAmountInSats(invalidLnInvoice) | ||
|
||
} | ||
|
||
@Test(expected = IllegalArgumentException::class) | ||
fun getAmountInSatsInvalidCharacter() { | ||
|
||
LnInvoiceUtils.getAmountInSats(invoiceInvalidCharacter) | ||
|
||
} | ||
} |