|
|
@ -5,23 +5,20 @@ import org.scalatest.{MustMatchers, OptionValues, WordSpec} |
|
|
|
|
|
|
|
class AddressSpec extends WordSpec with MustMatchers with OptionValues { |
|
|
|
|
|
|
|
val addresses = Map( |
|
|
|
"xsn legacy" -> "19Gfgd95swmT8jmktPK19mbYw9hiBGYV4", |
|
|
|
"P2WPKH" -> "bc1qzhayf65p2j4h3pfw22aujgr5w42xfqzx5uvddt", |
|
|
|
"bech32" -> "xc1qphyjl73szcnz3jfpjryljx8elwc6wpdqqccy3s8g57gw7e44hw4q2jqdds", |
|
|
|
"btc address 1" -> "1111111111111111111114oLvT2", |
|
|
|
) |
|
|
|
|
|
|
|
"from" should { |
|
|
|
"allow to create a legacy address" in { |
|
|
|
val input = "Xvjue2ZLnJwTrSLUBx7DTHaSHTdpWrxtLF" |
|
|
|
val result = Address.from(input) |
|
|
|
result.value.string mustEqual input |
|
|
|
} |
|
|
|
|
|
|
|
"allow to create a P2WPKH address" in { |
|
|
|
val input = "bc1qzhayf65p2j4h3pfw22aujgr5w42xfqzx5uvddt" |
|
|
|
addresses.foreach { case (tpe, input) => |
|
|
|
s"allow $tpe" in { |
|
|
|
val result = Address.from(input) |
|
|
|
result.value.string mustEqual input |
|
|
|
} |
|
|
|
|
|
|
|
"allow to create segwit address (bech32)" in { |
|
|
|
val input = "xc1qphyjl73szcnz3jfpjryljx8elwc6wpdqqccy3s8g57gw7e44hw4q2jqdds" |
|
|
|
val result = Address.from(input) |
|
|
|
result.value.string mustEqual input |
|
|
|
} |
|
|
|
|
|
|
|
"reject an empty string" in { |
|
|
|