diff --git a/build.gradle.kts b/build.gradle.kts index 44b7ac30..f697b413 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -56,7 +56,7 @@ kotlin { dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) - implementation("org.kodein.memory:kodein-memory-files:0.7.0") + implementation("org.kodein.memory:klio-files:0.12.0") api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0") } } diff --git a/src/commonTest/kotlin/fr/acinq/bitcoin/BlockTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/bitcoin/BlockTestsCommon.kt index 5445c876..4a879c9a 100644 --- a/src/commonTest/kotlin/fr/acinq/bitcoin/BlockTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/bitcoin/BlockTestsCommon.kt @@ -27,10 +27,10 @@ class BlockTestsCommon { private val blockData = run { val file = TransactionTestsCommon.resourcesDir().resolve("block1.dat") file.openReadableFile().use { - val len = it.available + val len = it.size // workaround for a bug in kotlin memory file where dstOffset cannot be 0 but is still ignored... val buffer = ByteArray(len) - for (i in buffer.indices) buffer[i] = it.readByte() + it.readBytes(buffer, 0, buffer.size) buffer } } diff --git a/src/commonTest/kotlin/fr/acinq/bitcoin/CryptoTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/bitcoin/CryptoTestsCommon.kt index 09c3becf..e87915a5 100644 --- a/src/commonTest/kotlin/fr/acinq/bitcoin/CryptoTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/bitcoin/CryptoTestsCommon.kt @@ -21,7 +21,7 @@ import fr.acinq.secp256k1.Hex import fr.acinq.secp256k1.Secp256k1 import org.kodein.memory.file.openReadableFile import org.kodein.memory.file.resolve -import org.kodein.memory.io.readLine +import org.kodein.memory.text.readLine import org.kodein.memory.use import kotlin.random.Random import kotlin.test.* diff --git a/src/commonTest/kotlin/fr/acinq/bitcoin/TaprootTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/bitcoin/TaprootTestsCommon.kt index d6a92572..baa4bf40 100644 --- a/src/commonTest/kotlin/fr/acinq/bitcoin/TaprootTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/bitcoin/TaprootTestsCommon.kt @@ -369,8 +369,8 @@ class TaprootTestsCommon { fun `parse and validate huge transaction`() { // this is the tx that broke btcd/lnd val file = resourcesDir().resolve("7393096d97bfee8660f4100ffd61874d62f9a65de9fb6acf740c4c386990ef73.bin").openReadableFile() - val buffer = ByteArray(file.available) - file.readBytes(buffer) + val buffer = ByteArray(file.size) + file.readBytes(buffer, 0, buffer.size) file.close() val tx = Transaction.read(buffer) assertEquals(1001, tx.txIn[0].witness.stack.size) @@ -421,8 +421,8 @@ class TaprootTestsCommon { @Test fun `parse and validate large ordinals transaction`() { val file = resourcesDir().resolve("b5a7e05f28d00e4a791759ad7b6bd6799d856693293ceeaad9b0bb93c8851f7f.bin").openReadableFile() - val buffer = ByteArray(file.available) - file.readBytes(buffer) + val buffer = ByteArray(file.size) + file.readBytes(buffer, 0, buffer.size) file.close() val tx = Transaction.read(buffer) val parentTx = Transaction.read(