problem: doesn't handle upstream error for additionally allowed methods; allowing an existing method redefines its logic

rel: #67
This commit is contained in:
Igor Artamonov
2021-03-23 18:39:45 -04:00
parent 51c56acd86
commit be33508bb9
12 changed files with 149 additions and 20 deletions

View File

@@ -11,6 +11,7 @@ cluster:
methods:
enabled:
- name: debug_traceTransaction
- name: test_foo
options:
disable-validation: true
connection:

View File

@@ -34,6 +34,11 @@ class TestcaseHandler implements CallHandler {
&& params[0].to?.toLowerCase() == "0xdAC17F958D2ee523a2206206994597C13D831ec7".toLowerCase()) {
return Result.error(-32000, "invalid opcode: opcode 0xfe not defined")
}
// https://github.com/emeraldpay/dshackle/issues/67, when a custom method configured
if (method == "test_foo"
&& params[0].to?.toLowerCase() == "0xdAC17F958D2ee523a2206206994597C13D831ec7".toLowerCase()) {
return Result.error(-32000, "invalid opcode: opcode 0xfe not defined")
}
return null
}
}

View File

@@ -51,4 +51,22 @@ class GivesErrorSpec extends Specification {
message == "invalid opcode: opcode 0xfe not defined"
}
}
def "Dispatch error from upstream when custome method is used"() {
// issue #67
when:
def call = [
to : "0xdAC17F958D2ee523a2206206994597C13D831ec7",
from: "0xEF65ffB384c99a00403EAa22115323a555700D79",
data: "0xa9059cbb0000000000000000000000003f5ce5fbfe3e9af3971dd833d26ba9b5c936f0be000000000000000000000000000000000000000000000000000000004856fb60"
]
def act = client.execute("test_foo", [call, "0x100000"])
then:
act.result == null
act.error != null
with(act.error) {
code == -32000
message == "invalid opcode: opcode 0xfe not defined"
}
}
}