1+ package io.github.hosseinkarami_dev.near.rpc.client
2+
3+ import io.github.hosseinkarami_dev.near.rpc.client.Utils.getResultOrNull
4+ import io.github.hosseinkarami_dev.near.rpc.models.CryptoHash
5+ import io.github.hosseinkarami_dev.near.rpc.models.RpcLightClientBlockProofRequest
6+ import io.github.hosseinkarami_dev.near.rpc.models.RpcLightClientNextBlockResponse
7+ import io.ktor.client.HttpClient
8+ import io.ktor.client.engine.cio.CIO
9+ import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
10+ import io.ktor.serialization.kotlinx.json.json
11+ import kotlinx.coroutines.test.runTest
12+ import org.junit.jupiter.api.Test
13+ import kotlin.test.AfterTest
14+ import kotlin.test.BeforeTest
15+ import kotlin.test.assertTrue
16+
17+ class ExperimentalLightClientBlockProofTest {
18+
19+ private lateinit var httpClient: HttpClient
20+ private lateinit var nearClient: NearClient
21+
22+ @BeforeTest
23+ fun setup () {
24+ httpClient = HttpClient (CIO ) {
25+ install(ContentNegotiation ) {
26+ json()
27+ }
28+ }
29+
30+ nearClient = NearClient (
31+ httpClient = httpClient,
32+ baseUrl = " https://rpc.mainnet.near.org"
33+ )
34+ }
35+
36+ @AfterTest
37+ fun teardown () {
38+ httpClient.close()
39+ }
40+
41+ @Test
42+ fun testStatus () = runTest {
43+ val response = nearClient.experimentalLightClientBlockProof(
44+ RpcLightClientBlockProofRequest (
45+ blockHash = CryptoHash (" " ),
46+ lightClientHead = CryptoHash (" " )
47+ )
48+ )
49+ val result = response.getResultOrNull<RpcLightClientNextBlockResponse >()
50+ println (" experimentalLightClientBlockProof Response: $response " )
51+ assertTrue { response is RpcResponse .Failure }
52+ }
53+ }
0 commit comments