vm: redefine SHL/SHR limits based on integer size

This commit is contained in:
Evgenii Stratonikov 2019-11-07 12:50:11 +03:00
parent 439cd72294
commit 816d78b5ee
2 changed files with 4 additions and 4 deletions

View file

@ -51,8 +51,8 @@ const (
// on all stacks at once. // on all stacks at once.
MaxStackSize = 2 * 1024 MaxStackSize = 2 * 1024
maxSHLArg = 256 maxSHLArg = MaxBigIntegerSizeBits
minSHLArg = -256 minSHLArg = -MaxBigIntegerSizeBits
) )
// VM represents the virtual machine. // VM represents the virtual machine.

View file

@ -624,7 +624,7 @@ func TestSHRSmallValue(t *testing.T) {
prog := makeProgram(SHR) prog := makeProgram(SHR)
vm := load(prog) vm := load(prog)
vm.estack.PushVal(5) vm.estack.PushVal(5)
vm.estack.PushVal(-257) vm.estack.PushVal(minSHLArg - 1)
checkVMFailed(t, vm) checkVMFailed(t, vm)
} }
@ -660,7 +660,7 @@ func TestSHLBigValue(t *testing.T) {
prog := makeProgram(SHL) prog := makeProgram(SHL)
vm := load(prog) vm := load(prog)
vm.estack.PushVal(5) vm.estack.PushVal(5)
vm.estack.PushVal(257) vm.estack.PushVal(maxSHLArg + 1)
checkVMFailed(t, vm) checkVMFailed(t, vm)
} }