make additional request for blockhash in polkadot (#537)
This commit is contained in:
@@ -2,8 +2,12 @@ package io.emeraldpay.dshackle.upstream.beaconchain
|
||||
|
||||
import io.emeraldpay.dshackle.data.BlockContainer
|
||||
import io.emeraldpay.dshackle.data.BlockId
|
||||
import io.emeraldpay.dshackle.reader.ChainReader
|
||||
import io.emeraldpay.dshackle.upstream.ChainRequest
|
||||
import io.emeraldpay.dshackle.upstream.ChainResponse
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
import reactor.core.publisher.Mono
|
||||
import java.math.BigInteger
|
||||
import java.time.Instant
|
||||
|
||||
@@ -44,7 +48,13 @@ class BeaconChainSpecificTest {
|
||||
parsed = null,
|
||||
)
|
||||
|
||||
val block = BeaconChainSpecific.parseBlock(header, "upId")
|
||||
val block = BeaconChainSpecific.parseBlock(
|
||||
header,
|
||||
"upId",
|
||||
object : ChainReader {
|
||||
override fun read(key: ChainRequest): Mono<ChainResponse> = Mono.empty()
|
||||
},
|
||||
).block()!!
|
||||
assertEquals(expected, block)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package io.emeraldpay.dshackle.upstream.polkadot
|
||||
|
||||
import io.emeraldpay.dshackle.data.BlockId
|
||||
import io.emeraldpay.dshackle.reader.ChainReader
|
||||
import io.emeraldpay.dshackle.upstream.ChainRequest
|
||||
import io.emeraldpay.dshackle.upstream.ChainResponse
|
||||
import io.emeraldpay.dshackle.upstream.UpstreamAvailability
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
val example = """
|
||||
{
|
||||
@@ -63,10 +67,16 @@ val healthBadSyncing = """{
|
||||
class PolkadotChainSpecificTest {
|
||||
@Test
|
||||
fun parseResponse() {
|
||||
val result = PolkadotChainSpecific.parseBlock(example.toByteArray(), "1")
|
||||
val result = PolkadotChainSpecific.parseBlock(
|
||||
example.toByteArray(),
|
||||
"1",
|
||||
object : ChainReader {
|
||||
override fun read(key: ChainRequest): Mono<ChainResponse> = Mono.just(ChainResponse("\"0x1\"".toByteArray(), null))
|
||||
},
|
||||
).block()!!
|
||||
|
||||
Assertions.assertThat(result.height).isEqualTo(17963964)
|
||||
Assertions.assertThat(result.hash).isEqualTo(BlockId.from("0xb52a9b51fb698a891cf378b990b0b6a5743e52fa5175b44a8a6d4e0b2cfd0a53"))
|
||||
Assertions.assertThat(result.hash).isEqualTo(BlockId.from("0x1"))
|
||||
Assertions.assertThat(result.upstreamId).isEqualTo("1")
|
||||
Assertions.assertThat(result.parentHash).isEqualTo(BlockId.from("0xb52a9b51fb698a891cf378b990b0b6a5743e52fa5175b44a8a6d4e0b2cfd0a53"))
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package io.emeraldpay.dshackle.upstream.starknet
|
||||
|
||||
import io.emeraldpay.dshackle.data.BlockId
|
||||
import io.emeraldpay.dshackle.reader.ChainReader
|
||||
import io.emeraldpay.dshackle.upstream.ChainRequest
|
||||
import io.emeraldpay.dshackle.upstream.ChainResponse
|
||||
import io.emeraldpay.dshackle.upstream.UpstreamAvailability
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
val example = """
|
||||
{
|
||||
@@ -45,21 +49,31 @@ val syncingBad = """
|
||||
class StarknetChainSpecificTest {
|
||||
@Test
|
||||
fun parseResponse() {
|
||||
val result = StarknetChainSpecific.parseBlock(example.toByteArray(), "1")
|
||||
val result = StarknetChainSpecific.parseBlock(
|
||||
example.toByteArray(),
|
||||
"1",
|
||||
object : ChainReader {
|
||||
override fun read(key: ChainRequest): Mono<ChainResponse> = Mono.empty()
|
||||
},
|
||||
).block()!!
|
||||
|
||||
Assertions.assertThat(result.height).isEqualTo(304789)
|
||||
Assertions.assertThat(result.hash).isEqualTo(BlockId.from("046fa6638dc7fae06cece980ce4195436a79ef314ca49d99e0cef552d6f13c4e"))
|
||||
Assertions.assertThat(result.hash)
|
||||
.isEqualTo(BlockId.from("046fa6638dc7fae06cece980ce4195436a79ef314ca49d99e0cef552d6f13c4e"))
|
||||
Assertions.assertThat(result.upstreamId).isEqualTo("1")
|
||||
Assertions.assertThat(result.parentHash).isEqualTo(BlockId.from("07cc1e178c848b0bdfa047a414d9a8bee4f6cb76f25f312f2d42e058ea91d78b"))
|
||||
Assertions.assertThat(result.parentHash)
|
||||
.isEqualTo(BlockId.from("07cc1e178c848b0bdfa047a414d9a8bee4f6cb76f25f312f2d42e058ea91d78b"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun validateOk() {
|
||||
Assertions.assertThat(StarknetChainSpecific.validate(syncingGood.toByteArray(), 10, "test")).isEqualTo(UpstreamAvailability.OK)
|
||||
Assertions.assertThat(StarknetChainSpecific.validate(syncingGood.toByteArray(), 10, "test"))
|
||||
.isEqualTo(UpstreamAvailability.OK)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun validateSyncing() {
|
||||
Assertions.assertThat(StarknetChainSpecific.validate(syncingBad.toByteArray(), 10, "test")).isEqualTo(UpstreamAvailability.SYNCING)
|
||||
Assertions.assertThat(StarknetChainSpecific.validate(syncingBad.toByteArray(), 10, "test"))
|
||||
.isEqualTo(UpstreamAvailability.SYNCING)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user