jvmTest.io.ipfs.kotlin.TestStats.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ipfs-api Show documentation
Show all versions of ipfs-api Show documentation
IPFS API for kotlin to access a IPFS node via http
package io.ipfs.kotlin
import io.ktor.http.*
import kotlinx.coroutines.test.runTest
import okhttp3.mockwebserver.MockResponse
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
class TestStats : BaseIPFSWebserverTest() {
@Test
fun testBandWidthStats() = runTest {
// setup
server.enqueue(
MockResponse().setHeader("Content-Type", ContentType.Application.Json)
.setBody("{\"TotalIn\":80461165,\"TotalOut\":70998948,\"RateIn\":1103.8830769540511,\"RateOut\":1814.6417381019044}\n")
)
// invoke
val statsBandWidth = ipfs.stats.bandWidth()
// assert
assertThat(statsBandWidth).isNotNull()
assertThat(statsBandWidth!!.TotalIn).isEqualTo(80461165)
assertThat(statsBandWidth.TotalOut).isEqualTo(70998948)
assertThat(statsBandWidth.RateIn).isEqualTo(1103.8830769540511)
assertThat(statsBandWidth.RateOut).isEqualTo(1814.6417381019044)
val executedRequest = server.takeRequest()
assertThat(executedRequest.path).isEqualTo("/stats/bw")
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy