Commit 8a87b8ec authored by vipwzw's avatar vipwzw

fix linter

parent ba74692e
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) {
......
......@@ -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 {
......
......@@ -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(), errInvalidFuncPrefix.Error()))
assert.Equal(t, true, strings.Contains(err.Error(), ptypes.ErrInvalidFuncPrefix.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(), errFuncNotFound.Error()))
assert.Equal(t, true, strings.Contains(err.Error(), ptypes.ErrFuncNotFound.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"))
}
......@@ -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() {
......
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