summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-06-15 00:42:50 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-06-15 00:42:50 +0900
commitd1885a58743f150fd1ec6979bbb4dfd05ec4900f (patch)
tree95583365f7a4b4cd115516db6d82c1545164c6a0
parent2d92571cf9f171479163bd386b12c49e5805113a (diff)
Allowed missing params in system.multicall RPC method.
-rw-r--r--src/RpcMethodImpl.cc16
-rw-r--r--test/RpcMethodTest.cc5
2 files changed, 11 insertions, 10 deletions
diff --git a/src/RpcMethodImpl.cc b/src/RpcMethodImpl.cc
index 216c4ce0..3012c218 100644
--- a/src/RpcMethodImpl.cc
+++ b/src/RpcMethodImpl.cc
@@ -1380,11 +1380,9 @@ SharedHandle<ValueBase> SystemMulticallRpcMethod::process
continue;
}
const String* methodName = asString(methodDict->get(KEY_METHOD_NAME));
- const List* paramsList = asList(methodDict->get(KEY_PARAMS));
-
- if(!methodName || !paramsList) {
+ if(!methodName) {
list->append(createErrorResponse
- (DL_ABORT_EX("Missing methodName or params."), req));
+ (DL_ABORT_EX("Missing methodName."), req));
continue;
}
if(methodName->s() == getMethodName()) {
@@ -1392,9 +1390,15 @@ SharedHandle<ValueBase> SystemMulticallRpcMethod::process
(DL_ABORT_EX("Recursive system.multicall forbidden."), req));
continue;
}
+ const SharedHandle<ValueBase>& tempParamsList = methodDict->get(KEY_PARAMS);
+ SharedHandle<List> paramsList;
+ if(asList(tempParamsList)) {
+ paramsList = static_pointer_cast<List>(tempParamsList);
+ } else {
+ paramsList = List::g();
+ }
SharedHandle<RpcMethod> method = RpcMethodFactory::create(methodName->s());
- RpcRequest innerReq
- (methodName->s(), static_pointer_cast<List>(methodDict->get(KEY_PARAMS)));
+ RpcRequest innerReq(methodName->s(), paramsList);
innerReq.jsonRpc = req.jsonRpc;
RpcResponse res = method->execute(innerReq, e);
if(res.code == 0) {
diff --git a/test/RpcMethodTest.cc b/test/RpcMethodTest.cc
index 72d03d1d..8d9c5d7a 100644
--- a/test/RpcMethodTest.cc
+++ b/test/RpcMethodTest.cc
@@ -1129,10 +1129,7 @@ void RpcMethodTest::testSystemMulticall()
asInteger
(asDict(resParams->get(4))->get("faultCode"))
->i());
- CPPUNIT_ASSERT_EQUAL((int64_t)1,
- asInteger
- (asDict(resParams->get(5))->get("faultCode"))
- ->i());
+ CPPUNIT_ASSERT(asList(resParams->get(5)));
CPPUNIT_ASSERT(asList(resParams->get(6)));
}