detect gas limit for a node (#545)

This commit is contained in:
Vyacheslav
2024-08-12 14:46:16 +03:00
committed by GitHub
parent ef9c2e42a8
commit e8410d7638
2 changed files with 71 additions and 2 deletions

View File

@@ -25,6 +25,16 @@ class EthereumUpstreamSettingsDetectorSpec extends Specification {
answer("eth_blockNumber", [], "0x10df3e5")
answer("eth_getBalance", ["0x0000000000000000000000000000000000000000", "0x10dccd5"], "")
answer("eth_getBalance", ["0x0000000000000000000000000000000000000000", "0x2710"], "")
answer("eth_call", [[
"to": "0x53Daa71B04d589429f6d3DF52db123913B818F22",
"data": "0x51be4eaa",
],
"latest",
[
"0x53Daa71B04d589429f6d3DF52db123913B818F22": [
"code": "0x6080604052348015600e575f80fd5b50600436106026575f3560e01c806351be4eaa14602a575b5f80fd5b60306044565b604051603b91906061565b60405180910390f35b5f5a905090565b5f819050919050565b605b81604b565b82525050565b5f60208201905060725f8301846054565b9291505056fea2646970667358221220a85b088da3911ea743505594ac7cfdd1a65865de64499ee1f3c6bd9cdad4552364736f6c634300081a0033",
],
]], "0x2fa9dc4")
}
)
def detector = new EthereumUpstreamSettingsDetector(up, Chain.ETHEREUM__MAINNET)
@@ -36,7 +46,8 @@ class EthereumUpstreamSettingsDetectorSpec extends Specification {
.expectNext(
new Pair<String, String>("client_type", clientType),
new Pair<String, String>("client_version", version),
new Pair<String, String>("archive", "true")
new Pair<String, String>("archive", "true"),
new Pair<String, String>("gas-limit", "50000000")
)
.expectComplete()
.verify(Duration.ofSeconds(1))
@@ -76,7 +87,7 @@ class EthereumUpstreamSettingsDetectorSpec extends Specification {
def "Only default label"() {
setup:
def up = Mock(DefaultUpstream) {
4 * getIngressReader() >> Mock(Reader) {
5 * getIngressReader() >> Mock(Reader) {
1 * read(new ChainRequest("web3_clientVersion", new ListParams())) >>
Mono.just(new ChainResponse('no/v1.19.3+e8ac1da4/linux-x64/dotnet7.0.8'.getBytes(), null))
1 * read(new ChainRequest("eth_blockNumber", new ListParams())) >>
@@ -85,6 +96,18 @@ class EthereumUpstreamSettingsDetectorSpec extends Specification {
Mono.error(new RuntimeException())
1 * read(new ChainRequest("eth_getBalance", new ListParams(["0x0000000000000000000000000000000000000000", "0x2710"]))) >>
Mono.just(new ChainResponse("".getBytes(), null))
1 * read(new ChainRequest("eth_call", new ListParams([
"to": "0x53Daa71B04d589429f6d3DF52db123913B818F22",
"data": "0x51be4eaa",
],
"latest",
[
"0x53Daa71B04d589429f6d3DF52db123913B818F22": [
"code": "0x6080604052348015600e575f80fd5b50600436106026575f3560e01c806351be4eaa14602a575b5f80fd5b60306044565b604051603b91906061565b60405180910390f35b5f5a905090565b5f819050919050565b605b81604b565b82525050565b5f60208201905060725f8301846054565b9291505056fea2646970667358221220a85b088da3911ea743505594ac7cfdd1a65865de64499ee1f3c6bd9cdad4552364736f6c634300081a0033",
],
],
))) >>
Mono.just(new ChainResponse("".getBytes(), null))
}
getLabels() >> []
}