disable local router caches
This commit is contained in:
@@ -47,4 +47,14 @@ class CacheConfigReaderSpec extends Specification {
|
||||
//later may be not null if we support something else besides Redis
|
||||
act == null
|
||||
}
|
||||
|
||||
def "Local read disabled"() {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("cache-local-router-disabled.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
|
||||
then:
|
||||
!act.requestsCacheEnabled
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ import com.google.protobuf.ByteString
|
||||
import io.emeraldpay.api.proto.BlockchainOuterClass
|
||||
import io.emeraldpay.api.proto.Common
|
||||
import io.emeraldpay.dshackle.Global
|
||||
import io.emeraldpay.dshackle.config.CacheConfig
|
||||
import io.emeraldpay.dshackle.quorum.QuorumReaderFactory
|
||||
import io.emeraldpay.dshackle.quorum.QuorumRpcReader
|
||||
import io.emeraldpay.dshackle.reader.Reader
|
||||
import io.emeraldpay.dshackle.startup.ConfiguredUpstreams
|
||||
import io.emeraldpay.dshackle.test.MultistreamHolderMock
|
||||
import io.emeraldpay.dshackle.test.TestingCommons
|
||||
import io.emeraldpay.dshackle.quorum.AlwaysQuorum
|
||||
@@ -52,14 +52,19 @@ class NativeCallSpec extends Specification {
|
||||
|
||||
ObjectMapper objectMapper = Global.objectMapper
|
||||
|
||||
def nativeCall(MultistreamHolder upstreams = null, ResponseSigner signer = null) {
|
||||
def nativeCall(MultistreamHolder upstreams = null, ResponseSigner signer = null, Boolean enableCache = true) {
|
||||
|
||||
if (upstreams == null) {
|
||||
upstreams = Stub(MultistreamHolder)
|
||||
}
|
||||
if (signer == null) {
|
||||
signer = Stub(ResponseSigner)
|
||||
}
|
||||
new NativeCall(upstreams, signer)
|
||||
|
||||
def config = new CacheConfig()
|
||||
config.requestsCacheEnabled = enableCache
|
||||
|
||||
new NativeCall(upstreams, signer, config)
|
||||
}
|
||||
|
||||
def "Tries router first"() {
|
||||
|
||||
@@ -327,8 +327,9 @@ class MultistreamSpec extends Specification {
|
||||
super(chain, upstreams, caches)
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
Mono<Reader<JsonRpcRequest, JsonRpcResponse>> getRoutedApi(@NotNull Selector.Matcher matcher) {
|
||||
Mono<Reader<JsonRpcRequest, JsonRpcResponse>> getRoutedApi(boolean localEnabled) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.emeraldpay.dshackle.upstream.ethereum
|
||||
|
||||
import io.emeraldpay.dshackle.Global
|
||||
import io.emeraldpay.dshackle.cache.Caches
|
||||
import io.emeraldpay.dshackle.config.CacheConfig
|
||||
import io.emeraldpay.dshackle.reader.EmptyReader
|
||||
import io.emeraldpay.dshackle.test.TestingCommons
|
||||
import io.emeraldpay.dshackle.upstream.EmptyHead
|
||||
@@ -29,7 +30,8 @@ class LocalCallRouterSpec extends Specification {
|
||||
ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM))
|
||||
),
|
||||
methods,
|
||||
new EmptyHead()
|
||||
new EmptyHead(),
|
||||
true
|
||||
)
|
||||
when:
|
||||
def act = router.read(new JsonRpcRequest("eth_coinbase", [])).block(Duration.ofSeconds(1))
|
||||
@@ -47,7 +49,8 @@ class LocalCallRouterSpec extends Specification {
|
||||
ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM))
|
||||
),
|
||||
methods,
|
||||
new EmptyHead()
|
||||
new EmptyHead(),
|
||||
true
|
||||
)
|
||||
when:
|
||||
def act = router.read(new JsonRpcRequest("eth_getTransactionByHash", ["test"], 10))
|
||||
@@ -69,7 +72,7 @@ class LocalCallRouterSpec extends Specification {
|
||||
}
|
||||
}
|
||||
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
|
||||
def router = new LocalCallRouter(reader, methods, head)
|
||||
def router = new LocalCallRouter(reader, methods, head, true)
|
||||
|
||||
when:
|
||||
def act = router.getBlockByNumber(["latest", false])
|
||||
@@ -95,7 +98,7 @@ class LocalCallRouterSpec extends Specification {
|
||||
}
|
||||
}
|
||||
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
|
||||
def router = new LocalCallRouter(reader, methods, head)
|
||||
def router = new LocalCallRouter(reader, methods, head, true)
|
||||
|
||||
when:
|
||||
def act = router.getBlockByNumber(["earliest", false])
|
||||
@@ -121,7 +124,7 @@ class LocalCallRouterSpec extends Specification {
|
||||
}
|
||||
}
|
||||
def methods = new DefaultEthereumMethods(Chain.ETHEREUM)
|
||||
def router = new LocalCallRouter(reader, methods, head)
|
||||
def router = new LocalCallRouter(reader, methods, head, true)
|
||||
|
||||
when:
|
||||
def act = router.getBlockByNumber(["0x123ef", false])
|
||||
|
||||
2
src/test/resources/cache-local-router-disabled.yaml
Normal file
2
src/test/resources/cache-local-router-disabled.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
cache:
|
||||
requests-cache-enabled: false
|
||||
Reference in New Issue
Block a user