forked from TrueCloudLab/neoneo-go
pkg/vm: fix all GolangCI warnings about v.executeOp errcheck
Fixes lots of warnings like this in the test code: Error return value of v.executeOp is not checked (from errcheck)
This commit is contained in:
parent
a4b2bb268e
commit
0258fa48f8
5 changed files with 110 additions and 55 deletions
|
@ -20,7 +20,8 @@ func TestInvertOp(t *testing.T) {
|
|||
ctx.Estack.Push(a)
|
||||
|
||||
// 1111 11001 = -6 (two complement representation)
|
||||
v.executeOp(stack.INVERT, ctx)
|
||||
_, err = v.executeOp(stack.INVERT, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -47,7 +48,8 @@ func TestAndOp(t *testing.T) {
|
|||
ctx.Estack.Push(a).Push(b)
|
||||
|
||||
// 100001 = 33
|
||||
v.executeOp(stack.AND, ctx)
|
||||
_, err = v.executeOp(stack.AND, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -74,7 +76,8 @@ func TestOrOp(t *testing.T) {
|
|||
ctx.Estack.Push(a).Push(b)
|
||||
|
||||
// 110011 = 51 (49 OR 35)
|
||||
v.executeOp(stack.OR, ctx)
|
||||
_, err = v.executeOp(stack.OR, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -101,7 +104,8 @@ func TestXorOp(t *testing.T) {
|
|||
ctx.Estack.Push(a).Push(b)
|
||||
|
||||
// 010010 = 18 (49 XOR 35)
|
||||
v.executeOp(stack.XOR, ctx)
|
||||
_, err = v.executeOp(stack.XOR, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -125,7 +129,8 @@ func TestEqualOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a).Push(b)
|
||||
|
||||
v.executeOp(stack.EQUAL, ctx)
|
||||
_, err = v.executeOp(stack.EQUAL, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
|
|
@ -18,7 +18,8 @@ func TestNopOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a)
|
||||
|
||||
v.executeOp(stack.NOP, ctx)
|
||||
_, err = v.executeOp(stack.NOP, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -46,7 +47,8 @@ func TestJmpOp(t *testing.T) {
|
|||
// ctx.ip will be set to offset.
|
||||
// offset = ctx.IP() + int(ctx.ReadInt16()) - 3
|
||||
// = 0 + 5 -3 = 2
|
||||
v.executeOp(stack.JMP, ctx)
|
||||
_, err = v.executeOp(stack.JMP, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -75,7 +77,8 @@ func TestJmpIfOp1(t *testing.T) {
|
|||
// on top of the stack.
|
||||
// offset = ctx.IP() + int(ctx.ReadInt16()) - 3
|
||||
// = 0 + 5 -3 = 2
|
||||
v.executeOp(stack.JMPIF, ctx)
|
||||
_, err := v.executeOp(stack.JMPIF, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have 0 item
|
||||
assert.Equal(t, 0, ctx.Estack.Len())
|
||||
|
@ -102,7 +105,8 @@ func TestJmpIfOp2(t *testing.T) {
|
|||
// nothing will happen because
|
||||
// the value of the boolean on top of the stack
|
||||
// is false
|
||||
v.executeOp(stack.JMPIF, ctx)
|
||||
_, err := v.executeOp(stack.JMPIF, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have 0 item
|
||||
assert.Equal(t, 0, ctx.Estack.Len())
|
||||
|
@ -129,7 +133,8 @@ func TestJmpIfNotOp1(t *testing.T) {
|
|||
// nothing will happen because
|
||||
// the value of the boolean on top of the stack
|
||||
// is true
|
||||
v.executeOp(stack.JMPIFNOT, ctx)
|
||||
_, err := v.executeOp(stack.JMPIFNOT, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have 0 item
|
||||
assert.Equal(t, 0, ctx.Estack.Len())
|
||||
|
@ -158,7 +163,8 @@ func TestJmpIfNotOp2(t *testing.T) {
|
|||
// on top of the stack.
|
||||
// offset = ctx.IP() + int(ctx.ReadInt16()) - 3
|
||||
// = 0 + 5 -3 = 2
|
||||
v.executeOp(stack.JMPIFNOT, ctx)
|
||||
_, err := v.executeOp(stack.JMPIFNOT, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 0, ctx.Estack.Len())
|
||||
|
|
|
@ -18,7 +18,8 @@ func TestIncOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a)
|
||||
|
||||
v.executeOp(stack.INC, ctx)
|
||||
_, err = v.executeOp(stack.INC, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -39,7 +40,8 @@ func TestDecOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a)
|
||||
|
||||
v.executeOp(stack.DEC, ctx)
|
||||
_, err = v.executeOp(stack.DEC, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -63,7 +65,8 @@ func TestAddOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a).Push(b)
|
||||
|
||||
v.executeOp(stack.ADD, ctx)
|
||||
_, err = v.executeOp(stack.ADD, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -88,7 +91,8 @@ func TestSubOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a).Push(b)
|
||||
|
||||
v.executeOp(stack.SUB, ctx)
|
||||
_, err = v.executeOp(stack.SUB, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -113,7 +117,8 @@ func TestDivOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a).Push(b)
|
||||
|
||||
v.executeOp(stack.DIV, ctx)
|
||||
_, err = v.executeOp(stack.DIV, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -137,7 +142,8 @@ func TestModOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a).Push(b)
|
||||
|
||||
v.executeOp(stack.MOD, ctx)
|
||||
_, err = v.executeOp(stack.MOD, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -158,7 +164,8 @@ func TestNzOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a)
|
||||
|
||||
v.executeOp(stack.NZ, ctx)
|
||||
_, err = v.executeOp(stack.NZ, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -182,7 +189,8 @@ func TestMulOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a).Push(b)
|
||||
|
||||
v.executeOp(stack.MUL, ctx)
|
||||
_, err = v.executeOp(stack.MUL, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -203,7 +211,8 @@ func TestAbsOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a)
|
||||
|
||||
v.executeOp(stack.ABS, ctx)
|
||||
_, err = v.executeOp(stack.ABS, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -223,7 +232,8 @@ func TestNotOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(b)
|
||||
|
||||
v.executeOp(stack.NOT, ctx)
|
||||
_, err := v.executeOp(stack.NOT, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -247,7 +257,8 @@ func TestNumEqual(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a).Push(b)
|
||||
|
||||
v.executeOp(stack.NUMEQUAL, ctx)
|
||||
_, err = v.executeOp(stack.NUMEQUAL, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -271,7 +282,8 @@ func TestNumNotEqual(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a).Push(b)
|
||||
|
||||
v.executeOp(stack.NUMNOTEQUAL, ctx)
|
||||
_, err = v.executeOp(stack.NUMNOTEQUAL, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -292,7 +304,8 @@ func TestSignOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a)
|
||||
|
||||
v.executeOp(stack.SIGN, ctx)
|
||||
_, err = v.executeOp(stack.SIGN, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -313,7 +326,8 @@ func TestNegateOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a)
|
||||
|
||||
v.executeOp(stack.NEGATE, ctx)
|
||||
_, err = v.executeOp(stack.NEGATE, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -342,7 +356,8 @@ func TestLteOp(t *testing.T) {
|
|||
// we perform a <= b and place
|
||||
// the result on top of the evaluation
|
||||
// stack
|
||||
v.executeOp(stack.LTE, ctx)
|
||||
_, err = v.executeOp(stack.LTE, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -371,7 +386,8 @@ func TestGteOp(t *testing.T) {
|
|||
// we perform a >= b and place
|
||||
// the result on top of the evaluation
|
||||
// stack
|
||||
v.executeOp(stack.GTE, ctx)
|
||||
_, err = v.executeOp(stack.GTE, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -400,7 +416,8 @@ func TestShlOp(t *testing.T) {
|
|||
// we perform a.Lsh(b) and place
|
||||
// the result on top of the evaluation
|
||||
// stack
|
||||
v.executeOp(stack.SHL, ctx)
|
||||
_, err = v.executeOp(stack.SHL, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -429,7 +446,8 @@ func TestShrOp(t *testing.T) {
|
|||
// we perform a.Rsh(b) and place
|
||||
// the result on top of the evaluation
|
||||
// stack
|
||||
v.executeOp(stack.SHR, ctx)
|
||||
_, err = v.executeOp(stack.SHR, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -450,7 +468,8 @@ func TestBoolAndOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a).Push(b)
|
||||
|
||||
v.executeOp(stack.BOOLAND, ctx)
|
||||
_, err := v.executeOp(stack.BOOLAND, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -471,7 +490,8 @@ func TestBoolOrOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a).Push(b)
|
||||
|
||||
v.executeOp(stack.BOOLOR, ctx)
|
||||
_, err := v.executeOp(stack.BOOLOR, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -500,7 +520,8 @@ func TestLtOp(t *testing.T) {
|
|||
// we perform a < b and place
|
||||
// the result on top of the evaluation
|
||||
// stack
|
||||
v.executeOp(stack.LT, ctx)
|
||||
_, err = v.executeOp(stack.LT, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -529,7 +550,8 @@ func TestGtOp(t *testing.T) {
|
|||
// we perform a > b and place
|
||||
// the result on top of the evaluation
|
||||
// stack
|
||||
v.executeOp(stack.GT, ctx)
|
||||
_, err = v.executeOp(stack.GT, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -553,7 +575,8 @@ func TestMinOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a).Push(b)
|
||||
|
||||
v.executeOp(stack.MIN, ctx)
|
||||
_, err = v.executeOp(stack.MIN, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -577,7 +600,8 @@ func TestMaxOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a).Push(b)
|
||||
|
||||
v.executeOp(stack.MAX, ctx)
|
||||
_, err = v.executeOp(stack.MAX, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -611,7 +635,8 @@ func TestWithinOp(t *testing.T) {
|
|||
// whose value is true, on top of the evaluation
|
||||
// stack. Otherwise we place a boolean with
|
||||
// false value.
|
||||
v.executeOp(stack.WITHIN, ctx)
|
||||
_, err = v.executeOp(stack.WITHIN, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
|
|
@ -32,7 +32,8 @@ func TestRollOp(t *testing.T) {
|
|||
// has index len(stack)-n-1 (= 3-2-1= 0)
|
||||
// onto the top stack item.
|
||||
// The final stack will be [b,c,a]
|
||||
v.executeOp(stack.ROLL, ctx)
|
||||
_, err = v.executeOp(stack.ROLL, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have three items
|
||||
assert.Equal(t, 3, ctx.Estack.Len())
|
||||
|
@ -69,7 +70,8 @@ func TestRotOp(t *testing.T) {
|
|||
// move the third top stack a item onto
|
||||
// the top stack item c.
|
||||
// The final stack will be [b,c,a]
|
||||
v.executeOp(stack.ROT, ctx)
|
||||
_, err = v.executeOp(stack.ROT, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have three items
|
||||
assert.Equal(t, 3, ctx.Estack.Len())
|
||||
|
@ -103,7 +105,8 @@ func TestSwapOp(t *testing.T) {
|
|||
|
||||
// Swaps the top two stack items.
|
||||
// The final stack will be [b,a]
|
||||
v.executeOp(stack.SWAP, ctx)
|
||||
_, err = v.executeOp(stack.SWAP, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have two items
|
||||
assert.Equal(t, 2, ctx.Estack.Len())
|
||||
|
@ -138,7 +141,8 @@ func TestTuckOp(t *testing.T) {
|
|||
// copy the top stack item c and
|
||||
// inserts it before the second top stack item.
|
||||
// The final stack will be [a,c,b,c]
|
||||
v.executeOp(stack.TUCK, ctx)
|
||||
_, err = v.executeOp(stack.TUCK, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have four items
|
||||
assert.Equal(t, 4, ctx.Estack.Len())
|
||||
|
@ -172,7 +176,8 @@ func TestDupOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a)
|
||||
|
||||
v.executeOp(stack.DUP, ctx)
|
||||
_, err = v.executeOp(stack.DUP, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have two items
|
||||
assert.Equal(t, 2, ctx.Estack.Len())
|
||||
|
@ -204,7 +209,8 @@ func TestNipOp(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(a).Push(b).Push(c)
|
||||
|
||||
v.executeOp(stack.NIP, ctx)
|
||||
_, err = v.executeOp(stack.NIP, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have two items
|
||||
assert.Equal(t, 2, ctx.Estack.Len())
|
||||
|
@ -236,7 +242,8 @@ func TestOverOp(t *testing.T) {
|
|||
// OVER copies the second top stack item a
|
||||
// onto the top stack item b.
|
||||
// the new stack will be [a,b,a].
|
||||
v.executeOp(stack.OVER, ctx)
|
||||
_, err = v.executeOp(stack.OVER, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have three items
|
||||
assert.Equal(t, 3, ctx.Estack.Len())
|
||||
|
@ -280,7 +287,8 @@ func TestPickOp(t *testing.T) {
|
|||
// has index len(stack)-n-1 (= 3-2-1= 0)
|
||||
// onto the top stack item.
|
||||
// The final stack will be [a,b,c,a]
|
||||
v.executeOp(stack.PICK, ctx)
|
||||
_, err = v.executeOp(stack.PICK, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have four items
|
||||
assert.Equal(t, 4, ctx.Estack.Len())
|
||||
|
@ -327,7 +335,8 @@ func TestXswapOp(t *testing.T) {
|
|||
// is located in position len(stack)-n-1 (= 3-2-1= 0)
|
||||
// with the top stack item.
|
||||
// The final stack will be [c,b,a]
|
||||
v.executeOp(stack.XSWAP, ctx)
|
||||
_, err = v.executeOp(stack.XSWAP, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have three items
|
||||
assert.Equal(t, 3, ctx.Estack.Len())
|
||||
|
@ -370,7 +379,8 @@ func TestXTuckOp(t *testing.T) {
|
|||
// and insert the top stack item c
|
||||
// to the position len(stack)-n (= 3-2 = 1)
|
||||
// of the stack.The final stack will be [a,c,b,c]
|
||||
v.executeOp(stack.XTUCK, ctx)
|
||||
_, err = v.executeOp(stack.XTUCK, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have four items
|
||||
assert.Equal(t, 4, ctx.Estack.Len())
|
||||
|
@ -410,7 +420,8 @@ func TestXDepthOp(t *testing.T) {
|
|||
|
||||
// push integer whose value is len(stack) (2)
|
||||
// on top of the stack
|
||||
v.executeOp(stack.DEPTH, ctx)
|
||||
_, err = v.executeOp(stack.DEPTH, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have three items
|
||||
assert.Equal(t, 3, ctx.Estack.Len())
|
||||
|
@ -444,7 +455,8 @@ func TestDupFromAltStackOp(t *testing.T) {
|
|||
ctx.Estack.Push(a)
|
||||
ctx.Astack.Push(b)
|
||||
|
||||
v.executeOp(stack.DUPFROMALTSTACK, ctx)
|
||||
_, err = v.executeOp(stack.DUPFROMALTSTACK, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
assert.Equal(t, 1, ctx.Astack.Len())
|
||||
assert.Equal(t, 2, ctx.Estack.Len())
|
||||
|
@ -473,7 +485,8 @@ func TestToAltStackOp(t *testing.T) {
|
|||
ctx.Estack.Push(a)
|
||||
ctx.Astack.Push(b)
|
||||
|
||||
v.executeOp(stack.TOALTSTACK, ctx)
|
||||
_, err = v.executeOp(stack.TOALTSTACK, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
assert.Equal(t, 2, ctx.Astack.Len())
|
||||
assert.Equal(t, 0, ctx.Estack.Len())
|
||||
|
@ -498,7 +511,8 @@ func TestFromAltStackOp(t *testing.T) {
|
|||
ctx.Estack.Push(a)
|
||||
ctx.Astack.Push(b)
|
||||
|
||||
v.executeOp(stack.FROMALTSTACK, ctx)
|
||||
_, err = v.executeOp(stack.FROMALTSTACK, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
assert.Equal(t, 0, ctx.Astack.Len())
|
||||
assert.Equal(t, 2, ctx.Estack.Len())
|
||||
|
@ -537,7 +551,8 @@ func TestXDropOp(t *testing.T) {
|
|||
// len(stack)-n-1 = 3-2-1 = 0.
|
||||
// Therefore a is removed from the stack.
|
||||
// Only b, c remain on the stack.
|
||||
v.executeOp(stack.XDROP, ctx)
|
||||
_, err = v.executeOp(stack.XDROP, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
assert.Equal(t, 2, ctx.Estack.Len())
|
||||
|
||||
|
|
|
@ -17,7 +17,8 @@ func TestSha1Op(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(ba1)
|
||||
|
||||
v.executeOp(stack.SHA1, ctx)
|
||||
_, err := v.executeOp(stack.SHA1, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -40,7 +41,8 @@ func TestSha256Op(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(ba1)
|
||||
|
||||
v.executeOp(stack.SHA256, ctx)
|
||||
_, err := v.executeOp(stack.SHA256, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -63,7 +65,8 @@ func TestHash160Op(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(ba1)
|
||||
|
||||
v.executeOp(stack.HASH160, ctx)
|
||||
_, err := v.executeOp(stack.HASH160, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
@ -86,7 +89,8 @@ func TestHash256Op(t *testing.T) {
|
|||
ctx := stack.NewContext([]byte{})
|
||||
ctx.Estack.Push(ba1)
|
||||
|
||||
v.executeOp(stack.HASH256, ctx)
|
||||
_, err := v.executeOp(stack.HASH256, ctx)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Stack should have one item
|
||||
assert.Equal(t, 1, ctx.Estack.Len())
|
||||
|
|
Loading…
Reference in a new issue