Skip to content

Commit a1f8556

Browse files
Test Coverage Added
1 parent 52c1c5c commit a1f8556

File tree

8 files changed

+70
-11
lines changed

8 files changed

+70
-11
lines changed

client/src/test/kotlin/io/github/hosseinkarami_dev/near/rpc/client/BlockTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import org.junit.jupiter.api.Test
1616
import kotlin.test.AfterTest
1717
import kotlin.test.BeforeTest
1818
import kotlin.test.assertNotNull
19+
import kotlin.test.assertTrue
1920

2021
class BlockTest {
2122

@@ -46,6 +47,6 @@ class BlockTest {
4647
val response = nearClient.block(RpcBlockRequest.Finality(Finality.FINAL))
4748
val result = response.getResultOrNull<RpcBlockResponse>()
4849
println("Block Response: $result")
49-
assertNotNull(result)
50+
assertTrue { response is RpcResponse.Success }
5051
}
5152
}

client/src/test/kotlin/io/github/hosseinkarami_dev/near/rpc/client/BroadcastTxCommitTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ class BroadcastTxCommitTest {
4848
)
4949
val result = response.getResultOrNull<RpcTransactionResponse>()
5050
println("broadcastTxCommit Response: $result")
51-
assertNotNull(response !is RpcResponse.Failure)
51+
assertNotNull(response is RpcResponse.Success)
5252
}
5353
}

client/src/test/kotlin/io/github/hosseinkarami_dev/near/rpc/client/ExperimentalChangesInBlockTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ExperimentalChangesInBlockTest {
4444
Finality.FINAL))
4545

4646
val result = response.getResultOrNull<RpcStateChangesInBlockByTypeResponse>()
47-
println("Experimental Changes In Block Response: $response")
47+
println("Experimental Changes In Block Response: $result")
4848
assertTrue { response is RpcResponse.Success }
4949
}
5050
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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.AccountId
5+
import io.github.hosseinkarami_dev.near.rpc.models.CryptoHash
6+
import io.github.hosseinkarami_dev.near.rpc.models.RpcLightClientExecutionProofRequest
7+
import io.github.hosseinkarami_dev.near.rpc.models.RpcLightClientNextBlockResponse
8+
import io.ktor.client.HttpClient
9+
import io.ktor.client.engine.cio.CIO
10+
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
11+
import io.ktor.serialization.kotlinx.json.json
12+
import kotlinx.coroutines.test.runTest
13+
import org.junit.jupiter.api.Test
14+
import kotlin.test.AfterTest
15+
import kotlin.test.BeforeTest
16+
import kotlin.test.assertTrue
17+
18+
class ExperimentalLightClientProofTest {
19+
20+
private lateinit var httpClient: HttpClient
21+
private lateinit var nearClient: NearClient
22+
23+
@BeforeTest
24+
fun setup() {
25+
httpClient = HttpClient(CIO) {
26+
install(ContentNegotiation) {
27+
json()
28+
}
29+
}
30+
31+
nearClient = NearClient(
32+
httpClient = httpClient,
33+
baseUrl = "https://rpc.mainnet.near.org"
34+
)
35+
}
36+
37+
@AfterTest
38+
fun teardown() {
39+
httpClient.close()
40+
}
41+
42+
@Test
43+
fun testStatus() = runTest {
44+
val response = nearClient.experimentalLightClientProof(
45+
RpcLightClientExecutionProofRequest.Transaction(
46+
senderId = AccountId(""),
47+
transactionHash = CryptoHash(""),
48+
type = RpcLightClientExecutionProofRequest.Transaction.Type.TRANSACTION,
49+
lightClientHead = CryptoHash("")
50+
)
51+
)
52+
val result = response.getResultOrNull<RpcLightClientNextBlockResponse>()
53+
println("experimentalLightClientProof Response: $result")
54+
assertTrue { response is RpcResponse.Failure }
55+
}
56+
}

client/src/test/kotlin/io/github/hosseinkarami_dev/near/rpc/client/ExperimentalReceiptTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ExperimentalReceiptTest {
4444
receiptId = CryptoHash("3YbVEYmAkXyKZUk7iyKs4mVzvQ43azZnGjGj2hZua7VC")
4545
))
4646
val result = response.getResultOrNull<RpcReceiptResponse>()
47-
println("RPC Receipt Response: $response")
48-
assertTrue { true }
47+
println("RPC Receipt Response: $result")
48+
assertTrue { response is RpcResponse.Failure }
4949
}
5050
}

client/src/test/kotlin/io/github/hosseinkarami_dev/near/rpc/client/HealthTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ class HealthTest {
4848
val response = nearClient.health()
4949
val result = response.getResultOrNull<RpcValidatorResponse>()
5050
println("Health Response: $result")
51-
assertNotNull(response !is RpcResponse.Failure)
51+
assertNotNull(response is RpcResponse.Success)
5252
}
5353
}

client/src/test/kotlin/io/github/hosseinkarami_dev/near/rpc/client/NextLightClientBlockTest.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ class NextLightClientBlockTest {
4040

4141
@Test
4242
fun testStatus() = runTest {
43-
val response = nearClient.nextLightClientBlock(RpcLightClientNextBlockRequest(
44-
lastBlockHash = CryptoHash("4GoYYrySh93RJZmTnKo7mFnXi2PMPXUJ6GW2sU4xt4MB")
45-
))
43+
val response = nearClient.nextLightClientBlock(
44+
RpcLightClientNextBlockRequest(
45+
lastBlockHash = CryptoHash("4GoYYrySh93RJZmTnKo7mFnXi2PMPXUJ6GW2sU4xt4MB")
46+
)
47+
)
4648
val result = response.getResultOrNull<RpcLightClientNextBlockResponse>()
47-
println("RPC Receipt Response: $result")
49+
println("nextLightClientBlock Response: $result")
4850
assertTrue { response is RpcResponse.Success }
4951
}
5052
}

client/src/test/kotlin/io/github/hosseinkarami_dev/near/rpc/client/QueryTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ class QueryTest {
5151
val result = response.getResultOrNull<RpcQueryResponse>()
5252
println("ViewAccountByFinality Response: $result")
5353

54-
assertNotNull(response !is RpcResponse.Failure)
54+
assertNotNull(response is RpcResponse.Success)
5555
}
5656
}

0 commit comments

Comments
 (0)