support object params

This commit is contained in:
a10zn8
2024-02-27 17:35:03 +03:00
parent 8c5e69a7f5
commit 6cc0e18692
50 changed files with 360 additions and 276 deletions

View File

@@ -6,6 +6,7 @@ import io.emeraldpay.dshackle.upstream.ethereum.EthereumLowerBoundBlockDetector
import io.emeraldpay.dshackle.upstream.polkadot.PolkadotLowerBoundBlockDetector
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
@@ -87,11 +88,11 @@ class RecursiveLowerBoundBlockDetectorTest {
blocks.forEach {
if (it == 17964844L) {
on {
read(JsonRpcRequest("eth_getBalance", listOf("0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", it.toHex())))
read(JsonRpcRequest("eth_getBalance", ListParams("0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", it.toHex())))
} doReturn Mono.just(JsonRpcResponse(ByteArray(0), null))
} else {
on {
read(JsonRpcRequest("eth_getBalance", listOf("0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", it.toHex())))
read(JsonRpcRequest("eth_getBalance", ListParams("0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", it.toHex())))
} doReturn Mono.error(RuntimeException("missing trie node"))
}
}
@@ -103,17 +104,17 @@ class RecursiveLowerBoundBlockDetectorTest {
blocks.forEach {
if (it == 17964844L) {
on {
read(JsonRpcRequest("chain_getBlockHash", listOf(it.toHex())))
read(JsonRpcRequest("chain_getBlockHash", ListParams(it.toHex())))
} doReturn Mono.just(JsonRpcResponse("\"$hash1\"".toByteArray(), null))
on {
read(JsonRpcRequest("state_getMetadata", listOf(hash1)))
read(JsonRpcRequest("state_getMetadata", ListParams(hash1)))
} doReturn Mono.just(JsonRpcResponse(ByteArray(0), null))
} else {
on {
read(JsonRpcRequest("chain_getBlockHash", listOf(it.toHex())))
read(JsonRpcRequest("chain_getBlockHash", ListParams(it.toHex())))
} doReturn Mono.just(JsonRpcResponse("\"$hash2\"".toByteArray(), null))
on {
read(JsonRpcRequest("state_getMetadata", listOf(hash2)))
read(JsonRpcRequest("state_getMetadata", ListParams(hash2)))
} doReturn Mono.error(RuntimeException("State already discarded for"))
}
}

View File

@@ -6,6 +6,7 @@ import io.emeraldpay.dshackle.reader.JsonRpcReader
import io.emeraldpay.dshackle.upstream.Upstream
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.mockito.kotlin.doReturn
@@ -19,13 +20,13 @@ class SolanaLowerBoundBlockDetectorTest {
@Test
fun `get solana lower block and slot`() {
val reader = mock<JsonRpcReader> {
on { read(JsonRpcRequest("getFirstAvailableBlock", listOf())) } doReturn
on { read(JsonRpcRequest("getFirstAvailableBlock", ListParams())) } doReturn
Mono.just(JsonRpcResponse("25000000".toByteArray(), null))
on {
read(
JsonRpcRequest(
"getBlock",
listOf(
ListParams(
25000000L,
mapOf(
"showRewards" to false,