Move hard coded test vectors from resource files into scala files (#2818)

* Remove sighash.json resource

* Remove trezor_bip39_vectors.json

* Hardcode transaction json test vectors

* Hardcode big size uint json test vectors

* Hardcode base58 json test vectors

* Hardcode script tests json test vectors

* Make BlockTest JVM only
This commit is contained in:
benthecarman 2021-03-23 12:06:18 -05:00 committed by GitHub
parent c5a3b5ac3f
commit 50d4e1f969
9 changed files with 1353 additions and 124 deletions

View File

@ -6,7 +6,6 @@ import org.scalatest.Assertion
import play.api.libs.json._
import scodec.bits.{BinStringSyntax, BitVector, ByteVector}
import scala.io.Source
import scala.util.{Failure, Try}
class MnemonicCodeTest extends BitcoinSUnitTest {
@ -234,14 +233,7 @@ class MnemonicCodeTest extends BitcoinSUnitTest {
}
}
val rawJsonStream = getClass
.getResourceAsStream("/trezor_bip39_vectors.json")
val rawJson =
Source
.fromInputStream(rawJsonStream)
.getLines()
.mkString("\n")
val rawJson = TrezorBIP39Vectors.str
val json = Json.parse(rawJson)
val testVectors =
@ -277,3 +269,156 @@ class MnemonicCodeTest extends BitcoinSUnitTest {
mnemonicCode.toStringSensitive must be(correctSeed.mkString(","))
}
}
object TrezorBIP39Vectors {
val str: String =
"""{
| "english": [
| [
| "00000000000000000000000000000000",
| "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",
| "c55257c360c07c72029aebc1b53c05ed0362ada38ead3e3e9efa3708e53495531f09a6987599d18264c1e1c92f2cf141630c7a3c4ab7c81b2f001698e7463b04",
| "xprv9s21ZrQH143K3h3fDYiay8mocZ3afhfULfb5GX8kCBdno77K4HiA15Tg23wpbeF1pLfs1c5SPmYHrEpTuuRhxMwvKDwqdKiGJS9XFKzUsAF"
| ],
| [
| "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f",
| "legal winner thank year wave sausage worth useful legal winner thank yellow",
| "2e8905819b8723fe2c1d161860e5ee1830318dbf49a83bd451cfb8440c28bd6fa457fe1296106559a3c80937a1c1069be3a3a5bd381ee6260e8d9739fce1f607",
| "xprv9s21ZrQH143K2gA81bYFHqU68xz1cX2APaSq5tt6MFSLeXnCKV1RVUJt9FWNTbrrryem4ZckN8k4Ls1H6nwdvDTvnV7zEXs2HgPezuVccsq"
| ],
| [
| "80808080808080808080808080808080",
| "letter advice cage absurd amount doctor acoustic avoid letter advice cage above",
| "d71de856f81a8acc65e6fc851a38d4d7ec216fd0796d0a6827a3ad6ed5511a30fa280f12eb2e47ed2ac03b5c462a0358d18d69fe4f985ec81778c1b370b652a8",
| "xprv9s21ZrQH143K2shfP28KM3nr5Ap1SXjz8gc2rAqqMEynmjt6o1qboCDpxckqXavCwdnYds6yBHZGKHv7ef2eTXy461PXUjBFQg6PrwY4Gzq"
| ],
| [
| "ffffffffffffffffffffffffffffffff",
| "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong",
| "ac27495480225222079d7be181583751e86f571027b0497b5b5d11218e0a8a13332572917f0f8e5a589620c6f15b11c61dee327651a14c34e18231052e48c069",
| "xprv9s21ZrQH143K2V4oox4M8Zmhi2Fjx5XK4Lf7GKRvPSgydU3mjZuKGCTg7UPiBUD7ydVPvSLtg9hjp7MQTYsW67rZHAXeccqYqrsx8LcXnyd"
| ],
| [
| "000000000000000000000000000000000000000000000000",
| "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon agent",
| "035895f2f481b1b0f01fcf8c289c794660b289981a78f8106447707fdd9666ca06da5a9a565181599b79f53b844d8a71dd9f439c52a3d7b3e8a79c906ac845fa",
| "xprv9s21ZrQH143K3mEDrypcZ2usWqFgzKB6jBBx9B6GfC7fu26X6hPRzVjzkqkPvDqp6g5eypdk6cyhGnBngbjeHTe4LsuLG1cCmKJka5SMkmU"
| ],
| [
| "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f",
| "legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth useful legal will",
| "f2b94508732bcbacbcc020faefecfc89feafa6649a5491b8c952cede496c214a0c7b3c392d168748f2d4a612bada0753b52a1c7ac53c1e93abd5c6320b9e95dd",
| "xprv9s21ZrQH143K3Lv9MZLj16np5GzLe7tDKQfVusBni7toqJGcnKRtHSxUwbKUyUWiwpK55g1DUSsw76TF1T93VT4gz4wt5RM23pkaQLnvBh7"
| ],
| [
| "808080808080808080808080808080808080808080808080",
| "letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter always",
| "107d7c02a5aa6f38c58083ff74f04c607c2d2c0ecc55501dadd72d025b751bc27fe913ffb796f841c49b1d33b610cf0e91d3aa239027f5e99fe4ce9e5088cd65",
| "xprv9s21ZrQH143K3VPCbxbUtpkh9pRG371UCLDz3BjceqP1jz7XZsQ5EnNkYAEkfeZp62cDNj13ZTEVG1TEro9sZ9grfRmcYWLBhCocViKEJae"
| ],
| [
| "ffffffffffffffffffffffffffffffffffffffffffffffff",
| "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo when",
| "0cd6e5d827bb62eb8fc1e262254223817fd068a74b5b449cc2f667c3f1f985a76379b43348d952e2265b4cd129090758b3e3c2c49103b5051aac2eaeb890a528",
| "xprv9s21ZrQH143K36Ao5jHRVhFGDbLP6FCx8BEEmpru77ef3bmA928BxsqvVM27WnvvyfWywiFN8K6yToqMaGYfzS6Db1EHAXT5TuyCLBXUfdm"
| ],
| [
| "0000000000000000000000000000000000000000000000000000000000000000",
| "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art",
| "bda85446c68413707090a52022edd26a1c9462295029f2e60cd7c4f2bbd3097170af7a4d73245cafa9c3cca8d561a7c3de6f5d4a10be8ed2a5e608d68f92fcc8",
| "xprv9s21ZrQH143K32qBagUJAMU2LsHg3ka7jqMcV98Y7gVeVyNStwYS3U7yVVoDZ4btbRNf4h6ibWpY22iRmXq35qgLs79f312g2kj5539ebPM"
| ],
| [
| "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f",
| "legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth title",
| "bc09fca1804f7e69da93c2f2028eb238c227f2e9dda30cd63699232578480a4021b146ad717fbb7e451ce9eb835f43620bf5c514db0f8add49f5d121449d3e87",
| "xprv9s21ZrQH143K3Y1sd2XVu9wtqxJRvybCfAetjUrMMco6r3v9qZTBeXiBZkS8JxWbcGJZyio8TrZtm6pkbzG8SYt1sxwNLh3Wx7to5pgiVFU"
| ],
| [
| "8080808080808080808080808080808080808080808080808080808080808080",
| "letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic bless",
| "c0c519bd0e91a2ed54357d9d1ebef6f5af218a153624cf4f2da911a0ed8f7a09e2ef61af0aca007096df430022f7a2b6fb91661a9589097069720d015e4e982f",
| "xprv9s21ZrQH143K3CSnQNYC3MqAAqHwxeTLhDbhF43A4ss4ciWNmCY9zQGvAKUSqVUf2vPHBTSE1rB2pg4avopqSiLVzXEU8KziNnVPauTqLRo"
| ],
| [
| "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
| "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo vote",
| "dd48c104698c30cfe2b6142103248622fb7bb0ff692eebb00089b32d22484e1613912f0a5b694407be899ffd31ed3992c456cdf60f5d4564b8ba3f05a69890ad",
| "xprv9s21ZrQH143K2WFF16X85T2QCpndrGwx6GueB72Zf3AHwHJaknRXNF37ZmDrtHrrLSHvbuRejXcnYxoZKvRquTPyp2JiNG3XcjQyzSEgqCB"
| ],
| [
| "9e885d952ad362caeb4efe34a8e91bd2",
| "ozone drill grab fiber curtain grace pudding thank cruise elder eight picnic",
| "274ddc525802f7c828d8ef7ddbcdc5304e87ac3535913611fbbfa986d0c9e5476c91689f9c8a54fd55bd38606aa6a8595ad213d4c9c9f9aca3fb217069a41028",
| "xprv9s21ZrQH143K2oZ9stBYpoaZ2ktHj7jLz7iMqpgg1En8kKFTXJHsjxry1JbKH19YrDTicVwKPehFKTbmaxgVEc5TpHdS1aYhB2s9aFJBeJH"
| ],
| [
| "6610b25967cdcca9d59875f5cb50b0ea75433311869e930b",
| "gravity machine north sort system female filter attitude volume fold club stay feature office ecology stable narrow fog",
| "628c3827a8823298ee685db84f55caa34b5cc195a778e52d45f59bcf75aba68e4d7590e101dc414bc1bbd5737666fbbef35d1f1903953b66624f910feef245ac",
| "xprv9s21ZrQH143K3uT8eQowUjsxrmsA9YUuQQK1RLqFufzybxD6DH6gPY7NjJ5G3EPHjsWDrs9iivSbmvjc9DQJbJGatfa9pv4MZ3wjr8qWPAK"
| ],
| [
| "68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c",
| "hamster diagram private dutch cause delay private meat slide toddler razor book happy fancy gospel tennis maple dilemma loan word shrug inflict delay length",
| "64c87cde7e12ecf6704ab95bb1408bef047c22db4cc7491c4271d170a1b213d20b385bc1588d9c7b38f1b39d415665b8a9030c9ec653d75e65f847d8fc1fc440",
| "xprv9s21ZrQH143K2XTAhys3pMNcGn261Fi5Ta2Pw8PwaVPhg3D8DWkzWQwjTJfskj8ofb81i9NP2cUNKxwjueJHHMQAnxtivTA75uUFqPFeWzk"
| ],
| [
| "c0ba5a8e914111210f2bd131f3d5e08d",
| "scheme spot photo card baby mountain device kick cradle pact join borrow",
| "ea725895aaae8d4c1cf682c1bfd2d358d52ed9f0f0591131b559e2724bb234fca05aa9c02c57407e04ee9dc3b454aa63fbff483a8b11de949624b9f1831a9612",
| "xprv9s21ZrQH143K3FperxDp8vFsFycKCRcJGAFmcV7umQmcnMZaLtZRt13QJDsoS5F6oYT6BB4sS6zmTmyQAEkJKxJ7yByDNtRe5asP2jFGhT6"
| ],
| [
| "6d9be1ee6ebd27a258115aad99b7317b9c8d28b6d76431c3",
| "horn tenant knee talent sponsor spell gate clip pulse soap slush warm silver nephew swap uncle crack brave",
| "fd579828af3da1d32544ce4db5c73d53fc8acc4ddb1e3b251a31179cdb71e853c56d2fcb11aed39898ce6c34b10b5382772db8796e52837b54468aeb312cfc3d",
| "xprv9s21ZrQH143K3R1SfVZZLtVbXEB9ryVxmVtVMsMwmEyEvgXN6Q84LKkLRmf4ST6QrLeBm3jQsb9gx1uo23TS7vo3vAkZGZz71uuLCcywUkt"
| ],
| [
| "9f6a2878b2520799a44ef18bc7df394e7061a224d2c33cd015b157d746869863",
| "panda eyebrow bullet gorilla call smoke muffin taste mesh discover soft ostrich alcohol speed nation flash devote level hobby quick inner drive ghost inside",
| "72be8e052fc4919d2adf28d5306b5474b0069df35b02303de8c1729c9538dbb6fc2d731d5f832193cd9fb6aeecbc469594a70e3dd50811b5067f3b88b28c3e8d",
| "xprv9s21ZrQH143K2WNnKmssvZYM96VAr47iHUQUTUyUXH3sAGNjhJANddnhw3i3y3pBbRAVk5M5qUGFr4rHbEWwXgX4qrvrceifCYQJbbFDems"
| ],
| [
| "23db8160a31d3e0dca3688ed941adbf3",
| "cat swing flag economy stadium alone churn speed unique patch report train",
| "deb5f45449e615feff5640f2e49f933ff51895de3b4381832b3139941c57b59205a42480c52175b6efcffaa58a2503887c1e8b363a707256bdd2b587b46541f5",
| "xprv9s21ZrQH143K4G28omGMogEoYgDQuigBo8AFHAGDaJdqQ99QKMQ5J6fYTMfANTJy6xBmhvsNZ1CJzRZ64PWbnTFUn6CDV2FxoMDLXdk95DQ"
| ],
| [
| "8197a4a47f0425faeaa69deebc05ca29c0a5b5cc76ceacc0",
| "light rule cinnamon wrap drastic word pride squirrel upgrade then income fatal apart sustain crack supply proud access",
| "4cbdff1ca2db800fd61cae72a57475fdc6bab03e441fd63f96dabd1f183ef5b782925f00105f318309a7e9c3ea6967c7801e46c8a58082674c860a37b93eda02",
| "xprv9s21ZrQH143K3wtsvY8L2aZyxkiWULZH4vyQE5XkHTXkmx8gHo6RUEfH3Jyr6NwkJhvano7Xb2o6UqFKWHVo5scE31SGDCAUsgVhiUuUDyh"
| ],
| [
| "066dca1a2bb7e8a1db2832148ce9933eea0f3ac9548d793112d9a95c9407efad",
| "all hour make first leader extend hole alien behind guard gospel lava path output census museum junior mass reopen famous sing advance salt reform",
| "26e975ec644423f4a4c4f4215ef09b4bd7ef924e85d1d17c4cf3f136c2863cf6df0a475045652c57eb5fb41513ca2a2d67722b77e954b4b3fc11f7590449191d",
| "xprv9s21ZrQH143K3rEfqSM4QZRVmiMuSWY9wugscmaCjYja3SbUD3KPEB1a7QXJoajyR2T1SiXU7rFVRXMV9XdYVSZe7JoUXdP4SRHTxsT1nzm"
| ],
| [
| "f30f8c1da665478f49b001d94c5fc452",
| "vessel ladder alter error federal sibling chat ability sun glass valve picture",
| "2aaa9242daafcee6aa9d7269f17d4efe271e1b9a529178d7dc139cd18747090bf9d60295d0ce74309a78852a9caadf0af48aae1c6253839624076224374bc63f",
| "xprv9s21ZrQH143K2QWV9Wn8Vvs6jbqfF1YbTCdURQW9dLFKDovpKaKrqS3SEWsXCu6ZNky9PSAENg6c9AQYHcg4PjopRGGKmdD313ZHszymnps"
| ],
| [
| "c10ec20dc3cd9f652c7fac2f1230f7a3c828389a14392f05",
| "scissors invite lock maple supreme raw rapid void congress muscle digital elegant little brisk hair mango congress clump",
| "7b4a10be9d98e6cba265566db7f136718e1398c71cb581e1b2f464cac1ceedf4f3e274dc270003c670ad8d02c4558b2f8e39edea2775c9e232c7cb798b069e88",
| "xprv9s21ZrQH143K4aERa2bq7559eMCCEs2QmmqVjUuzfy5eAeDX4mqZffkYwpzGQRE2YEEeLVRoH4CSHxianrFaVnMN2RYaPUZJhJx8S5j6puX"
| ],
| [
| "f585c11aec520db57dd353c69554b21a89b20fb0650966fa0a9d6f74fd989d8f",
| "void come effort suffer camp survey warrior heavy shoot primary clutch crush open amazing screen patrol group space point ten exist slush involve unfold",
| "01f5bced59dec48e362f2c45b5de68b9fd6c92c6634f44d6d40aab69056506f0e35524a518034ddc1192e1dacd32c1ed3eaa3c3b131c88ed8e7e54c49a5d0998",
| "xprv9s21ZrQH143K39rnQJknpH1WEPFJrzmAqqasiDcVrNuk926oizzJDDQkdiTvNPr2FYDYzWgiMiC63YmfPAa2oPyNB23r2g7d1yiK6WpqaQS"
| ]
| ]
|}""".stripMargin
}

