forked from TrueCloudLab/neoneo-go
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.
|
||||
case opcode.INVERT:
|
||||
// inplace
|
||||
a := v.estack.Peek(0).BigInt()
|
||||
a.Not(a)
|
||||
e := v.estack.Peek(0)
|
||||
i := e.BigInt()
|
||||
e.value = makeStackItem(i.Not(i))
|
||||
|
||||
case opcode.AND:
|
||||
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())
|
||||
}
|
||||
|
||||
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) {
|
||||
prog := makeProgram(opcode.CAT)
|
||||
vm := load(prog)
|
||||
|
|
Loading…
Reference in a new issue