mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 19:29:39 +00:00
Merge pull request #439 from nspcc-dev/inspectionFixes
Inspection fixes
This commit is contained in:
commit
60b2cbb809
16 changed files with 18 additions and 19 deletions
|
@ -18,8 +18,8 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
errNoInput = errors.New("No input file was found, specify an input file with the '--in or -i' flag")
|
||||
errNoSmartContractName = errors.New("No name was provided, specify the '--name or -n' flag")
|
||||
errNoInput = errors.New("no input file was found, specify an input file with the '--in or -i' flag")
|
||||
errNoSmartContractName = errors.New("no name was provided, specify the '--name or -n' flag")
|
||||
errFileExist = errors.New("A file with given smart-contract name already exists")
|
||||
)
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ func TestBinBlockDecodeEncode(t *testing.T) {
|
|||
"908a398dd65dfd2aad6c06090c5a71d5e5280746577a6ddd5a1f2c1453f71ead": false,
|
||||
}
|
||||
|
||||
hashes := []string{}
|
||||
var hashes []string
|
||||
|
||||
for _, tx := range b.Transactions {
|
||||
switch tx.Type {
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestEncodeDecodeContract(t *testing.T) {
|
|||
assert.Equal(t, ContractType, tx.Type)
|
||||
assert.IsType(t, tx.Data, &ContractTX{})
|
||||
assert.Equal(t, 0, int(tx.Version))
|
||||
assert.Equal(t, 1, int(len(tx.Inputs)))
|
||||
assert.Equal(t, 1, len(tx.Inputs))
|
||||
|
||||
input := tx.Inputs[0]
|
||||
|
||||
|
|
|
@ -122,15 +122,14 @@ func IsDoubleSpend(s storage.Store, tx *transaction.Transaction) bool {
|
|||
if r.Err != nil {
|
||||
return false
|
||||
}
|
||||
if unspent == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
for _, input := range inputs {
|
||||
if int(input.PrevIndex) >= len(unspent.states) || unspent.states[input.PrevIndex] == CoinStateSpent {
|
||||
return true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ func TestCreateMultiSigRedeemScript(t *testing.T) {
|
|||
|
||||
for i := 0; i < len(validators); i++ {
|
||||
bb := br.ReadBytes()
|
||||
if err != nil {
|
||||
if br.Err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, validators[i].Bytes(), bb)
|
||||
|
|
|
@ -12,7 +12,7 @@ const (
|
|||
decimals = 100000000
|
||||
)
|
||||
|
||||
var errInvalidString = errors.New("Fixed8 must satisfy following regex \\d+(\\.\\d{1,8})?")
|
||||
var errInvalidString = errors.New("fixed8 must satisfy following regex \\d+(\\.\\d{1,8})?")
|
||||
|
||||
// Fixed8 represents a fixed-point number with precision 10^-8.
|
||||
type Fixed8 int64
|
||||
|
|
|
@ -213,7 +213,7 @@ func handleBreak(c *ishell.Context) {
|
|||
}
|
||||
v := getVMFromContext(c)
|
||||
if len(c.Args) != 1 {
|
||||
c.Err(errors.New("Missing parameter <ip>"))
|
||||
c.Err(errors.New("missing parameter <ip>"))
|
||||
}
|
||||
n, err := strconv.Atoi(c.Args[0])
|
||||
if err != nil {
|
||||
|
|
|
@ -87,7 +87,7 @@ func CompileAndSave(src string, o *Options) error {
|
|||
}
|
||||
b, err = Compile(bytes.NewReader(b), o)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error while trying to compile smart contract file: %v", err)
|
||||
return fmt.Errorf("error while trying to compile smart contract file: %v", err)
|
||||
}
|
||||
|
||||
log.Println(hex.EncodeToString(b))
|
||||
|
|
|
@ -85,7 +85,7 @@ func emitSyscall(w *bytes.Buffer, api string) error {
|
|||
}
|
||||
buf := make([]byte, len(api)+1)
|
||||
buf[0] = byte(len(api))
|
||||
copy(buf[1:], []byte(api))
|
||||
copy(buf[1:], api)
|
||||
return emit(w, vm.SYSCALL, buf)
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ func EmitSyscall(w *bytes.Buffer, api string) error {
|
|||
}
|
||||
buf := make([]byte, len(api)+1)
|
||||
buf[0] = byte(len(api))
|
||||
copy(buf[1:], []byte(api))
|
||||
copy(buf[1:], api)
|
||||
return Emit(w, SYSCALL, buf)
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ func makeStackItem(v interface{}) StackItem {
|
|||
case StackItem:
|
||||
return val
|
||||
case []int:
|
||||
a := []StackItem{}
|
||||
var a []StackItem
|
||||
for _, i := range val {
|
||||
a = append(a, makeStackItem(i))
|
||||
}
|
||||
|
|
|
@ -131,5 +131,5 @@ var assignTestCases = []testCase{
|
|||
}
|
||||
|
||||
func TestAssignments(t *testing.T) {
|
||||
run_testcases(t, assignTestCases)
|
||||
runTestCases(t, assignTestCases)
|
||||
}
|
||||
|
|
|
@ -189,5 +189,5 @@ var binaryExprTestCases = []testCase{
|
|||
}
|
||||
|
||||
func TestBinaryExprs(t *testing.T) {
|
||||
run_testcases(t, binaryExprTestCases)
|
||||
runTestCases(t, binaryExprTestCases)
|
||||
}
|
||||
|
|
|
@ -21,5 +21,5 @@ var numericTestCases = []testCase{
|
|||
}
|
||||
|
||||
func TestNumericExprs(t *testing.T) {
|
||||
run_testcases(t, numericTestCases)
|
||||
runTestCases(t, numericTestCases)
|
||||
}
|
||||
|
|
|
@ -240,5 +240,5 @@ var structTestCases = []testCase{
|
|||
}
|
||||
|
||||
func TestStructs(t *testing.T) {
|
||||
run_testcases(t, structTestCases)
|
||||
runTestCases(t, structTestCases)
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ type testCase struct {
|
|||
result interface{}
|
||||
}
|
||||
|
||||
func run_testcases(t *testing.T, tcases []testCase) {
|
||||
func runTestCases(t *testing.T, tcases []testCase) {
|
||||
for _, tcase := range tcases {
|
||||
t.Run(tcase.name, func(t *testing.T) { eval(t, tcase.src, tcase.result) })
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue