Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
8a87b8ec
Commit
8a87b8ec
authored
Jan 01, 2019
by
vipwzw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix linter
parent
ba74692e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
21 deletions
+11
-21
const.go
plugin/dapp/js/executor/const.go
+0
-11
js.go
plugin/dapp/js/executor/js.go
+1
-7
jsvm_test.go
plugin/dapp/js/executor/jsvm_test.go
+4
-3
js.go
plugin/dapp/js/types/js.go
+6
-0
No files found.
plugin/dapp/js/executor/const.go
View file @
8a87b8ec
package
executor
import
"errors"
//ErrInvalidFuncFormat 错误的函数调用格式(没有_)
var
errInvalidFuncFormat
=
errors
.
New
(
"chain33.js: invalid function name format"
)
//ErrInvalidFuncPrefix not exec_ execloal_ query_
var
errInvalidFuncPrefix
=
errors
.
New
(
"chain33.js: invalid function prefix format"
)
//ErrFuncNotFound 函数没有找到
var
errFuncNotFound
=
errors
.
New
(
"chain33.js: invalid function name not found"
)
var
callcode
=
`
var tojson = JSON.stringify
function kvcreator(dbtype) {
...
...
plugin/dapp/js/executor/js.go
View file @
8a87b8ec
...
...
@@ -4,7 +4,6 @@ import (
"encoding/json"
"github.com/33cn/chain33/common"
log
"github.com/33cn/chain33/common/log/log15"
drivers
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
ptypes
"github.com/33cn/plugin/plugin/dapp/js/types"
...
...
@@ -12,10 +11,6 @@ import (
"github.com/robertkrimen/otto"
)
var
(
ptylog
=
log
.
New
(
"module"
,
"execs.js"
)
)
var
driverName
=
ptypes
.
JsX
func
init
()
{
...
...
@@ -30,8 +25,7 @@ func Init(name string, sub []byte) {
type
js
struct
{
drivers
.
DriverBase
prefix
[]
byte
localprefix
[]
byte
prefix
[]
byte
}
func
newjs
()
drivers
.
Driver
{
...
...
plugin/dapp/js/executor/jsvm_test.go
View file @
8a87b8ec
...
...
@@ -9,6 +9,7 @@ import (
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util"
ptypes
"github.com/33cn/plugin/plugin/dapp/js/types"
"github.com/33cn/plugin/plugin/dapp/js/types/jsproto"
"github.com/robertkrimen/otto"
"github.com/stretchr/testify/assert"
...
...
@@ -164,18 +165,18 @@ func TestCallError(t *testing.T) {
_
,
err
=
e
.
callVM
(
"hello"
,
call
,
tx
,
0
,
nil
)
_
,
ok
=
err
.
(
*
otto
.
Error
)
assert
.
Equal
(
t
,
true
,
ok
)
assert
.
Equal
(
t
,
true
,
strings
.
Contains
(
err
.
Error
(),
e
rrInvalidFuncPrefix
.
Error
()))
assert
.
Equal
(
t
,
true
,
strings
.
Contains
(
err
.
Error
(),
ptypes
.
E
rrInvalidFuncPrefix
.
Error
()))
call
,
tx
=
callCodeTx
(
"test"
,
"hello2"
,
`{"hello":"world"}`
)
_
,
err
=
e
.
callVM
(
"exec"
,
call
,
tx
,
0
,
nil
)
_
,
ok
=
err
.
(
*
otto
.
Error
)
assert
.
Equal
(
t
,
true
,
ok
)
assert
.
Equal
(
t
,
true
,
strings
.
Contains
(
err
.
Error
(),
e
rrFuncNotFound
.
Error
()))
assert
.
Equal
(
t
,
true
,
strings
.
Contains
(
err
.
Error
(),
ptypes
.
E
rrFuncNotFound
.
Error
()))
}
func
TestCalcLocalPrefix
(
t
*
testing
.
T
)
{
assert
.
Equal
(
t
,
calcLocalPrefix
([]
byte
(
"a"
)),
[]
byte
(
"LODB-a-"
))
assert
.
Equal
(
t
,
calcStatePrefix
([]
byte
(
"a"
)),
[]
byte
(
"mavl-a-"
))
assert
.
Equal
(
t
,
calcCodeKey
(
"a"
),
[]
byte
(
"mavl-js-code-a"
))
assert
.
Equal
(
t
,
calcRollbackKey
([]
byte
(
"a"
)),
[]
byte
(
"
mavl
-js-rollback-a"
))
assert
.
Equal
(
t
,
calcRollbackKey
([]
byte
(
"a"
)),
[]
byte
(
"
LODB
-js-rollback-a"
))
}
plugin/dapp/js/types/js.go
View file @
8a87b8ec
...
...
@@ -38,6 +38,12 @@ var (
ErrJsReturnNotObject
=
errors
.
New
(
"ErrJsReturnNotObject"
)
ErrJsReturnKVSFormat
=
errors
.
New
(
"ErrJsReturnKVSFormat"
)
ErrJsReturnLogsFormat
=
errors
.
New
(
"ErrJsReturnLogsFormat"
)
//ErrInvalidFuncFormat 错误的函数调用格式(没有_)
ErrInvalidFuncFormat
=
errors
.
New
(
"chain33.js: invalid function name format"
)
//ErrInvalidFuncPrefix not exec_ execloal_ query_
ErrInvalidFuncPrefix
=
errors
.
New
(
"chain33.js: invalid function prefix format"
)
//ErrFuncNotFound 函数没有找到
ErrFuncNotFound
=
errors
.
New
(
"chain33.js: invalid function name not found"
)
)
func
init
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment