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

Function TestScript_RemoveOpCodeByIndex

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

Source from the content-addressed store, hash-verified

253}
254
255func TestScript_RemoveOpCodeByIndex(t *testing.T) {
256 tests := []struct {
257 name string
258 before []byte
259 remove int
260 after []byte
261 }{
262 {
263 // Nothing to remove.
264 name: "nothing to remove",
265 before: []byte{OP_NOP},
266 remove: 0,
267 after: []byte{},
268 },
269 {
270 // Test basic opcode removal.
271 name: "codeseparator 1",
272 before: []byte{OP_NOP, OP_CODESEPARATOR, OP_TRUE},
273 remove: 1,
274 after: []byte{OP_NOP, OP_TRUE},
275 },
276 }
277
278 for _, v := range tests {
279 value := v
280
281 testScript := NewScriptRaw(value.before)
282 afterRemove := testScript.RemoveOpCodeByIndex(value.remove)
283 wantScript := NewScriptRaw(value.after)
284
285 assert.Equal(t, wantScript, afterRemove, value.name)
286 }
287}
288
289func TestScript_IsCommitment(t *testing.T) {
290 scriptRaw := []byte{0x6a, 0x13, 0xe1, 0x2a, 0x40, 0xd4, 0xa2, 0x21, 0x8d, 0x33, 0xf2,

Callers

nothing calls this directly

Calls 3

NewScriptRawFunction · 0.85
RemoveOpCodeByIndexMethod · 0.80
EqualMethod · 0.45

Tested by

no test coverage detected