vm: make PUSH0 create empty bytearray

Also make tests expect []byte{} instead of 0.
This commit is contained in:
Evgenii Stratonikov 2019-09-12 11:42:27 +03:00
parent 66501f9ef9
commit 09e197eaf3
7 changed files with 14 additions and 14 deletions

View file

@ -26,7 +26,7 @@ var binaryExprTestCases = []testCase{
return x
}
`,
big.NewInt(0),
[]byte{},
},
{
"simple div",
@ -86,7 +86,7 @@ var binaryExprTestCases = []testCase{
return 0
}
`,
big.NewInt(0),
[]byte{},
},
{
"compare equal strings with eql",
@ -128,7 +128,7 @@ var binaryExprTestCases = []testCase{
return 0
}
`,
big.NewInt(0),
[]byte{},
},
{
"compare equal ints with eql",
@ -156,7 +156,7 @@ var binaryExprTestCases = []testCase{
return 0
}
`,
big.NewInt(0),
[]byte{},
},
{
"compare not equal ints with eql",
@ -170,7 +170,7 @@ var binaryExprTestCases = []testCase{
return 0
}
`,
big.NewInt(0),
[]byte{},
},
{
"compare not equal ints with neq",

View file

@ -275,7 +275,7 @@ func TestIfUnaryInvert(t *testing.T) {
return 0
}
`
eval(t, src, big.NewInt(0))
eval(t, src, []byte{})
}
func TestAppendByte(t *testing.T) {

View file

@ -35,7 +35,7 @@ func TestNotAssignedFunctionCall(t *testing.T) {
return 0
}
`
eval(t, src, big.NewInt(0))
eval(t, src, []byte{})
}
func TestMultipleFunctionCalls(t *testing.T) {

View file

@ -30,7 +30,7 @@ func TestGT(t *testing.T) {
return 0
}
`
eval(t, src, big.NewInt(0))
eval(t, src, []byte{})
}
func TestGTE(t *testing.T) {
@ -44,7 +44,7 @@ func TestGTE(t *testing.T) {
return 0
}
`
eval(t, src, big.NewInt(0))
eval(t, src, []byte{})
}
func TestLAND(t *testing.T) {
@ -89,5 +89,5 @@ func TestNestedIF(t *testing.T) {
return 0
}
`
eval(t, src, big.NewInt(0))
eval(t, src, []byte{})
}

View file

@ -32,7 +32,7 @@ func TestImportStruct(t *testing.T) {
return b.Y
}
`
eval(t, src, big.NewInt(0))
eval(t, src, []byte{})
}
func TestMultipleDirFileImport(t *testing.T) {

View file

@ -179,7 +179,7 @@ var structTestCases = []testCase{
return t.y
}
`,
big.NewInt(0),
[]byte{},
},
{
"test return struct from func",
@ -209,7 +209,7 @@ var structTestCases = []testCase{
vm.NewBigIntegerItem(1),
vm.NewBigIntegerItem(2),
vm.NewByteArrayItem([]byte("hello")),
vm.NewBigIntegerItem(0),
vm.NewByteArrayItem([]byte{}),
},
},
{

View file

@ -257,7 +257,7 @@ func (v *VM) execute(ctx *Context, op Instruction) {
v.estack.PushVal(val)
case PUSH0:
v.estack.PushVal(0)
v.estack.PushVal([]byte{})
case PUSHDATA1:
n := ctx.readByte()