multistreams as beans
This commit is contained in:
@@ -27,6 +27,7 @@ import io.emeraldpay.dshackle.reader.Reader
|
||||
import io.emeraldpay.dshackle.upstream.Multistream
|
||||
import io.emeraldpay.dshackle.upstream.calls.DirectCallMethods
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosUpstream
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.domain.BlockHash
|
||||
@@ -90,6 +91,17 @@ class TestingCommons {
|
||||
return new CachesFactory(new CacheConfig())
|
||||
}
|
||||
|
||||
static List<Multistream> defaultMultistreams() {
|
||||
return [
|
||||
multistreamWithoutUpstreams(Chain.ETHEREUM),
|
||||
multistreamWithoutUpstreams(Chain.ETHEREUM_CLASSIC)
|
||||
]
|
||||
}
|
||||
|
||||
static Multistream multistreamWithoutUpstreams(Chain chain) {
|
||||
return new EthereumPosMultiStream(chain, [], emptyCaches().getCaches(chain))
|
||||
}
|
||||
|
||||
static FileResolver fileResolver() {
|
||||
return new FileResolver(new File("src/test/resources"))
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class CurrentMultistreamHolderSpec extends Specification {
|
||||
|
||||
def "add upstream"() {
|
||||
setup:
|
||||
def current = new CurrentMultistreamHolder(TestingCommons.emptyCaches())
|
||||
def current = new CurrentMultistreamHolder(TestingCommons.defaultMultistreams())
|
||||
def up = new EthereumPosRpcUpstreamMock("test", Chain.ETHEREUM, TestingCommons.api())
|
||||
when:
|
||||
current.update(new UpstreamChange(Chain.ETHEREUM, up, UpstreamChange.ChangeType.ADDED))
|
||||
@@ -37,7 +37,7 @@ class CurrentMultistreamHolderSpec extends Specification {
|
||||
|
||||
def "add multiple upstreams"() {
|
||||
setup:
|
||||
def current = new CurrentMultistreamHolder(TestingCommons.emptyCaches())
|
||||
def current = new CurrentMultistreamHolder(TestingCommons.defaultMultistreams())
|
||||
def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api())
|
||||
def up2 = new EthereumRpcUpstreamMock("test2", Chain.ETHEREUM_CLASSIC, TestingCommons.api())
|
||||
def up3 = new EthereumPosRpcUpstreamMock("test3", Chain.ETHEREUM, TestingCommons.api())
|
||||
@@ -53,7 +53,7 @@ class CurrentMultistreamHolderSpec extends Specification {
|
||||
|
||||
def "remove upstream"() {
|
||||
setup:
|
||||
def current = new CurrentMultistreamHolder(TestingCommons.emptyCaches())
|
||||
def current = new CurrentMultistreamHolder(TestingCommons.defaultMultistreams())
|
||||
def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api())
|
||||
def up2 = new EthereumRpcUpstreamMock("test2", Chain.ETHEREUM_CLASSIC, TestingCommons.api())
|
||||
def up3 = new EthereumPosRpcUpstreamMock("test3", Chain.ETHEREUM, TestingCommons.api())
|
||||
@@ -71,7 +71,7 @@ class CurrentMultistreamHolderSpec extends Specification {
|
||||
|
||||
def "available after adding"() {
|
||||
setup:
|
||||
def current = new CurrentMultistreamHolder(TestingCommons.emptyCaches())
|
||||
def current = new CurrentMultistreamHolder(TestingCommons.defaultMultistreams())
|
||||
def up1 = new EthereumPosRpcUpstreamMock("test1", Chain.ETHEREUM, TestingCommons.api())
|
||||
|
||||
when:
|
||||
|
||||
Reference in New Issue
Block a user