Skip to content

Commit

Permalink
Replace kodein-memory-file with klio-files
Browse files Browse the repository at this point in the history
  • Loading branch information
sstone committed Dec 13, 2023
1 parent 3053286 commit 00417aa
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/commonTest/kotlin/fr/acinq/bitcoin/BlockTestsCommon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down
8 changes: 4 additions & 4 deletions src/commonTest/kotlin/fr/acinq/bitcoin/TaprootTestsCommon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 00417aa

Please sign in to comment.