remove unused code
This commit is contained in:
@@ -180,26 +180,6 @@ class MultistreamSpec extends Specification {
|
||||
!act
|
||||
}
|
||||
|
||||
def "Call postprocess after api use"() {
|
||||
setup:
|
||||
def request = new JsonRpcRequest("test_foo", [1], 1, null)
|
||||
|
||||
def api = TestingCommons.api()
|
||||
api.answer("test_foo", [1], "test")
|
||||
def postprocessor = Mock(RequestPostprocessor)
|
||||
def up = TestingCommons.upstream(api)
|
||||
def multistream = new TestMultistream([up], postprocessor)
|
||||
|
||||
when:
|
||||
def rdr = multistream.getDirectApi(Selector.empty).block(Duration.ofSeconds(1))
|
||||
def act = rdr.read(request).block(Duration.ofSeconds(1))
|
||||
|
||||
then:
|
||||
act != null
|
||||
act.hasResult()
|
||||
act.resultAsProcessedString == "test"
|
||||
1 * postprocessor.onReceive("test_foo", [1], "\"test\"".bytes)
|
||||
}
|
||||
|
||||
def "Filter upstream matching selector single"() {
|
||||
setup:
|
||||
@@ -341,48 +321,6 @@ class MultistreamSpec extends Specification {
|
||||
.expectComplete()
|
||||
.verify(Duration.ofSeconds(1))
|
||||
}
|
||||
|
||||
class TestMultistream extends Multistream {
|
||||
|
||||
TestMultistream(List<Upstream> upstreams, @NotNull RequestPostprocessor postprocessor) {
|
||||
super(Chain.ETHEREUM, upstreams, Caches.default(), postprocessor)
|
||||
}
|
||||
|
||||
@Override
|
||||
Mono<Reader<JsonRpcRequest, JsonRpcResponse>> getRoutedApi(@NotNull Selector.Matcher matcher) {
|
||||
return null
|
||||
}
|
||||
|
||||
@Override
|
||||
Head updateHead() {
|
||||
return null
|
||||
}
|
||||
|
||||
@Override
|
||||
void setHead(@NotNull Head head) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
Head getHead() {
|
||||
return null
|
||||
}
|
||||
|
||||
@Override
|
||||
Collection<UpstreamsConfig.Labels> getLabels() {
|
||||
return null
|
||||
}
|
||||
|
||||
public <T extends Upstream> T cast(Class<T> selfType) {
|
||||
return this
|
||||
}
|
||||
|
||||
@Override
|
||||
ChainFees getFeeEstimation() {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
class TestEthereumPosMultistream extends EthereumPosMultiStream {
|
||||
|
||||
TestEthereumPosMultistream(@NotNull Chain chain, @NotNull List<EthereumPosUpstream> upstreams, @NotNull Caches caches) {
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
package io.emeraldpay.dshackle.upstream
|
||||
|
||||
import io.emeraldpay.dshackle.reader.Reader
|
||||
import io.emeraldpay.dshackle.test.TestingCommons
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import reactor.core.publisher.Mono
|
||||
import spock.lang.Specification
|
||||
|
||||
import java.time.Duration
|
||||
|
||||
class RequestPostprocessorSpec extends Specification {
|
||||
|
||||
def "Wrappers calls onReceive for a value"() {
|
||||
setup:
|
||||
def request = new JsonRpcRequest("test_foo", [1], 1, null)
|
||||
def processor = Mock(RequestPostprocessor)
|
||||
def api = TestingCommons.api()
|
||||
api.answer("test_foo", [1], "test")
|
||||
def wrapped = new RequestPostprocessor.Wrapper(api, processor)
|
||||
|
||||
when:
|
||||
def act = wrapped.read(request).block(Duration.ofSeconds(1))
|
||||
|
||||
then:
|
||||
act.hasResult()
|
||||
act.resultAsProcessedString == "test"
|
||||
1 * processor.onReceive("test_foo", [1], "\"test\"".bytes)
|
||||
}
|
||||
|
||||
def "Wrappers doesn't call onReceive for no value"() {
|
||||
setup:
|
||||
def request = new JsonRpcRequest("test_foo", [1], 1, null)
|
||||
def processor = Mock(RequestPostprocessor)
|
||||
Reader<JsonRpcRequest, JsonRpcResponse> reader = Mock(Reader) {
|
||||
1 * it.read(request) >> Mono.empty()
|
||||
}
|
||||
def wrapped = new RequestPostprocessor.Wrapper(reader, processor)
|
||||
|
||||
when:
|
||||
def act = wrapped.read(request).block(Duration.ofSeconds(1))
|
||||
|
||||
then:
|
||||
act == null
|
||||
0 * processor.onReceive(_, _, _)
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package io.emeraldpay.dshackle.upstream.ethereum
|
||||
|
||||
import io.emeraldpay.dshackle.cache.Caches
|
||||
import io.emeraldpay.dshackle.data.DefaultContainer
|
||||
import spock.lang.Specification
|
||||
|
||||
class CacheRequestedSpec extends Specification {
|
||||
|
||||
def "Do nothing if unsupported method"() {
|
||||
setup:
|
||||
def caches = Mock(Caches)
|
||||
CacheRequested instance = new CacheRequested(caches)
|
||||
when:
|
||||
instance.onReceive("eth_hashrate", [], '"0x38a"'.bytes)
|
||||
then:
|
||||
0 * caches._(*_)
|
||||
}
|
||||
|
||||
def "Caches tx receipt"() {
|
||||
setup:
|
||||
def caches = Mock(Caches)
|
||||
CacheRequested instance = new CacheRequested(caches)
|
||||
def json = '''{
|
||||
"blockHash": "0x2c3cfd4c7f2b58859371f5795eaf8524caa6e63145ac7e9df23c8d63aab891ae",
|
||||
"blockNumber": "0x213b8a",
|
||||
"contractAddress": null,
|
||||
"cumulativeGasUsed": "0x5208",
|
||||
"gasUsed": "0x5208",
|
||||
"logs": [],
|
||||
"transactionHash": "0x5929b36be4586c57bd87dfb7ea6be3b985c1f527fa3d69d221604b424aeb4197",
|
||||
"transactionIndex": "0x00"
|
||||
}'''.bytes
|
||||
|
||||
when:
|
||||
instance.onReceive("eth_getTransactionReceipt", ["0x5929b36be4586c57bd87dfb7ea6be3b985c1f527fa3d69d221604b424aeb4197"], json)
|
||||
|
||||
then:
|
||||
1 * caches.cacheReceipt(Caches.Tag.REQUESTED, { DefaultContainer it ->
|
||||
it.height == 0x213b8a &&
|
||||
it.txId.toHex() == "5929b36be4586c57bd87dfb7ea6be3b985c1f527fa3d69d221604b424aeb4197" &&
|
||||
it.json == json
|
||||
})
|
||||
}
|
||||
|
||||
def "Ignore null"() {
|
||||
setup:
|
||||
def caches = Mock(Caches)
|
||||
CacheRequested instance = new CacheRequested(caches)
|
||||
def json = 'null'.bytes
|
||||
|
||||
when:
|
||||
instance.cacheTxReceipt(["0x5929b36be4586c57bd87dfb7ea6be3b985c1f527fa3d69d221604b424aeb4197"], json)
|
||||
|
||||
then:
|
||||
0 * caches.cacheReceipt(_, _)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user