diff options
author | Felix Lange <fjl@twurst.com> | 2015-05-25 08:27:37 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-05-25 08:27:37 +0800 |
commit | e221a449e069783ca53fd02716066e66baeae1f0 (patch) | |
tree | 03b5465f6d71e79b06befede03976f852d9f9058 /jsre/jsre_test.go | |
parent | 394826f520f4c34fe11c8e9dc45c5810024a22e2 (diff) | |
download | go-tangerine-e221a449e069783ca53fd02716066e66baeae1f0.tar go-tangerine-e221a449e069783ca53fd02716066e66baeae1f0.tar.gz go-tangerine-e221a449e069783ca53fd02716066e66baeae1f0.tar.bz2 go-tangerine-e221a449e069783ca53fd02716066e66baeae1f0.tar.lz go-tangerine-e221a449e069783ca53fd02716066e66baeae1f0.tar.xz go-tangerine-e221a449e069783ca53fd02716066e66baeae1f0.tar.zst go-tangerine-e221a449e069783ca53fd02716066e66baeae1f0.zip |
cmd/geth, jsre, rpc: run all JS code on the event loop
Some JSRE methods (PrettyPrint, ToVal) bypassed the event loop. All
calls to the JS VM are now wrapped. In order to make this somewhat more
foolproof, the otto VM is now a local variable inside the event loop.
Diffstat (limited to 'jsre/jsre_test.go')
-rw-r--r-- | jsre/jsre_test.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/jsre/jsre_test.go b/jsre/jsre_test.go index 5eaca2b91..42308de88 100644 --- a/jsre/jsre_test.go +++ b/jsre/jsre_test.go @@ -1,16 +1,15 @@ package jsre import ( - "github.com/robertkrimen/otto" "io/ioutil" "os" "testing" "time" + + "github.com/robertkrimen/otto" ) -type testNativeObjectBinding struct { - toVal func(interface{}) otto.Value -} +type testNativeObjectBinding struct{} type msg struct { Msg string @@ -21,7 +20,8 @@ func (no *testNativeObjectBinding) TestMethod(call otto.FunctionCall) otto.Value if err != nil { return otto.UndefinedValue() } - return no.toVal(&msg{m}) + v, _ := call.Otto.ToValue(&msg{m}) + return v } func TestExec(t *testing.T) { @@ -74,7 +74,7 @@ func TestNatto(t *testing.T) { func TestBind(t *testing.T) { jsre := New("/tmp") - jsre.Bind("no", &testNativeObjectBinding{jsre.ToVal}) + jsre.Bind("no", &testNativeObjectBinding{}) val, err := jsre.Run(`no.TestMethod("testMsg")`) if err != nil { |