Skip to content

Commit f46cfcb

Browse files
fixed some bugs
1 parent cbf18d6 commit f46cfcb

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed
Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,46 @@
11
package io.github.hosseinkarami_dev.near.rpc.client
22

3+
import io.github.hosseinkarami_dev.near.rpc.client.Utils.getResultOrNull
4+
import io.github.hosseinkarami_dev.near.rpc.models.RpcStatusResponse
35
import io.ktor.client.HttpClient
46
import io.ktor.client.engine.cio.CIO
57
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
68
import io.ktor.serialization.kotlinx.json.json
79
import kotlinx.coroutines.test.runTest
810
import org.junit.jupiter.api.Test
11+
import kotlin.test.AfterTest
12+
import kotlin.test.BeforeTest
13+
import kotlin.test.assertNotNull
914

1015
class NearClientTest {
1116

12-
private val httpClient = HttpClient(CIO) {
13-
install(ContentNegotiation) {
14-
json()
17+
private lateinit var httpClient: HttpClient
18+
private lateinit var nearClient: NearClient
19+
20+
@BeforeTest
21+
fun setup() {
22+
httpClient = HttpClient(CIO) {
23+
install(ContentNegotiation) {
24+
json()
25+
}
1526
}
27+
28+
nearClient = NearClient(
29+
httpClient = httpClient,
30+
baseUrl = "https://rpc.testnet.near.org"
31+
)
32+
}
33+
34+
@AfterTest
35+
fun teardown() {
36+
httpClient.close()
1637
}
17-
//
18-
// private val nearClient = NearClient(
19-
// httpClient = httpClient,
20-
// baseUrl = "https://rpc.mainnet.near.org"
21-
// )
2238

2339
@Test
24-
fun testTransactionStatus() = runTest {
40+
fun testStatus() = runTest {
41+
val response = nearClient.status()
42+
val result = response.getResultOrNull<RpcStatusResponse>()
43+
assertNotNull(result)
44+
println("Status response: $result")
2545
}
2646
}

0 commit comments

Comments
 (0)