Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
qfrank committed Jun 21, 2023
1 parent 57de3fd commit 22a920e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
24 changes: 6 additions & 18 deletions modules/react-native-status/nodejs/status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1877,37 +1877,25 @@ void _InitLogging(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();

if (args.Length() != 3) {
if (args.Length() != 1) {
// Throw an Error that is passed back to JavaScript
isolate->ThrowException(Exception::TypeError(
String::NewFromUtf8Literal(isolate, "Wrong number of arguments for InitLogging")));
return;
}

// Check the argument types
if (!args[0]->IsNumber()) {
isolate->ThrowException(Exception::TypeError(
String::NewFromUtf8Literal(isolate, "Wrong argument type for 'enabled'")));
return;
}
if (!args[1]->IsNumber()) {
isolate->ThrowException(Exception::TypeError(
String::NewFromUtf8Literal(isolate, "Wrong argument type for 'mobileSystem'")));
return;
}
if (!args[2]->IsString()) {
if (!args[0]->IsString()) {
isolate->ThrowException(Exception::TypeError(
String::NewFromUtf8Literal(isolate, "Wrong argument type for 'logLevel'")));
String::NewFromUtf8Literal(isolate, "Wrong argument type for 'logSettingsJSON'")));
return;
}

int arg0 = args[0]->Int32Value(context).ToChecked();
int arg1 = args[1]->Int32Value(context).ToChecked();
String::Utf8Value arg2Obj(isolate, args[2]->ToString(context).ToLocalChecked());
char *arg2 = *arg2Obj;
String::Utf8Value arg0Obj(isolate, args[0]->ToString(context).ToLocalChecked());
char *arg0 = *arg0Obj;

// Call exported Go function, which returns a C string
char *c = InitLogging(arg0, arg1, arg2);
char *c = InitLogging(arg0);

Local<String> ret = String::NewFromUtf8(isolate, c).ToLocalChecked();
args.GetReturnValue().Set(ret);
Expand Down
9 changes: 7 additions & 2 deletions src/status_im/utils/test.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns status-im.utils.test
(:require [re-frame.core :as re-frame]))
(:require [re-frame.core :as re-frame]
[status-im.utils.types :as types]))

(def native-status (js/require "../../modules/react-native-status/nodejs/bindings"))

Expand Down Expand Up @@ -129,4 +130,8 @@

:initLogging
(fn [enabled mobile-system log-level callback]
(callback (.initLogging native-status enabled mobile-system log-level)))}))
(callback (.initLogging native-status
(types/clj->json {:Enabled enabled
:MobileSystem mobile-system
:Level log-level
:File (str test-dir "/geth.log")}))))}))

0 comments on commit 22a920e

Please sign in to comment.