blob detector npe fix, other detectors fix 404 scenario (#776)
* blob detector npe fix, other detectors fix 404 scenario * Fix flaky GenericRpcHeadTest scheduler
This commit is contained in:
@@ -55,12 +55,16 @@ class BeaconChainLowerBoundBlobDetector(
|
|||||||
|
|
||||||
private fun parseHeadersResponse(data: ByteArray): ChainResponse {
|
private fun parseHeadersResponse(data: ByteArray): ChainResponse {
|
||||||
val node = Global.objectMapper.readValue<JsonNode>(data)
|
val node = Global.objectMapper.readValue<JsonNode>(data)
|
||||||
if (node.get("code") != null && node.get("message") != null && node.get("code").textValue() == "404") {
|
val codeNode = node.get("code")
|
||||||
return ChainResponse(null, ChainCallError(node.get("code").asInt(), node.get("message").asText(), node.get("message").asText()))
|
val messageNode = node.get("message")
|
||||||
|
val is404 = codeNode != null && (codeNode.asInt() == 404 || codeNode.asText() == "404")
|
||||||
|
if (is404 && messageNode != null) {
|
||||||
|
return ChainResponse(null, ChainCallError(404, messageNode.asText(), messageNode.asText()))
|
||||||
}
|
}
|
||||||
if (node.get("data").toString() == "[]") {
|
val dataNode = node.get("data")
|
||||||
|
if (dataNode == null || dataNode.isNull || (dataNode.isArray && dataNode.size() == 0)) {
|
||||||
return ChainResponse(null, ChainCallError(404, notFoundError))
|
return ChainResponse(null, ChainCallError(404, notFoundError))
|
||||||
}
|
}
|
||||||
return ChainResponse(node.get("data").toString().toByteArray(), null)
|
return ChainResponse(dataNode.toString().toByteArray(), null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,8 +57,11 @@ class BeaconChainLowerBoundBlockDetector(
|
|||||||
|
|
||||||
private fun parseHeadersResponse(data: ByteArray): ChainResponse {
|
private fun parseHeadersResponse(data: ByteArray): ChainResponse {
|
||||||
val node = Global.objectMapper.readValue<JsonNode>(data)
|
val node = Global.objectMapper.readValue<JsonNode>(data)
|
||||||
if (node.get("code") != null && node.get("message") != null && node.get("code").textValue() == "404") {
|
val codeNode = node.get("code")
|
||||||
return ChainResponse(null, ChainCallError(node.get("code").asInt(), node.get("message").asText(), node.get("message").asText()))
|
val messageNode = node.get("message")
|
||||||
|
val is404 = codeNode != null && (codeNode.asInt() == 404 || codeNode.asText() == "404")
|
||||||
|
if (is404 && messageNode != null) {
|
||||||
|
return ChainResponse(null, ChainCallError(404, messageNode.asText(), messageNode.asText()))
|
||||||
}
|
}
|
||||||
if (node.get("data")?.get("message")?.get("slot") != null) {
|
if (node.get("data")?.get("message")?.get("slot") != null) {
|
||||||
return ChainResponse(node.get("data").toString().toByteArray(), null)
|
return ChainResponse(node.get("data").toString().toByteArray(), null)
|
||||||
|
|||||||
@@ -80,10 +80,12 @@ class BeaconChainLowerBoundEpochDetector(
|
|||||||
|
|
||||||
private fun parseHeadersResponse(data: ByteArray): ChainResponse {
|
private fun parseHeadersResponse(data: ByteArray): ChainResponse {
|
||||||
val node = Global.objectMapper.readValue<JsonNode>(data)
|
val node = Global.objectMapper.readValue<JsonNode>(data)
|
||||||
if (node.get("code") != null && node.get("message") != null && node.get("code").textValue() == "404") {
|
val codeNode = node.get("code")
|
||||||
return ChainResponse(null, ChainCallError(node.get("code").asInt(), node.get("message").asText(), node.get("message").asText()))
|
val messageNode = node.get("message")
|
||||||
|
val is404 = codeNode != null && (codeNode.asInt() == 404 || codeNode.asText() == "404")
|
||||||
|
if (is404 && messageNode != null) {
|
||||||
|
return ChainResponse(null, ChainCallError(404, messageNode.asText(), messageNode.asText()))
|
||||||
}
|
}
|
||||||
|
|
||||||
val jsonData = node.get("data")
|
val jsonData = node.get("data")
|
||||||
if (jsonData != null) {
|
if (jsonData != null) {
|
||||||
val str = jsonData.toString()
|
val str = jsonData.toString()
|
||||||
|
|||||||
@@ -54,10 +54,12 @@ class BeaconChainLowerBoundStateDetector(
|
|||||||
|
|
||||||
private fun parseHeadersResponse(data: ByteArray): ChainResponse {
|
private fun parseHeadersResponse(data: ByteArray): ChainResponse {
|
||||||
val node = Global.objectMapper.readValue<JsonNode>(data)
|
val node = Global.objectMapper.readValue<JsonNode>(data)
|
||||||
if (node.get("code") != null && node.get("message") != null && node.get("code").textValue() == "404") {
|
val codeNode = node.get("code")
|
||||||
return ChainResponse(null, ChainCallError(node.get("code").asInt(), node.get("message").asText(), node.get("message").asText()))
|
val messageNode = node.get("message")
|
||||||
|
val is404 = codeNode != null && (codeNode.asInt() == 404 || codeNode.asText() == "404")
|
||||||
|
if (is404 && messageNode != null) {
|
||||||
|
return ChainResponse(null, ChainCallError(404, messageNode.asText(), messageNode.asText()))
|
||||||
}
|
}
|
||||||
|
|
||||||
val jsonData = node.get("data")
|
val jsonData = node.get("data")
|
||||||
if (jsonData != null) {
|
if (jsonData != null) {
|
||||||
val str = jsonData.toString()
|
val str = jsonData.toString()
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ class GenericRpcHeadTest {
|
|||||||
"id",
|
"id",
|
||||||
BlockValidator.ALWAYS_VALID,
|
BlockValidator.ALWAYS_VALID,
|
||||||
upstream,
|
upstream,
|
||||||
Schedulers.boundedElastic(),
|
Schedulers.immediate(),
|
||||||
EthereumChainSpecific,
|
EthereumChainSpecific,
|
||||||
Duration.ofSeconds(5),
|
Duration.ofSeconds(5),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user