problem: WS connection still breaks with very large frames

solution: increase default limit and make it configurable
This commit is contained in:
Igor Artamonov
2021-09-22 19:35:14 -04:00
parent bd8c0f7c19
commit ebef8cf27a
9 changed files with 159 additions and 12 deletions

View File

@@ -99,6 +99,32 @@ class UpstreamsConfigReaderSpec extends Specification {
}
}
def "Parse full defined websocket config"() {
setup:
def config = this.class.getClassLoader().getResourceAsStream("upstreams-ws-full.yaml")
when:
def act = reader.read(config)
then:
act != null
act.upstreams.size() == 1
with(act.upstreams.get(0)) {
id == "local"
chain == "ethereum"
connection instanceof UpstreamsConfig.EthereumConnection
with((UpstreamsConfig.EthereumConnection) connection) {
rpc == null
ws != null
ws.url == new URI("ws://localhost:8546")
ws.basicAuth != null
with(ws.basicAuth) {
username == "9c199ad8f281f20154fc258fe41a6814"
password == "258fe4149c199ad8f2811a68f20154fc"
}
ws.frameSize == 10 * 1024 * 1024
ws.msgSize == 25 * 1024 * 1024
}
}
}
def "Parse bitcoin upstreams"() {
setup:

View File

@@ -0,0 +1,45 @@
/**
* Copyright (c) 2021 EmeraldPay, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.emeraldpay.dshackle.config
import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.nodes.MappingNode
import spock.lang.Specification
class YamlConfigReaderSpec extends Specification {
def "reads bytes values"() {
setup:
def rdr = new Impl()
expect:
rdr.getValueAsBytes(asNode("test", input), "test") == exp
where:
input | exp
"1024" | 1024
"1k" | 1024
"1kb" | 1024
"1K" | 1024
"16kb" | 16 * 1024
"1M" | 1024 * 1024
"4mb" | 4 * 1024 * 1024
}
private MappingNode asNode(String key, String value) {
return new Yaml().compose(new StringReader("$key: $value")) as MappingNode
}
class Impl extends YamlConfigReader {}
}

View File

@@ -0,0 +1,15 @@
version: v1
upstreams:
- id: local
chain: ethereum
connection:
ethereum:
ws:
url: "ws://localhost:8546"
origin: "http://localhost"
frameSize: 10Mb
msgSize: 25Mb
basic-auth:
username: 9c199ad8f281f20154fc258fe41a6814
password: 258fe4149c199ad8f2811a68f20154fc