소스 검색

Allowed missing params in system.multicall RPC method.

Tatsuhiro Tsujikawa 14 년 전
부모
커밋
d1885a5874
2개의 변경된 파일11개의 추가작업 그리고 10개의 파일을 삭제
  1. 10 6
      src/RpcMethodImpl.cc
  2. 1 4
      test/RpcMethodTest.cc

+ 10 - 6
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) {

+ 1 - 4
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)));
 }