MCPcopy Create free account
hub / github.com/copernet/copernicus / TestScript_RemoveOpcode

Function TestScript_RemoveOpcode

model/script/script_test.go:146–178  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

144}
145
146func TestScript_RemoveOpcode(t *testing.T) {
147 tests := []struct {
148 name string
149 before []byte
150 remove byte
151 after []byte
152 }{
153 {
154 // Nothing to remove.
155 name: "nothing to remove",
156 before: []byte{OP_NOP},
157 remove: OP_CODESEPARATOR,
158 after: []byte{OP_NOP},
159 },
160 {
161 // Test basic opcode removal.
162 name: "codeseparator 1",
163 before: []byte{OP_NOP, OP_CODESEPARATOR, OP_TRUE},
164 remove: OP_CODESEPARATOR,
165 after: []byte{OP_NOP, OP_TRUE},
166 },
167 }
168
169 for _, v := range tests {
170 value := v
171
172 testScript := NewScriptRaw(value.before)
173 afterRemove := testScript.RemoveOpcode(value.remove)
174 wantScript := NewScriptRaw(value.after)
175
176 assert.Equal(t, wantScript, afterRemove, value.name)
177 }
178}
179
180func TestScript_RemoveOpcodeByData(t *testing.T) {
181 tests := []struct {

Callers

nothing calls this directly

Calls 3

NewScriptRawFunction · 0.85
RemoveOpcodeMethod · 0.80
EqualMethod · 0.45

Tested by

no test coverage detected