Validate upstream settings periodically (#316)
This commit is contained in:
@@ -37,6 +37,9 @@ import java.time.Duration
|
||||
import static io.emeraldpay.dshackle.Chain.ETHEREUM__MAINNET
|
||||
import static io.emeraldpay.dshackle.Chain.OPTIMISM__MAINNET
|
||||
import static io.emeraldpay.dshackle.upstream.UpstreamAvailability.*
|
||||
import static io.emeraldpay.dshackle.upstream.ethereum.EthereumUpstreamValidator.ValidateUpstreamSettingsResult.UPSTREAM_FATAL_SETTINGS_ERROR
|
||||
import static io.emeraldpay.dshackle.upstream.ethereum.EthereumUpstreamValidator.ValidateUpstreamSettingsResult.UPSTREAM_SETTINGS_ERROR
|
||||
import static io.emeraldpay.dshackle.upstream.ethereum.EthereumUpstreamValidator.ValidateUpstreamSettingsResult.UPSTREAM_VALID
|
||||
import static java.util.Collections.emptyList
|
||||
|
||||
class EthereumUpstreamValidatorSpec extends Specification {
|
||||
@@ -45,18 +48,18 @@ class EthereumUpstreamValidatorSpec extends Specification {
|
||||
setup:
|
||||
def validator = new EthereumUpstreamValidator(ETHEREUM__MAINNET, Stub(EthereumLikeUpstream), ChainOptions.PartialOptions.getDefaults().buildOptions())
|
||||
expect:
|
||||
validator.resolve(Tuples.of(sync, peers, call)) == exp
|
||||
validator.resolve(Tuples.of(sync, peers)) == exp
|
||||
where:
|
||||
exp | sync | peers | call
|
||||
OK | OK | OK | OK
|
||||
IMMATURE | OK | IMMATURE | OK
|
||||
UNAVAILABLE | OK | UNAVAILABLE | OK
|
||||
SYNCING | SYNCING | OK | OK
|
||||
SYNCING | SYNCING | IMMATURE | OK
|
||||
UNAVAILABLE | SYNCING | UNAVAILABLE | OK
|
||||
UNAVAILABLE | UNAVAILABLE | OK | OK
|
||||
UNAVAILABLE | UNAVAILABLE | IMMATURE | OK
|
||||
UNAVAILABLE | UNAVAILABLE | UNAVAILABLE | OK
|
||||
exp | sync | peers
|
||||
OK | OK | OK
|
||||
IMMATURE | OK | IMMATURE
|
||||
UNAVAILABLE | OK | UNAVAILABLE
|
||||
SYNCING | SYNCING | OK
|
||||
SYNCING | SYNCING | IMMATURE
|
||||
UNAVAILABLE | SYNCING | UNAVAILABLE
|
||||
UNAVAILABLE | UNAVAILABLE | OK
|
||||
UNAVAILABLE | UNAVAILABLE | IMMATURE
|
||||
UNAVAILABLE | UNAVAILABLE | UNAVAILABLE
|
||||
}
|
||||
|
||||
def "Doesnt check eth_syncing when disabled"() {
|
||||
@@ -280,9 +283,9 @@ class EthereumUpstreamValidatorSpec extends Specification {
|
||||
def validator = new EthereumUpstreamValidator(ETHEREUM__MAINNET, up, options)
|
||||
|
||||
when:
|
||||
def act = validator.validateUpstreamSettings()
|
||||
def act = validator.validateUpstreamSettingsOnStartup()
|
||||
then:
|
||||
act
|
||||
act == UPSTREAM_VALID
|
||||
}
|
||||
|
||||
def "Upstream is valid if not error from call limit check"() {
|
||||
@@ -304,9 +307,9 @@ class EthereumUpstreamValidatorSpec extends Specification {
|
||||
def validator = new EthereumUpstreamValidator(ETHEREUM__MAINNET, up, options, "0x32268860cAAc2948Ab5DdC7b20db5a420467Cf96")
|
||||
|
||||
when:
|
||||
def act = validator.validateUpstreamSettings()
|
||||
def act = validator.validateUpstreamSettingsOnStartup()
|
||||
then:
|
||||
act
|
||||
act == UPSTREAM_VALID
|
||||
}
|
||||
|
||||
def "Upstream is not valid if error returned on call limit check"() {
|
||||
@@ -328,9 +331,9 @@ class EthereumUpstreamValidatorSpec extends Specification {
|
||||
def validator = new EthereumUpstreamValidator(ETHEREUM__MAINNET, up, options, "0x32268860cAAc2948Ab5DdC7b20db5a420467Cf96")
|
||||
|
||||
when:
|
||||
def act = validator.validateUpstreamSettings()
|
||||
def act = validator.validateUpstreamSettingsOnStartup()
|
||||
then:
|
||||
!act
|
||||
act == UPSTREAM_SETTINGS_ERROR
|
||||
}
|
||||
|
||||
def "Upstream is valid if chain settings are valid"() {
|
||||
@@ -350,9 +353,9 @@ class EthereumUpstreamValidatorSpec extends Specification {
|
||||
def validator = new EthereumUpstreamValidator(ETHEREUM__MAINNET, up, options, "0x32268860cAAc2948Ab5DdC7b20db5a420467Cf96")
|
||||
|
||||
when:
|
||||
def act = validator.validateUpstreamSettings()
|
||||
def act = validator.validateUpstreamSettingsOnStartup()
|
||||
then:
|
||||
act
|
||||
act == UPSTREAM_VALID
|
||||
}
|
||||
|
||||
def "Upstream is not valid - specified optimism but got ethereum"() {
|
||||
@@ -372,9 +375,9 @@ class EthereumUpstreamValidatorSpec extends Specification {
|
||||
def validator = new EthereumUpstreamValidator(OPTIMISM__MAINNET, up, options, "0x32268860cAAc2948Ab5DdC7b20db5a420467Cf96")
|
||||
|
||||
when:
|
||||
def act = validator.validateUpstreamSettings()
|
||||
def act = validator.validateUpstreamSettingsOnStartup()
|
||||
then:
|
||||
!act
|
||||
act == UPSTREAM_FATAL_SETTINGS_ERROR
|
||||
}
|
||||
|
||||
def "Upstream is valid if all setting are valid"() {
|
||||
@@ -396,9 +399,9 @@ class EthereumUpstreamValidatorSpec extends Specification {
|
||||
def validator = new EthereumUpstreamValidator(ETHEREUM__MAINNET, up, options, "0x32268860cAAc2948Ab5DdC7b20db5a420467Cf96")
|
||||
|
||||
when:
|
||||
def act = validator.validateUpstreamSettings()
|
||||
def act = validator.validateUpstreamSettingsOnStartup()
|
||||
then:
|
||||
act
|
||||
act == UPSTREAM_VALID
|
||||
}
|
||||
|
||||
def "Upstream is not valid if there are errors"() {
|
||||
@@ -420,9 +423,9 @@ class EthereumUpstreamValidatorSpec extends Specification {
|
||||
def validator = new EthereumUpstreamValidator(ETHEREUM__MAINNET, up, options, "0x32268860cAAc2948Ab5DdC7b20db5a420467Cf96")
|
||||
|
||||
when:
|
||||
def act = validator.validateUpstreamSettings()
|
||||
def act = validator.validateUpstreamSettingsOnStartup()
|
||||
then:
|
||||
!act
|
||||
act == UPSTREAM_SETTINGS_ERROR
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user