View File

@ -6,8 +6,6 @@ import org.bitcoins.crypto.DoubleSha256DigestBE
import org.bitcoins.testkitcore.util.BitcoinSUnitTest
import play.api.libs.json.{JsArray, Json}
import scala.io.Source
class BlockFilterTest extends BitcoinSUnitTest {
behavior of "BlockFilter"
@ -88,12 +86,28 @@ class BlockFilterTest extends BitcoinSUnitTest {
}
it must "pass bip 158 test vectors" in {
val source = Source.fromURL(getClass.getResource("/testnet-19.json"))
val vec: Vector[JsArray] =
Json.parse(source.mkString).validate[Vector[JsArray]].get.tail
Json.parse(Testnet19.str.mkString).validate[Vector[JsArray]].get.tail
val testCases = vec.map(Bip158TestCase.fromJsArray)
testCases.foreach(_.runTest())
}
}
object Testnet19 {
val str: String =
"""[
| ["Block Height,Block Hash,Block,[Prev Output Scripts for Block],Previous Basic Header,Basic Filter,Basic Header,Notes"],
| [0,"000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943","0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5494dffff001d1aa4ae180101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000",[],"0000000000000000000000000000000000000000000000000000000000000000","019dfca8","21584579b7eb08997773e5aeff3a7f932700042d0ed2a6129012b7d7ae81b750","Genesis block"],
| [2,"000000006c02c8ea6e4ff69651f7fcde348fb9d557a06e6957b65552002a7820","0100000006128e87be8b1b4dea47a7247d5528d2702c96826c7a648497e773b800000000e241352e3bec0a95a6217e10c3abb54adfa05abb12c126695595580fb92e222032e7494dffff001d00d235340101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0e0432e7494d010e062f503253482fffffffff0100f2052a010000002321038a7f6ef1c8ca0c588aa53fa860128077c9e6c11e6830f4d7ee4e763a56b7718fac00000000",[],"d7bdac13a59d745b1add0d2ce852f1a0442e8945fc1bf3848d3cbffd88c24fe1","0174a170","186afd11ef2b5e7e3504f2e8cbf8df28a1fd251fe53d60dff8b1467d1b386cf0",""],
| [3,"000000008b896e272758da5297bcd98fdc6d97c9b765ecec401e286dc1fdbe10","0100000020782a005255b657696ea057d5b98f34defcf75196f64f6eeac8026c0000000041ba5afc532aae03151b8aa87b65e1594f97504a768e010c98c0add79216247186e7494dffff001d058dc2b60101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0e0486e7494d0151062f503253482fffffffff0100f2052a01000000232103f6d9ff4c12959445ca5549c811683bf9c88e637b222dd2e0311154c4c85cf423ac00000000",[],"186afd11ef2b5e7e3504f2e8cbf8df28a1fd251fe53d60dff8b1467d1b386cf0","016cf7a0","8d63aadf5ab7257cb6d2316a57b16f517bff1c6388f124ec4c04af1212729d2a",""],
| [15007,"0000000038c44c703bae0f98cdd6bf30922326340a5996cc692aaae8bacf47ad","0100000002394092aa378fe35d7e9ac79c869b975c4de4374cd75eb5484b0e1e00000000eb9b8670abd44ad6c55cee18e3020fb0c6519e7004b01a16e9164867531b67afc33bc94fffff001d123f10050101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0e04c33bc94f0115062f503253482fffffffff0100f2052a01000000232103f268e9ae07e0f8cb2f6e901d87c510d650b97230c0365b021df8f467363cafb1ac00000000",[],"18b5c2b0146d2d09d24fb00ff5b52bd0742f36c9e65527abdb9de30c027a4748","013c3710","07384b01311867949e0c046607c66b7a766d338474bb67f66c8ae9dbd454b20e","Tx has non-standard OP_RETURN output followed by opcodes"],
| [49291,"0000000018b07dca1b28b4b5a119f6d6e71698ce1ed96f143f54179ce177a19c","02000000abfaf47274223ca2fea22797e44498240e482cb4c2f2baea088962f800000000604b5b52c32305b15d7542071d8b04e750a547500005d4010727694b6e72a776e55d0d51ffff001d211806480201000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0d038bc0000102062f503253482fffffffff01a078072a01000000232102971dd6034ed0cf52450b608d196c07d6345184fcb14deb277a6b82d526a6163dac0000000001000000081cefd96060ecb1c4fbe675ad8a4f8bdc61d634c52b3a1c4116dee23749fe80ff000000009300493046022100866859c21f306538152e83f115bcfbf59ab4bb34887a88c03483a5dff9895f96022100a6dfd83caa609bf0516debc2bf65c3df91813a4842650a1858b3f61cfa8af249014730440220296d4b818bb037d0f83f9f7111665f49532dfdcbec1e6b784526e9ac4046eaa602204acf3a5cb2695e8404d80bf49ab04828bcbe6fc31d25a2844ced7a8d24afbdff01ffffffff1cefd96060ecb1c4fbe675ad8a4f8bdc61d634c52b3a1c4116dee23749fe80ff020000009400483045022100e87899175991aa008176cb553c6f2badbb5b741f328c9845fcab89f8b18cae2302200acce689896dc82933015e7230e5230d5cff8a1ffe82d334d60162ac2c5b0c9601493046022100994ad29d1e7b03e41731a4316e5f4992f0d9b6e2efc40a1ccd2c949b461175c502210099b69fdc2db00fbba214f16e286f6a49e2d8a0d5ffc6409d87796add475478d601ffffffff1e4a6d2d280ea06680d6cf8788ac90344a9c67cca9b06005bbd6d3f6945c8272010000009500493046022100a27400ba52fd842ce07398a1de102f710a10c5599545e6c95798934352c2e4df022100f6383b0b14c9f64b6718139f55b6b9494374755b86bae7d63f5d3e583b57255a01493046022100fdf543292f34e1eeb1703b264965339ec4a450ec47585009c606b3edbc5b617b022100a5fbb1c8de8aaaa582988cdb23622838e38de90bebcaab3928d949aa502a65d401ffffffff1e4a6d2d280ea06680d6cf8788ac90344a9c67cca9b06005bbd6d3f6945c8272020000009400493046022100ac626ac3051f875145b4fe4cfe089ea895aac73f65ab837b1ac30f5d875874fa022100bc03e79fa4b7eb707fb735b95ff6613ca33adeaf3a0607cdcead4cfd3b51729801483045022100b720b04a5c5e2f61b7df0fcf334ab6fea167b7aaede5695d3f7c6973496adbf1022043328c4cc1cdc3e5db7bb895ccc37133e960b2fd3ece98350f774596badb387201ffffffff23a8733e349c97d6cd90f520fdd084ba15ce0a395aad03cd51370602bb9e5db3010000004a00483045022100e8556b72c5e9c0da7371913a45861a61c5df434dfd962de7b23848e1a28c86ca02205d41ceda00136267281be0974be132ac4cda1459fe2090ce455619d8b91045e901ffffffff6856d609b881e875a5ee141c235e2a82f6b039f2b9babe82333677a5570285a6000000006a473044022040a1c631554b8b210fbdf2a73f191b2851afb51d5171fb53502a3a040a38d2c0022040d11cf6e7b41fe1b66c3d08f6ada1aee07a047cb77f242b8ecc63812c832c9a012102bcfad931b502761e452962a5976c79158a0f6d307ad31b739611dac6a297c256ffffffff6856d609b881e875a5ee141c235e2a82f6b039f2b9babe82333677a5570285a601000000930048304502205b109df098f7e932fbf71a45869c3f80323974a826ee2770789eae178a21bfc8022100c0e75615e53ee4b6e32b9bb5faa36ac539e9c05fa2ae6b6de5d09c08455c8b9601483045022009fb7d27375c47bea23b24818634df6a54ecf72d52e0c1268fb2a2c84f1885de022100e0ed4f15d62e7f537da0d0f1863498f9c7c0c0a4e00e4679588c8d1a9eb20bb801ffffffffa563c3722b7b39481836d5edfc1461f97335d5d1e9a23ade13680d0e2c1c371f030000006c493046022100ecc38ae2b1565643dc3c0dad5e961a5f0ea09cab28d024f92fa05c922924157e022100ebc166edf6fbe4004c72bfe8cf40130263f98ddff728c8e67b113dbd621906a601210211a4ed241174708c07206601b44a4c1c29e5ad8b1f731c50ca7e1d4b2a06dc1fffffffff02d0223a00000000001976a91445db0b779c0b9fa207f12a8218c94fc77aff504588ac80f0fa02000000000000000000",["5221033423007d8f263819a2e42becaaf5b06f34cb09919e06304349d950668209eaed21021d69e2b68c3960903b702af7829fadcd80bd89b158150c85c4a75b2c8cb9c39452ae","52210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179821021d69e2b68c3960903b702af7829fadcd80bd89b158150c85c4a75b2c8cb9c39452ae","522102a7ae1e0971fc1689bd66d2a7296da3a1662fd21a53c9e38979e0f090a375c12d21022adb62335f41eb4e27056ac37d462cda5ad783fa8e0e526ed79c752475db285d52ae","52210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179821022adb62335f41eb4e27056ac37d462cda5ad783fa8e0e526ed79c752475db285d52ae","512103b9d1d0e2b4355ec3cdef7c11a5c0beff9e8b8d8372ab4b4e0aaf30e80173001951ae","76a9149144761ebaccd5b4bbdc2a35453585b5637b2f8588ac","522103f1848b40621c5d48471d9784c8174ca060555891ace6d2b03c58eece946b1a9121020ee5d32b54d429c152fdc7b1db84f2074b0564d35400d89d11870f9273ec140c52ae","76a914f4fa1cc7de742d135ea82c17adf0bb9cf5f4fb8388ac"],"ed47705334f4643892ca46396eb3f4196a5e30880589e4009ef38eae895d4a13","0afbc2920af1b027f31f87b592276eb4c32094bb4d3697021b4c6380","b6d98692cec5145f67585f3434ec3c2b3030182e1cb3ec58b855c5c164dfaaa3","Tx pays to empty output script"],
| [180480,"00000000fd3ceb2404ff07a785c7fdcc76619edc8ed61bd25134eaa22084366a","020000006058aa080a655aa991a444bd7d1f2defd9a3bbe68aabb69030cf3b4e00000000d2e826bfd7ef0beaa891a7eedbc92cd6a544a6cb61c7bdaa436762eb2123ef9790f5f552ffff001d0002c90f0501000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0e0300c102024608062f503253482fffffffff01c0c6072a01000000232102e769e60137a4df6b0df8ebd387cca44c4c57ae74cc0114a8e8317c8f3bfd85e9ac00000000010000000381a0802911a01ffb025c4dea0bc77963e8c1bb46313b71164c53f72f37fe5248010000000151ffffffffc904b267833d215e2128bd9575242232ac2bc311550c7fc1f0ef6f264b40d14c010000000151ffffffffdf0915666649dba81886519c531649b7b02180b4af67d6885e871299e9d5f775000000000151ffffffff0180817dcb00000000232103bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4ac0000000001000000018da38b434fba82d66052af74fc5e4e94301b114d9bc03f819dc876398404c8b4010000006c493046022100fe738b7580dc5fb5168e51fc61b5aed211125eb71068031009a22d9bbad752c5022100be5086baa384d40bcab0fa586e4f728397388d86e18b66cc417dc4f7fa4f9878012103f233299455134caa2687bdf15cb0becdfb03bd0ff2ff38e65ec6b7834295c34fffffffff022ebc1400000000001976a9147779b7fba1c1e06b717069b80ca170e8b04458a488ac9879c40f000000001976a9142a0307cd925dbb66b534c4db33003dd18c57015788ac0000000001000000026139a62e3422a602de36c873a225c1d3ca5aeee598539ceecb9f0dc8d1ad0f83010000006b483045022100ad9f32b4a0a2ddc19b5a74eba78123e57616f1b3cfd72ce68c03ea35a3dda1f002200dbd22aa6da17213df5e70dfc3b2611d40f70c98ed9626aa5e2cde9d97461f0a012103ddb295d2f1e8319187738fb4b230fdd9aa29d0e01647f69f6d770b9ab24eea90ffffffff983c82c87cf020040d671956525014d5c2b28c6d948c85e1a522362c0059eeae010000006b4830450221009ca544274c786d30a5d5d25e17759201ea16d3aedddf0b9e9721246f7ef6b32e02202cfa5564b6e87dfd9fd98957820e4d4e6238baeb0f65fe305d91506bb13f5f4f012103c99113deac0d5d044e3ac0346abc02501542af8c8d3759f1382c72ff84e704f7ffffffff02c0c62d00000000001976a914ae19d27efe12f5a886dc79af37ad6805db6f922d88ac70ce2000000000001976a9143b8d051d37a07ea1042067e93efe63dbf73920b988ac000000000100000002be566e8cd9933f0c75c4a82c027f7d0c544d5c101d0607ef6ae5d07b98e7f1dc000000006b483045022036a8cdfd5ea7ebc06c2bfb6e4f942bbf9a1caeded41680d11a3a9f5d8284abad022100cacb92a5be3f39e8bc14db1710910ef7b395fa1e18f45d41c28d914fcdde33be012102bf59abf110b5131fae0a3ce1ec379329b4c896a6ae5d443edb68529cc2bc7816ffffffff96cf67645b76ceb23fe922874847456a15feee1655082ff32d25a6bf2c0dfc90000000006a47304402203471ca2001784a5ac0abab583581f2613523da47ec5f53df833c117b5abd81500220618a2847723d57324f2984678db556dbca1a72230fc7e39df04c2239942ba942012102925c9794fd7bb9f8b29e207d5fc491b1150135a21f505041858889fa4edf436fffffffff026c840f00000000001976a914797fb8777d7991d8284d88bfd421ce520f0f843188ac00ca9a3b000000001976a9146d10f3f592699265d10b106eda37c3ce793f7a8588ac00000000",["","","","76a9142903b138c24be9e070b3e73ec495d77a204615e788ac","76a91433a1941fd9a37b9821d376f5a51bd4b52fa50e2888ac","76a914e4374e8155d0865742ca12b8d4d14d41b57d682f88ac","76a914001fa7459a6cfc64bdc178ba7e7a21603bb2568f88ac","76a914f6039952bc2b307aeec5371bfb96b66078ec17f688ac"],"d34ef98386f413769502808d4bac5f20f8dfd5bffc9eedafaa71de0eb1f01489","0db414c859a07e8205876354a210a75042d0463404913d61a8e068e58a3ae2aa080026","c582d51c0ca365e3fcf36c51cb646d7f83a67e867cb4743fd2128e3e022b700c","Tx spends from empty output script"],
| [926485,"000000000000015d6077a411a8f5cc95caf775ccf11c54e27df75ce58d187313","0000002060bbab0edbf3ef8a49608ee326f8fd75c473b7e3982095e2d100000000000000c30134f8c9b6d2470488d7a67a888f6fa12f8692e0c3411fbfb92f0f68f67eedae03ca57ef13021acc22dc4105010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff2f0315230e0004ae03ca57043e3d1e1d0c8796bf579aef0c0000000000122f4e696e6a61506f6f6c2f5345475749542fffffffff038427a112000000001976a914876fbb82ec05caa6af7a3b5e5a983aae6c6cc6d688ac0000000000000000266a24aa21a9ed5c748e121c0fe146d973a4ac26fa4a68b0549d46ee22d25f50a5e46fe1b377ee00000000000000002952534b424c4f434b3acd16772ad61a3c5f00287480b720f6035d5e54c9efc71be94bb5e3727f10909001200000000000000000000000000000000000000000000000000000000000000000000000000100000000010145310e878941a1b2bc2d33797ee4d89d95eaaf2e13488063a2aa9a74490f510a0100000023220020b6744de4f6ec63cc92f7c220cdefeeb1b1bed2b66c8e5706d80ec247d37e65a1ffffffff01002d3101000000001976a9143ebc40e411ed3c76f86711507ab952300890397288ac0400473044022001dd489a5d4e2fbd8a3ade27177f6b49296ba7695c40dbbe650ea83f106415fd02200b23a0602d8ff1bdf79dee118205fc7e9b40672bf31563e5741feb53fb86388501483045022100f88f040e90cc5dc6c6189d04718376ac19ed996bf9e4a3c29c3718d90ffd27180220761711f16c9e3a44f71aab55cbc0634907a1fa8bb635d971a9a01d368727bea10169522103b3623117e988b76aaabe3d63f56a4fc88b228a71e64c4cc551d1204822fe85cb2103dd823066e096f72ed617a41d3ca56717db335b1ea47a1b4c5c9dbdd0963acba621033d7c89bd9da29fa8d44db7906a9778b53121f72191184a9fee785c39180e4be153ae00000000010000000120925534261de4dcebb1ed5ab1b62bfe7a3ef968fb111dc2c910adfebc6e3bdf010000006b483045022100f50198f5ae66211a4f485190abe4dc7accdabe3bc214ebc9ea7069b97097d46e0220316a70a03014887086e335fc1b48358d46cd6bdc9af3b57c109c94af76fc915101210316cff587a01a2736d5e12e53551b18d73780b83c3bfb4fcf209c869b11b6415effffffff0220a10700000000001976a91450333046115eaa0ac9e0216565f945070e44573988ac2e7cd01a000000001976a914c01a7ca16b47be50cbdbc60724f701d52d75156688ac00000000010000000203a25f58630d7a1ea52550365fd2156683f56daf6ca73a4b4bbd097e66516322010000006a47304402204efc3d70e4ca3049c2a425025edf22d5ca355f9ec899dbfbbeeb2268533a0f2b02204780d3739653035af4814ea52e1396d021953f948c29754edd0ee537364603dc012103f7a897e4dbecab2264b21917f90664ea8256189ea725d28740cf7ba5d85b5763ffffffff03a25f58630d7a1ea52550365fd2156683f56daf6ca73a4b4bbd097e66516322000000006a47304402202d96defdc5b4af71d6ba28c9a6042c2d5ee7bc6de565d4db84ef517445626e03022022da80320e9e489c8f41b74833dfb6a54a4eb5087cdb46eb663eef0b25caa526012103f7a897e4dbecab2264b21917f90664ea8256189ea725d28740cf7ba5d85b5763ffffffff0200e1f5050000000017a914b7e6f7ff8658b2d1fb107e3d7be7af4742e6b1b3876f88fc00000000001976a914913bcc2be49cb534c20474c4dee1e9c4c317e7eb88ac0000000001000000043ffd60d3818431c495b89be84afac205d5d1ed663009291c560758bbd0a66df5010000006b483045022100f344607de9df42049688dcae8ff1db34c0c7cd25ec05516e30d2bc8f12ac9b2f022060b648f6a21745ea6d9782e17bcc4277b5808326488a1f40d41e125879723d3a012103f7a897e4dbecab2264b21917f90664ea8256189ea725d28740cf7ba5d85b5763ffffffffa5379401cce30f84731ef1ba65ce27edf2cc7ce57704507ebe8714aa16a96b92010000006a473044022020c37a63bf4d7f564c2192528709b6a38ab8271bd96898c6c2e335e5208661580220435c6f1ad4d9305d2c0a818b2feb5e45d443f2f162c0f61953a14d097fd07064012103f7a897e4dbecab2264b21917f90664ea8256189ea725d28740cf7ba5d85b5763ffffffff70e731e193235ff12c3184510895731a099112ffca4b00246c60003c40f843ce000000006a473044022053760f74c29a879e30a17b5f03a5bb057a5751a39f86fa6ecdedc36a1b7db04c022041d41c9b95f00d2d10a0373322a9025dba66c942196bc9d8adeb0e12d3024728012103f7a897e4dbecab2264b21917f90664ea8256189ea725d28740cf7ba5d85b5763ffffffff66b7a71b3e50379c8e85fc18fe3f1a408fc985f257036c34702ba205cef09f6f000000006a4730440220499bf9e2db3db6e930228d0661395f65431acae466634d098612fd80b08459ee022040e069fc9e3c60009f521cef54c38aadbd1251aee37940e6018aadb10f194d6a012103f7a897e4dbecab2264b21917f90664ea8256189ea725d28740cf7ba5d85b5763ffffffff0200e1f5050000000017a9148fc37ad460fdfbd2b44fe446f6e3071a4f64faa6878f447f0b000000001976a914913bcc2be49cb534c20474c4dee1e9c4c317e7eb88ac00000000",["a914feb8a29635c56d9cd913122f90678756bf23887687","76a914c01a7ca16b47be50cbdbc60724f701d52d75156688ac","76a914913bcc2be49cb534c20474c4dee1e9c4c317e7eb88ac","76a914913bcc2be49cb534c20474c4dee1e9c4c317e7eb88ac","76a914913bcc2be49cb534c20474c4dee1e9c4c317e7eb88ac","76a914913bcc2be49cb534c20474c4dee1e9c4c317e7eb88ac","76a914913bcc2be49cb534c20474c4dee1e9c4c317e7eb88ac","76a914913bcc2be49cb534c20474c4dee1e9c4c317e7eb88ac"],"8f13b9a9c85611635b47906c3053ac53cfcec7211455d4cb0d63dc9acc13d472","09027acea61b6cc3fb33f5d52f7d088a6b2f75d234e89ca800","546c574a0472144bcaf9b6aeabf26372ad87c7af7d1ee0dbfae5e099abeae49c","Duplicate pushdata 913bcc2be49cb534c20474c4dee1e9c4c317e7eb"],
| [987876,"0000000000000c00901f2049055e2a437c819d79a3d54fd63e6af796cd7b8a79","000000202694f74969fdb542090e95a56bc8aa2d646e27033850e32f1c5f000000000000f7e53676b3f12d5beb524ed617f2d25f5a93b5f4f52c1ba2678260d72712f8dd0a6dfe5740257e1a4b1768960101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1603e4120ff9c30a1c216900002f424d4920546573742fffffff0001205fa012000000001e76a914c486de584a735ec2f22da7cd9681614681f92173d83d0aa68688ac00000000",[],"fe4d230dbb0f4fec9bed23a5283e08baf996e3f32b93f52c7de1f641ddfd04ad","010c0b40","0965a544743bbfa36f254446e75630c09404b3d164a261892372977538928ed5","Coinbase tx has unparseable output script"],
| [1263442,"000000006f27ddfe1dd680044a34548f41bed47eba9e6f0b310da21423bc5f33","000000201c8d1a529c39a396db2db234d5ec152fa651a2872966daccbde028b400000000083f14492679151dbfaa1a825ef4c18518e780c1f91044180280a7d33f4a98ff5f45765aaddc001d38333b9a02010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff230352471300fe5f45765afe94690a000963676d696e6572343208000000000000000000ffffffff024423a804000000001976a914f2c25ac3d59f3d674b1d1d0a25c27339aaac0ba688ac0000000000000000266a24aa21a9edcb26cb3052426b9ebb4d19c819ef87c19677bbf3a7c46ef0855bd1b2abe83491012000000000000000000000000000000000000000000000000000000000000000000000000002000000000101d20978463906ba4ff5e7192494b88dd5eb0de85d900ab253af909106faa22cc5010000000004000000014777ff000000000016001446c29eabe8208a33aa1023c741fa79aa92e881ff0347304402207d7ca96134f2bcfdd6b536536fdd39ad17793632016936f777ebb32c22943fda02206014d2fb8a6aa58279797f861042ba604ebd2f8f61e5bddbd9d3be5a245047b201004b632103eeaeba7ce5dc2470221e9517fb498e8d6bd4e73b85b8be655196972eb9ccd5566754b2752103a40b74d43df244799d041f32ce1ad515a6cd99501701540e38750d883ae21d3a68ac00000000",["002027a5000c7917f785d8fc6e5a55adfca8717ecb973ebb7743849ff956d896a7ed"],"31d66d516a9eda7de865df29f6ef6cb8e4bf9309e5dac899968a9a62a5df61e3","0385acb4f0fe889ef0","4e6d564c2a2452065c205dd7eb2791124e0c4e0dbb064c410c24968572589dec","Includes witness data"],
| [1414221,"0000000000000027b2b3b3381f114f674f481544ff2be37ae3788d7e078383b1","000000204ea88307a7959d8207968f152bedca5a93aefab253f1fb2cfb032a400000000070cebb14ec6dbc27a9dfd066d9849a4d3bac5f674665f73a5fe1de01a022a0c851fda85bf05f4c19a779d1450102000000010000000000000000000000000000000000000000000000000000000000000000ffffffff18034d94154d696e6572476174653030310d000000f238f401ffffffff01c817a804000000000000000000",[],"5e5e12d90693c8e936f01847859404c67482439681928353ca1296982042864e","00","021e8882ef5a0ed932edeebbecfeda1d7ce528ec7b3daa27641acf1189d7b5dc","Empty data"]
|]""".stripMargin
}

