MCPcopy Create free account
hub / github.com/DNAProject/DNA / checkAltStackOpCodeNew

Function checkAltStackOpCodeNew

vm/neovm/stack_opcode_test.go:128–153  ·  view source on GitHub ↗
(t *testing.T, code []byte, origin [2][]Value, expected [2][]Value)

Source from the content-addressed store, hash-verified

126}
127
128func checkAltStackOpCodeNew(t *testing.T, code []byte, origin [2][]Value, expected [2][]Value) {
129 executor := NewExecutor(code, VmFeatureFlag{})
130 for _, val := range origin[0] {
131 err := executor.EvalStack.Push(newVmValue(t, val))
132 assert.Nil(t, err)
133 }
134 for _, val := range origin[1] {
135 err := executor.AltStack.Push(newVmValue(t, val))
136 assert.Nil(t, err)
137 }
138 err := executor.Execute()
139 assert.Nil(t, err)
140 assert.Equal(t, len(expected[0]), executor.EvalStack.Count())
141 assert.Equal(t, len(expected[1]), executor.AltStack.Count())
142
143 stacks := [2]*ValueStack{executor.EvalStack, executor.AltStack}
144 for s, stack := range stacks {
145 expect := expected[s]
146 for i := 0; i < len(expect); i++ {
147 val := expect[len(expect)-i-1]
148 res, _ := stack.Pop()
149 exp := newVmValue(t, val)
150 assertEqual(t, res, exp)
151 }
152 }
153}
154
155func TestAltStackOpCode(t *testing.T) {
156 checkAltStackOpCode(t, DUPFROMALTSTACK, [2][]Value{

Callers 5

checkAltStackOpCodeFunction · 0.85
checkMultiAltStackOpCodeFunction · 0.85
checkMultiOpCodeFunction · 0.85
TestStructValueFunction · 0.85
TestVerifyFunction · 0.85

Calls 7

ExecuteMethod · 0.95
NewExecutorFunction · 0.85
newVmValueFunction · 0.85
assertEqualFunction · 0.85
PushMethod · 0.45
CountMethod · 0.45
PopMethod · 0.45

Tested by

no test coverage detected