Commit 8a87b8ec authored by vipwzw's avatar vipwzw

fix linter

parent ba74692e
package executor 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 callcode = `
var tojson = JSON.stringify var tojson = JSON.stringify
function kvcreator(dbtype) { function kvcreator(dbtype) {
......
...@@ -4,7 +4,6 @@ import ( ...@@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"github.com/33cn/chain33/common" "github.com/33cn/chain33/common"
log "github.com/33cn/chain33/common/log/log15"
drivers "github.com/33cn/chain33/system/dapp" drivers "github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
ptypes "github.com/33cn/plugin/plugin/dapp/js/types" ptypes "github.com/33cn/plugin/plugin/dapp/js/types"
...@@ -12,10 +11,6 @@ import ( ...@@ -12,10 +11,6 @@ import (
"github.com/robertkrimen/otto" "github.com/robertkrimen/otto"
) )
var (
ptylog = log.New("module", "execs.js")
)
var driverName = ptypes.JsX var driverName = ptypes.JsX
func init() { func init() {
...@@ -31,7 +26,6 @@ func Init(name string, sub []byte) { ...@@ -31,7 +26,6 @@ func Init(name string, sub []byte) {
type js struct { type js struct {
drivers.DriverBase drivers.DriverBase
prefix []byte prefix []byte
localprefix []byte
} }
func newjs() drivers.Driver { func newjs() drivers.Driver {
......
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"github.com/33cn/chain33/common/db" "github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
"github.com/33cn/chain33/util" "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/33cn/plugin/plugin/dapp/js/types/jsproto"
"github.com/robertkrimen/otto" "github.com/robertkrimen/otto"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
...@@ -164,18 +165,18 @@ func TestCallError(t *testing.T) { ...@@ -164,18 +165,18 @@ func TestCallError(t *testing.T) {
_, err = e.callVM("hello", call, tx, 0, nil) _, err = e.callVM("hello", call, tx, 0, nil)
_, ok = err.(*otto.Error) _, ok = err.(*otto.Error)
assert.Equal(t, true, ok) assert.Equal(t, true, ok)
assert.Equal(t, true, strings.Contains(err.Error(), errInvalidFuncPrefix.Error())) assert.Equal(t, true, strings.Contains(err.Error(), ptypes.ErrInvalidFuncPrefix.Error()))
call, tx = callCodeTx("test", "hello2", `{"hello":"world"}`) call, tx = callCodeTx("test", "hello2", `{"hello":"world"}`)
_, err = e.callVM("exec", call, tx, 0, nil) _, err = e.callVM("exec", call, tx, 0, nil)
_, ok = err.(*otto.Error) _, ok = err.(*otto.Error)
assert.Equal(t, true, ok) assert.Equal(t, true, ok)
assert.Equal(t, true, strings.Contains(err.Error(), errFuncNotFound.Error())) assert.Equal(t, true, strings.Contains(err.Error(), ptypes.ErrFuncNotFound.Error()))
} }
func TestCalcLocalPrefix(t *testing.T) { func TestCalcLocalPrefix(t *testing.T) {
assert.Equal(t, calcLocalPrefix([]byte("a")), []byte("LODB-a-")) assert.Equal(t, calcLocalPrefix([]byte("a")), []byte("LODB-a-"))
assert.Equal(t, calcStatePrefix([]byte("a")), []byte("mavl-a-")) assert.Equal(t, calcStatePrefix([]byte("a")), []byte("mavl-a-"))
assert.Equal(t, calcCodeKey("a"), []byte("mavl-js-code-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"))
} }
...@@ -38,6 +38,12 @@ var ( ...@@ -38,6 +38,12 @@ var (
ErrJsReturnNotObject = errors.New("ErrJsReturnNotObject") ErrJsReturnNotObject = errors.New("ErrJsReturnNotObject")
ErrJsReturnKVSFormat = errors.New("ErrJsReturnKVSFormat") ErrJsReturnKVSFormat = errors.New("ErrJsReturnKVSFormat")
ErrJsReturnLogsFormat = errors.New("ErrJsReturnLogsFormat") 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() { func init() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment