mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 19:42:23 +00:00
vm: fix INVERT behaviour for converted values
Tests added were failing before this change.
This commit is contained in:
parent
4b4e492954
commit
c596a6b273
2 changed files with 17 additions and 2 deletions
|
@ -677,8 +677,9 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro
|
||||||
// Bit operations.
|
// Bit operations.
|
||||||
case opcode.INVERT:
|
case opcode.INVERT:
|
||||||
// inplace
|
// inplace
|
||||||
a := v.estack.Peek(0).BigInt()
|
e := v.estack.Peek(0)
|
||||||
a.Not(a)
|
i := e.BigInt()
|
||||||
|
e.value = makeStackItem(i.Not(i))
|
||||||
|
|
||||||
case opcode.AND:
|
case opcode.AND:
|
||||||
b := v.estack.Pop().BigInt()
|
b := v.estack.Pop().BigInt()
|
||||||
|
|
|
@ -1759,6 +1759,20 @@ func TestINVERTgood3(t *testing.T) {
|
||||||
assert.Equal(t, int64(-0x6A), vm.estack.Peek(0).BigInt().Int64())
|
assert.Equal(t, int64(-0x6A), vm.estack.Peek(0).BigInt().Int64())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestINVERTWithConversion1(t *testing.T) {
|
||||||
|
prog := makeProgram(opcode.PUSHDATA2, 0, 0, opcode.INVERT)
|
||||||
|
vm := load(prog)
|
||||||
|
runVM(t, vm)
|
||||||
|
assert.Equal(t, int64(-1), vm.estack.Peek(0).BigInt().Int64())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestINVERTWithConversion2(t *testing.T) {
|
||||||
|
prog := makeProgram(opcode.PUSH0, opcode.PUSH1, opcode.NUMEQUAL, opcode.INVERT)
|
||||||
|
vm := load(prog)
|
||||||
|
runVM(t, vm)
|
||||||
|
assert.Equal(t, int64(-1), vm.estack.Peek(0).BigInt().Int64())
|
||||||
|
}
|
||||||
|
|
||||||
func TestCATBadNoArgs(t *testing.T) {
|
func TestCATBadNoArgs(t *testing.T) {
|
||||||
prog := makeProgram(opcode.CAT)
|
prog := makeProgram(opcode.CAT)
|
||||||
vm := load(prog)
|
vm := load(prog)
|
||||||
|
|
Loading…
Reference in a new issue