View File

@ -27,12 +27,7 @@ class BigSizeUIntTest extends BitcoinSUnitTest {
}
it must "pass encoding tests" in {
val bufferedSource =
io.Source.fromURL(getClass.getResource("/bigsize_encoding.json"))
try {
val builder = new StringBuilder
bufferedSource.getLines().foreach(builder.append)
val tests = ujson.read(builder.result()).arr.toVector
val tests = ujson.read(BigSizeJsonTestVectors.encode).arr.toVector
tests.foreach { test =>
val obj = test.obj
val name = obj("name").str
@ -40,18 +35,10 @@ class BigSizeUIntTest extends BitcoinSUnitTest {
val bytes = ByteVector.fromValidHex(obj("bytes").str)
assert(BigSizeUInt(num).bytes == bytes, name)
}
} finally {
bufferedSource.close()
}
}
it must "pass decoding tests" in {
val bufferedSource =
io.Source.fromURL(getClass.getResource("/bigsize_decoding.json"))
try {
val builder = new StringBuilder
bufferedSource.getLines().foreach(builder.append)
val tests = ujson.read(builder.result()).arr.toVector
val tests = ujson.read(BigSizeJsonTestVectors.decode).arr.toVector
tests.foreach { test =>
val obj = test.obj
val name = obj("name").str
@ -70,8 +57,153 @@ class BigSizeUIntTest extends BitcoinSUnitTest {
}
}
}
} finally {
bufferedSource.close()
}
}
object BigSizeJsonTestVectors {
val encode: String = """[
| {
| "name": "zero",
| "value": "0",
| "bytes": "00"
| },
| {
| "name": "one byte high",
| "value": "252",
| "bytes": "fc"
| },
| {
| "name": "two byte low",
| "value": "253",
| "bytes": "fd00fd"
| },
| {
| "name": "two byte high",
| "value": "65535",
| "bytes": "fdffff"
| },
| {
| "name": "four byte low",
| "value": "65536",
| "bytes": "fe00010000"
| },
| {
| "name": "four byte high",
| "value": "4294967295",
| "bytes": "feffffffff"
| },
| {
| "name": "eight byte low",
| "value": "4294967296",
| "bytes": "ff0000000100000000"
| },
| {
| "name": "eight byte high",
| "value": "18446744073709551615",
| "bytes": "ffffffffffffffffff"
| }
|]""".stripMargin
val decode: String = """[
| {
| "name": "zero",
| "value": "0",
| "bytes": "00"
| },
| {
| "name": "one byte high",
| "value": "252",
| "bytes": "fc"
| },
| {
| "name": "two byte low",
| "value": "253",
| "bytes": "fd00fd"
| },
| {
| "name": "two byte high",
| "value": "65535",
| "bytes": "fdffff"
| },
| {
| "name": "four byte low",
| "value": "65536",
| "bytes": "fe00010000"
| },
| {
| "name": "four byte high",
| "value": "4294967295",
| "bytes": "feffffffff"
| },
| {
| "name": "eight byte low",
| "value": "4294967296",
| "bytes": "ff0000000100000000"
| },
| {
| "name": "eight byte high",
| "value": "18446744073709551615",
| "bytes": "ffffffffffffffffff"
| },
| {
| "name": "two byte not canonical",
| "value": "",
| "bytes": "fd00fc",
| "exp_error": "decoded bigsize is not canonical"
| },
| {
| "name": "four byte not canonical",
| "value": "",
| "bytes": "fe0000ffff",
| "exp_error": "decoded bigsize is not canonical"
| },
| {
| "name": "eight byte not canonical",
| "value": "",
| "bytes": "ff00000000ffffffff",
| "exp_error": "decoded bigsize is not canonical"
| },
| {
| "name": "two byte short read",
| "value": "",
| "bytes": "fd00",
| "exp_error": "unexpected EOF"
| },
| {
| "name": "four byte short read",
| "value": "",
| "bytes": "feffff",
| "exp_error": "unexpected EOF"
| },
| {
| "name": "eight byte short read",
| "value": "",
| "bytes": "ffffffffff",
| "exp_error": "unexpected EOF"
| },
| {
| "name": "one byte no read",
| "value": "",
| "bytes": "",
| "exp_error": "EOF"
| },
| {
| "name": "two byte no read",
| "value": "",
| "bytes": "fd",
| "exp_error": "unexpected EOF"
| },
| {
| "name": "four byte no read",
| "value": "",
| "bytes": "fe",
| "exp_error": "unexpected EOF"
| },
| {
| "name": "eight byte no read",
| "value": "",
| "bytes": "ff",
| "exp_error": "unexpected EOF"
| }
|]""".stripMargin
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4,8 +4,6 @@ import org.bitcoins.core.util.testprotocol._
import org.bitcoins.testkitcore.util.BitcoinSUnitTest
import spray.json._
import scala.io.Source
/** Created by tom on 5/17/16.
*/
class Base58Test extends BitcoinSUnitTest {
@ -64,12 +62,7 @@ class Base58Test extends BitcoinSUnitTest {
it must "read base58_keys_valid.json and validate each case" in {
import org.bitcoins.core.util.testprotocol.Base58ValidTestCaseProtocol._
val source =
Source.fromURL(this.getClass.getResource("/base58_keys_valid.json"))
val lines =
try source.getLines().filterNot(_.isEmpty).map(_.trim) mkString "\n"
finally source.close()
val json = lines.parseJson
val json = Base58EncodingTestVectors.valid.parseJson
val testCases: Seq[Base58ValidTestCase] =
json.convertTo[Seq[Base58ValidTestCase]]
for {
@ -90,13 +83,7 @@ class Base58Test extends BitcoinSUnitTest {
it must "read base58_keys_invalid.json and return each as an invalid base58 string" in {
import org.bitcoins.core.util.testprotocol.Base58InvalidTestCase
import org.bitcoins.core.util.testprotocol.Base58InvalidTestCaseProtocol._
val source =
Source.fromURL(this.getClass.getResource("/base58_keys_invalid.json"))
val lines =
try source.getLines().filterNot(_.isEmpty).map(_.trim) mkString "\n"
finally source.close()
val json = lines.parseJson
val json = Base58EncodingTestVectors.invalid.parseJson
val testCases: Seq[Base58InvalidTestCase] =
json.convertTo[Seq[Base58InvalidTestCase]]
for {
@ -119,3 +106,616 @@ class Base58Test extends BitcoinSUnitTest {
true)
}
}
object Base58EncodingTestVectors {
val valid: String =
"""[
| [
| "1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i",
| "65a16059864a2fdbc7c99a4723a8395bc6f188eb",
| {
| "addrType": "pubkey",
| "isPrivkey": false,
| "isTestnet": false
| }
| ],
| [
| "3CMNFxN1oHBc4R1EpboAL5yzHGgE611Xou",
| "74f209f6ea907e2ea48f74fae05782ae8a665257",
| {
| "addrType": "script",
| "isPrivkey": false,
| "isTestnet": false
| }
| ],
| [
| "mo9ncXisMeAoXwqcV5EWuyncbmCcQN4rVs",
| "53c0307d6851aa0ce7825ba883c6bd9ad242b486",
| {
| "addrType": "pubkey",
| "isPrivkey": false,
| "isTestnet": true
| }
| ],
| [
| "2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br",
| "6349a418fc4578d10a372b54b45c280cc8c4382f",
| {
| "addrType": "script",
| "isPrivkey": false,
| "isTestnet": true
| }
| ],
| [
| "5Kd3NBUAdUnhyzenEwVLy9pBKxSwXvE9FMPyR4UKZvpe6E3AgLr",
| "eddbdc1168f1daeadbd3e44c1e3f8f5a284c2029f78ad26af98583a499de5b19",
| {
| "isCompressed": false,
| "isPrivkey": true,
| "isTestnet": false
| }
| ],
| [
| "Kz6UJmQACJmLtaQj5A3JAge4kVTNQ8gbvXuwbmCj7bsaabudb3RD",
| "55c9bccb9ed68446d1b75273bbce89d7fe013a8acd1625514420fb2aca1a21c4",
| {
| "isCompressed": true,
| "isPrivkey": true,
| "isTestnet": false
| }
| ],
| [
| "9213qJab2HNEpMpYNBa7wHGFKKbkDn24jpANDs2huN3yi4J11ko",
| "36cb93b9ab1bdabf7fb9f2c04f1b9cc879933530ae7842398eef5a63a56800c2",
| {
| "isCompressed": false,
| "isPrivkey": true,
| "isTestnet": true
| }
| ],
| [
| "cTpB4YiyKiBcPxnefsDpbnDxFDffjqJob8wGCEDXxgQ7zQoMXJdH",
| "b9f4892c9e8282028fea1d2667c4dc5213564d41fc5783896a0d843fc15089f3",
| {
| "isCompressed": true,
| "isPrivkey": true,
| "isTestnet": true
| }
| ],
| [
| "1Ax4gZtb7gAit2TivwejZHYtNNLT18PUXJ",
| "6d23156cbbdcc82a5a47eee4c2c7c583c18b6bf4",
| {
| "addrType": "pubkey",
| "isPrivkey": false,
| "isTestnet": false
| }
| ],
| [
| "3QjYXhTkvuj8qPaXHTTWb5wjXhdsLAAWVy",
| "fcc5460dd6e2487c7d75b1963625da0e8f4c5975",
| {
| "addrType": "script",
| "isPrivkey": false,
| "isTestnet": false
| }
| ],
| [
| "n3ZddxzLvAY9o7184TB4c6FJasAybsw4HZ",
| "f1d470f9b02370fdec2e6b708b08ac431bf7a5f7",
| {
| "addrType": "pubkey",
| "isPrivkey": false,
| "isTestnet": true
| }
| ],
| [
| "2NBFNJTktNa7GZusGbDbGKRZTxdK9VVez3n",
| "c579342c2c4c9220205e2cdc285617040c924a0a",
| {
| "addrType": "script",
| "isPrivkey": false,
| "isTestnet": true
| }
| ],
| [
| "5K494XZwps2bGyeL71pWid4noiSNA2cfCibrvRWqcHSptoFn7rc",
| "a326b95ebae30164217d7a7f57d72ab2b54e3be64928a19da0210b9568d4015e",
| {
| "isCompressed": false,
| "isPrivkey": true,
| "isTestnet": false
| }
| ],
| [
| "L1RrrnXkcKut5DEMwtDthjwRcTTwED36thyL1DebVrKuwvohjMNi",
| "7d998b45c219a1e38e99e7cbd312ef67f77a455a9b50c730c27f02c6f730dfb4",
| {
| "isCompressed": true,
| "isPrivkey": true,
| "isTestnet": false
| }
| ],
| [
| "93DVKyFYwSN6wEo3E2fCrFPUp17FtrtNi2Lf7n4G3garFb16CRj",
| "d6bca256b5abc5602ec2e1c121a08b0da2556587430bcf7e1898af2224885203",
| {
| "isCompressed": false,
| "isPrivkey": true,
| "isTestnet": true
| }
| ],
| [
| "cTDVKtMGVYWTHCb1AFjmVbEbWjvKpKqKgMaR3QJxToMSQAhmCeTN",
| "a81ca4e8f90181ec4b61b6a7eb998af17b2cb04de8a03b504b9e34c4c61db7d9",
| {
| "isCompressed": true,
| "isPrivkey": true,
| "isTestnet": true
| }
| ],
| [
| "1C5bSj1iEGUgSTbziymG7Cn18ENQuT36vv",
| "7987ccaa53d02c8873487ef919677cd3db7a6912",
| {
| "addrType": "pubkey",
| "isPrivkey": false,
| "isTestnet": false
| }
| ],
| [
| "3AnNxabYGoTxYiTEZwFEnerUoeFXK2Zoks",
| "63bcc565f9e68ee0189dd5cc67f1b0e5f02f45cb",
| {
| "addrType": "script",
| "isPrivkey": false,
| "isTestnet": false
| }
| ],
| [
| "n3LnJXCqbPjghuVs8ph9CYsAe4Sh4j97wk",
| "ef66444b5b17f14e8fae6e7e19b045a78c54fd79",
| {
| "addrType": "pubkey",
| "isPrivkey": false,
| "isTestnet": true
| }
| ],
| [
| "2NB72XtkjpnATMggui83aEtPawyyKvnbX2o",
| "c3e55fceceaa4391ed2a9677f4a4d34eacd021a0",
| {
| "addrType": "script",
| "isPrivkey": false,
| "isTestnet": true
| }
| ],
| [
| "5KaBW9vNtWNhc3ZEDyNCiXLPdVPHCikRxSBWwV9NrpLLa4LsXi9",
| "e75d936d56377f432f404aabb406601f892fd49da90eb6ac558a733c93b47252",
| {
| "isCompressed": false,
| "isPrivkey": true,
| "isTestnet": false
| }
| ],
| [
| "L1axzbSyynNYA8mCAhzxkipKkfHtAXYF4YQnhSKcLV8YXA874fgT",
| "8248bd0375f2f75d7e274ae544fb920f51784480866b102384190b1addfbaa5c",
| {
| "isCompressed": true,
| "isPrivkey": true,
| "isTestnet": false
| }
| ],
| [
| "927CnUkUbasYtDwYwVn2j8GdTuACNnKkjZ1rpZd2yBB1CLcnXpo",
| "44c4f6a096eac5238291a94cc24c01e3b19b8d8cef72874a079e00a242237a52",
| {
| "isCompressed": false,
| "isPrivkey": true,
| "isTestnet": true
| }
| ],
| [
| "cUcfCMRjiQf85YMzzQEk9d1s5A4K7xL5SmBCLrezqXFuTVefyhY7",
| "d1de707020a9059d6d3abaf85e17967c6555151143db13dbb06db78df0f15c69",
| {
| "isCompressed": true,
| "isPrivkey": true,
| "isTestnet": true
| }
| ],
| [
| "1Gqk4Tv79P91Cc1STQtU3s1W6277M2CVWu",
| "adc1cc2081a27206fae25792f28bbc55b831549d",
| {
| "addrType": "pubkey",
| "isPrivkey": false,
| "isTestnet": false
| }
| ],
| [
| "33vt8ViH5jsr115AGkW6cEmEz9MpvJSwDk",
| "188f91a931947eddd7432d6e614387e32b244709",
| {
| "addrType": "script",
| "isPrivkey": false,
| "isTestnet": false
| }
| ],
| [
| "mhaMcBxNh5cqXm4aTQ6EcVbKtfL6LGyK2H",
| "1694f5bc1a7295b600f40018a618a6ea48eeb498",
| {
| "addrType": "pubkey",
| "isPrivkey": false,
| "isTestnet": true
| }
| ],
| [
| "2MxgPqX1iThW3oZVk9KoFcE5M4JpiETssVN",
| "3b9b3fd7a50d4f08d1a5b0f62f644fa7115ae2f3",
| {
| "addrType": "script",
| "isPrivkey": false,
| "isTestnet": true
| }
| ],
| [
| "5HtH6GdcwCJA4ggWEL1B3jzBBUB8HPiBi9SBc5h9i4Wk4PSeApR",
| "091035445ef105fa1bb125eccfb1882f3fe69592265956ade751fd095033d8d0",
| {
| "isCompressed": false,
| "isPrivkey": true,
| "isTestnet": false
| }
| ],
| [
| "L2xSYmMeVo3Zek3ZTsv9xUrXVAmrWxJ8Ua4cw8pkfbQhcEFhkXT8",
| "ab2b4bcdfc91d34dee0ae2a8c6b6668dadaeb3a88b9859743156f462325187af",
| {
| "isCompressed": true,
| "isPrivkey": true,
| "isTestnet": false
| }
| ],
| [
| "92xFEve1Z9N8Z641KQQS7ByCSb8kGjsDzw6fAmjHN1LZGKQXyMq",
| "b4204389cef18bbe2b353623cbf93e8678fbc92a475b664ae98ed594e6cf0856",
| {
| "isCompressed": false,
| "isPrivkey": true,
| "isTestnet": true
| }
| ],
| [
| "cVM65tdYu1YK37tNoAyGoJTR13VBYFva1vg9FLuPAsJijGvG6NEA",
| "e7b230133f1b5489843260236b06edca25f66adb1be455fbd38d4010d48faeef",
| {
| "isCompressed": true,
| "isPrivkey": true,
| "isTestnet": true
| }
| ],
| [
| "1JwMWBVLtiqtscbaRHai4pqHokhFCbtoB4",
| "c4c1b72491ede1eedaca00618407ee0b772cad0d",
| {
| "addrType": "pubkey",
| "isPrivkey": false,
| "isTestnet": false
| }
| ],
| [
| "3QCzvfL4ZRvmJFiWWBVwxfdaNBT8EtxB5y",
| "f6fe69bcb548a829cce4c57bf6fff8af3a5981f9",
| {
| "addrType": "script",
| "isPrivkey": false,
| "isTestnet": false
| }
| ],
| [
| "mizXiucXRCsEriQCHUkCqef9ph9qtPbZZ6",
| "261f83568a098a8638844bd7aeca039d5f2352c0",
| {
| "addrType": "pubkey",
| "isPrivkey": false,
| "isTestnet": true
| }
| ],
| [
| "2NEWDzHWwY5ZZp8CQWbB7ouNMLqCia6YRda",
| "e930e1834a4d234702773951d627cce82fbb5d2e",
| {
| "addrType": "script",
| "isPrivkey": false,
| "isTestnet": true
| }
| ],
| [
| "5KQmDryMNDcisTzRp3zEq9e4awRmJrEVU1j5vFRTKpRNYPqYrMg",
| "d1fab7ab7385ad26872237f1eb9789aa25cc986bacc695e07ac571d6cdac8bc0",
| {
| "isCompressed": false,
| "isPrivkey": true,
| "isTestnet": false
| }
| ],
| [
| "L39Fy7AC2Hhj95gh3Yb2AU5YHh1mQSAHgpNixvm27poizcJyLtUi",
| "b0bbede33ef254e8376aceb1510253fc3550efd0fcf84dcd0c9998b288f166b3",
| {
| "isCompressed": true,
| "isPrivkey": true,
| "isTestnet": false
| }
| ],
| [
| "91cTVUcgydqyZLgaANpf1fvL55FH53QMm4BsnCADVNYuWuqdVys",
| "037f4192c630f399d9271e26c575269b1d15be553ea1a7217f0cb8513cef41cb",
| {
| "isCompressed": false,
| "isPrivkey": true,
| "isTestnet": true
| }
| ],
| [
| "cQspfSzsgLeiJGB2u8vrAiWpCU4MxUT6JseWo2SjXy4Qbzn2fwDw",
| "6251e205e8ad508bab5596bee086ef16cd4b239e0cc0c5d7c4e6035441e7d5de",
| {
| "isCompressed": true,
| "isPrivkey": true,
| "isTestnet": true
| }
| ],
| [
| "19dcawoKcZdQz365WpXWMhX6QCUpR9SY4r",
| "5eadaf9bb7121f0f192561a5a62f5e5f54210292",
| {
| "addrType": "pubkey",
| "isPrivkey": false,
| "isTestnet": false
| }
| ],
| [
| "37Sp6Rv3y4kVd1nQ1JV5pfqXccHNyZm1x3",
| "3f210e7277c899c3a155cc1c90f4106cbddeec6e",
| {
| "addrType": "script",
| "isPrivkey": false,
| "isTestnet": false
| }
| ],
| [
| "myoqcgYiehufrsnnkqdqbp69dddVDMopJu",
| "c8a3c2a09a298592c3e180f02487cd91ba3400b5",
| {
| "addrType": "pubkey",
| "isPrivkey": false,
| "isTestnet": true
| }
| ],
| [
| "2N7FuwuUuoTBrDFdrAZ9KxBmtqMLxce9i1C",
| "99b31df7c9068d1481b596578ddbb4d3bd90baeb",
| {
| "addrType": "script",
| "isPrivkey": false,
| "isTestnet": true
| }
| ],
| [
| "5KL6zEaMtPRXZKo1bbMq7JDjjo1bJuQcsgL33je3oY8uSJCR5b4",
| "c7666842503db6dc6ea061f092cfb9c388448629a6fe868d068c42a488b478ae",
| {
| "isCompressed": false,
| "isPrivkey": true,
| "isTestnet": false
| }
| ],
| [
| "KwV9KAfwbwt51veZWNscRTeZs9CKpojyu1MsPnaKTF5kz69H1UN2",
| "07f0803fc5399e773555ab1e8939907e9badacc17ca129e67a2f5f2ff84351dd",
| {
| "isCompressed": true,
| "isPrivkey": true,
| "isTestnet": false
| }
| ],
| [
| "93N87D6uxSBzwXvpokpzg8FFmfQPmvX4xHoWQe3pLdYpbiwT5YV",
| "ea577acfb5d1d14d3b7b195c321566f12f87d2b77ea3a53f68df7ebf8604a801",
| {
| "isCompressed": false,
| "isPrivkey": true,
| "isTestnet": true
| }
| ],
| [
| "cMxXusSihaX58wpJ3tNuuUcZEQGt6DKJ1wEpxys88FFaQCYjku9h",
| "0b3b34f0958d8a268193a9814da92c3e8b58b4a4378a542863e34ac289cd830c",
| {
| "isCompressed": true,
| "isPrivkey": true,
| "isTestnet": true
| }
| ],
| [
| "13p1ijLwsnrcuyqcTvJXkq2ASdXqcnEBLE",
| "1ed467017f043e91ed4c44b4e8dd674db211c4e6",
| {
| "addrType": "pubkey",
| "isPrivkey": false,
| "isTestnet": false
| }
| ],
| [
| "3ALJH9Y951VCGcVZYAdpA3KchoP9McEj1G",
| "5ece0cadddc415b1980f001785947120acdb36fc",
| {
| "addrType": "script",
| "isPrivkey": false,
| "isTestnet": false
| }
| ]
|]
|""".stripMargin
val invalid: String =
"""[
| [
| ""
| ],
| [
| "x"
| ],
| [
| "37qgekLpCCHrQuSjvX3fs496FWTGsHFHizjJAs6NPcR47aefnnCWECAhHV6E3g4YN7u7Yuwod5Y"
| ],
| [
| "dzb7VV1Ui55BARxv7ATxAtCUeJsANKovDGWFVgpTbhq9gvPqP3yv"
| ],
| [
| "MuNu7ZAEDFiHthiunm7dPjwKqrVNCM3mAz6rP9zFveQu14YA8CxExSJTHcVP9DErn6u84E6Ej7S"
| ],
| [
| "rPpQpYknyNQ5AEHuY6H8ijJJrYc2nDKKk9jjmKEXsWzyAQcFGpDLU2Zvsmoi8JLR7hAwoy3RQWf"
| ],
| [
| "4Uc3FmN6NQ6zLBK5QQBXRBUREaaHwCZYsGCueHauuDmJpZKn6jkEskMB2Zi2CNgtb5r6epWEFfUJq"
| ],
| [
| "7aQgR5DFQ25vyXmqZAWmnVCjL3PkBcdVkBUpjrjMTcghHx3E8wb"
| ],
| [
| "17QpPprjeg69fW1DV8DcYYCKvWjYhXvWkov6MJ1iTTvMFj6weAqW7wybZeH57WTNxXVCRH4veVs"
| ],
| [
| "KxuACDviz8Xvpn1xAh9MfopySZNuyajYMZWz16Dv2mHHryznWUp3"
| ],
| [
| "7nK3GSmqdXJQtdohvGfJ7KsSmn3TmGqExug49583bDAL91pVSGq5xS9SHoAYL3Wv3ijKTit65th"
| ],
| [
| "cTivdBmq7bay3RFGEBBuNfMh2P1pDCgRYN2Wbxmgwr4ki3jNUL2va"
| ],
| [
| "gjMV4vjNjyMrna4fsAr8bWxAbwtmMUBXJS3zL4NJt5qjozpbQLmAfK1uA3CquSqsZQMpoD1g2nk"
| ],
| [
| "emXm1naBMoVzPjbk7xpeTVMFy4oDEe25UmoyGgKEB1gGWsK8kRGs"
| ],
| [
| "7VThQnNRj1o3Zyvc7XHPRrjDf8j2oivPTeDXnRPYWeYGE4pXeRJDZgf28ppti5hsHWXS2GSobdqyo"
| ],
| [
| "1G9u6oCVCPh2o8m3t55ACiYvG1y5BHewUkDSdiQarDcYXXhFHYdzMdYfUAhfxn5vNZBwpgUNpso"
| ],
| [
| "31QQ7ZMLkScDiB4VyZjuptr7AEc9j1SjstF7pRoLhHTGkW4Q2y9XELobQmhhWxeRvqcukGd1XCq"
| ],
| [
| "DHqKSnpxa8ZdQyH8keAhvLTrfkyBMQxqngcQA5N8LQ9KVt25kmGN"
| ],
| [
| "2LUHcJPbwLCy9GLH1qXmfmAwvadWw4bp4PCpDfduLqV17s6iDcy1imUwhQJhAoNoN1XNmweiJP4i"
| ],
| [
| "7USRzBXAnmck8fX9HmW7RAb4qt92VFX6soCnts9s74wxm4gguVhtG5of8fZGbNPJA83irHVY6bCos"
| ],
| [
| "1DGezo7BfVebZxAbNT3XGujdeHyNNBF3vnficYoTSp4PfK2QaML9bHzAMxke3wdKdHYWmsMTJVu"
| ],
| [
| "2D12DqDZKwCxxkzs1ZATJWvgJGhQ4cFi3WrizQ5zLAyhN5HxuAJ1yMYaJp8GuYsTLLxTAz6otCfb"
| ],
| [
| "8AFJzuTujXjw1Z6M3fWhQ1ujDW7zsV4ePeVjVo7D1egERqSW9nZ"
| ],
| [
| "163Q17qLbTCue8YY3AvjpUhotuaodLm2uqMhpYirsKjVqnxJRWTEoywMVY3NbBAHuhAJ2cF9GAZ"
| ],
| [
| "2MnmgiRH4eGLyLc9eAqStzk7dFgBjFtUCtu"
| ],
| [
| "461QQ2sYWxU7H2PV4oBwJGNch8XVTYYbZxU"
| ],
| [
| "2UCtv53VttmQYkVU4VMtXB31REvQg4ABzs41AEKZ8UcB7DAfVzdkV9JDErwGwyj5AUHLkmgZeobs"
| ],
| [
| "cSNjAsnhgtiFMi6MtfvgscMB2Cbhn2v1FUYfviJ1CdjfidvmeW6mn"
| ],
| [
| "gmsow2Y6EWAFDFE1CE4Hd3Tpu2BvfmBfG1SXsuRARbnt1WjkZnFh1qGTiptWWbjsq2Q6qvpgJVj"
| ],
| [
| "nksUKSkzS76v8EsSgozXGMoQFiCoCHzCVajFKAXqzK5on9ZJYVHMD5CKwgmX3S3c7M1U3xabUny"
| ],
| [
| "L3favK1UzFGgdzYBF2oBT5tbayCo4vtVBLJhg2iYuMeePxWG8SQc"
| ],
| [
| "7VxLxGGtYT6N99GdEfi6xz56xdQ8nP2dG1CavuXx7Rf2PrvNMTBNevjkfgs9JmkcGm6EXpj8ipyPZ"
| ],
| [
| "2mbZwFXF6cxShaCo2czTRB62WTx9LxhTtpP"
| ],
| [
| "dB7cwYdcPSgiyAwKWL3JwCVwSk6epU2txw"
| ],
| [
| "HPhFUhUAh8ZQQisH8QQWafAxtQYju3SFTX"
| ],
| [
| "4ctAH6AkHzq5ioiM1m9T3E2hiYEev5mTsB"
| ],
| [
| "Hn1uFi4dNexWrqARpjMqgT6cX1UsNPuV3cHdGg9ExyXw8HTKadbktRDtdeVmY3M1BxJStiL4vjJ"
| ],
| [
| "Sq3fDbvutABmnAHHExJDgPLQn44KnNC7UsXuT7KZecpaYDMU9Txs"
| ],
| [
| "6TqWyrqdgUEYDQU1aChMuFMMEimHX44qHFzCUgGfqxGgZNMUVWJ"
| ],
| [
| "giqJo7oWqFxNKWyrgcBxAVHXnjJ1t6cGoEffce5Y1y7u649Noj5wJ4mmiUAKEVVrYAGg2KPB3Y4"
| ],
| [
| "cNzHY5e8vcmM3QVJUcjCyiKMYfeYvyueq5qCMV3kqcySoLyGLYUK"
| ],
| [
| "37uTe568EYc9WLoHEd9jXEvUiWbq5LFLscNyqvAzLU5vBArUJA6eydkLmnMwJDjkL5kXc2VK7ig"
| ],
| [
| "EsYbG4tWWWY45G31nox838qNdzksbPySWc"
| ],
| [
| "nbuzhfwMoNzA3PaFnyLcRxE9bTJPDkjZ6Rf6Y6o2ckXZfzZzXBT"
| ],
| [
| "cQN9PoxZeCWK1x56xnz6QYAsvR11XAce3Ehp3gMUdfSQ53Y2mPzx"
| ],
| [
| "1Gm3N3rkef6iMbx4voBzaxtXcmmiMTqZPhcuAepRzYUJQW4qRpEnHvMojzof42hjFRf8PE2jPde"
| ],
| [
| "2TAq2tuN6x6m233bpT7yqdYQPELdTDJn1eU"
| ],
| [
| "ntEtnnGhqPii4joABvBtSEJG6BxjT2tUZqE8PcVYgk3RHpgxgHDCQxNbLJf7ardf1dDk2oCQ7Cf"
| ],
| [
| "Ky1YjoZNgQ196HJV3HpdkecfhRBmRZdMJk89Hi5KGfpfPwS2bUbfd"
| ],
| [
| "2A1q1YsMZowabbvta7kTy2Fd6qN4r5ZCeG3qLpvZBMzCixMUdkN2Y4dHB1wPsZAeVXUGD83MfRED"
| ]
|]
|""".stripMargin
}