Fix: Conversion to list.
When converting from an array of characters into a list of words, there was an off-by-one error that was causing the words to display incorrectly. This issue did not effect the seed that was used it only impacted the display. The problem has been fixed and the tests updated to catch this type of problem in the future.
This commit is contained in:
parent
c02842fbfc
commit
300e25dba9
|
@ -6,9 +6,10 @@ object Deps {
|
||||||
const val kotlinVersion = "1.3.72"
|
const val kotlinVersion = "1.3.72"
|
||||||
const val group = "cash.z.ecc.android"
|
const val group = "cash.z.ecc.android"
|
||||||
const val artifactName = "kotlin-bip39"
|
const val artifactName = "kotlin-bip39"
|
||||||
const val versionName = "1.0.0-beta08"
|
const val versionName = "1.0.0-beta09"
|
||||||
const val description = "A concise implementation of BIP-0039 in Kotlin for Android."
|
const val description = "A concise implementation of BIP-0039 in Kotlin for Android."
|
||||||
const val githubUrl = "https://github.com/zcash/kotlin-bip39"
|
const val githubUrl = "https://github.com/zcash/kotlin-bip39"
|
||||||
|
const val publishingActive = false // set to true to activate bintrayUpload task
|
||||||
|
|
||||||
object Kotlin : Version(kotlinVersion) {
|
object Kotlin : Version(kotlinVersion) {
|
||||||
val STDLIB = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version"
|
val STDLIB = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version"
|
||||||
|
|
|
@ -78,7 +78,7 @@ bintray {
|
||||||
userOrg = 'ecc-mobile'
|
userOrg = 'ecc-mobile'
|
||||||
licenses = ['MIT']
|
licenses = ['MIT']
|
||||||
vcsUrl = Deps.githubUrl
|
vcsUrl = Deps.githubUrl
|
||||||
dryRun = true
|
dryRun = !Deps.publishingActive
|
||||||
version {
|
version {
|
||||||
name = Deps.versionName
|
name = Deps.versionName
|
||||||
desc = Deps.description
|
desc = Deps.description
|
||||||
|
|
|
@ -72,7 +72,7 @@ object Mnemonics {
|
||||||
var cursor = 0
|
var cursor = 0
|
||||||
chars.forEachIndexed { i, c ->
|
chars.forEachIndexed { i, c ->
|
||||||
if (c == ' ' || i == chars.lastIndex) {
|
if (c == ' ' || i == chars.lastIndex) {
|
||||||
add(chars.copyOfRange(cursor, if (chars[i].isWhitespace()) i else i - 1))
|
add(chars.copyOfRange(cursor, if (chars[i].isWhitespace()) i else i + 1))
|
||||||
cursor = i + 1
|
cursor = i + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import io.kotest.assertions.throwables.shouldThrow
|
||||||
import io.kotest.core.spec.style.BehaviorSpec
|
import io.kotest.core.spec.style.BehaviorSpec
|
||||||
import io.kotest.data.forAll
|
import io.kotest.data.forAll
|
||||||
import io.kotest.data.row
|
import io.kotest.data.row
|
||||||
|
import io.kotest.matchers.collections.shouldContainAll
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
import io.kotest.matchers.shouldNotBe
|
import io.kotest.matchers.shouldNotBe
|
||||||
import io.kotest.matchers.string.shouldContain
|
import io.kotest.matchers.string.shouldContain
|
||||||
|
@ -81,8 +82,8 @@ class MnemonicsTest : BehaviorSpec({
|
||||||
words.size shouldBe wordCount.count
|
words.size shouldBe wordCount.count
|
||||||
}
|
}
|
||||||
Then("Each word is present in the original phrase") {
|
Then("Each word is present in the original phrase") {
|
||||||
words.forEach {
|
phraseString.split(' ').let { correctWords ->
|
||||||
phraseString shouldContain "$it"
|
words.shouldContainAll(correctWords)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue