(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestComplexOpcodes(t *testing.T) { |
| 12 | var emptySeed = make([]byte, 32) |
| 13 | |
| 14 | cases := []struct { |
| 15 | name string |
| 16 | preCon stack // items on the vm stack before op is run |
| 17 | preArg stack // items on the arg stack |
| 18 | |
| 19 | prog []byte // code to be run |
| 20 | |
| 21 | postCon stack // contract stack after execution, from bottom -> top of stack |
| 22 | postArg stack |
| 23 | log []string // storing as a []string for ease of populating test cases, actual log is []Tuple |
| 24 | wanterr error // check only if postCon, postArg, log are nil |
| 25 | }{ |
| 26 | /* STACK INSTRUCTIONS */ |
| 27 | { |
| 28 | name: "put bytes", |
| 29 | preCon: stack{Bytes("hello")}, |
| 30 | preArg: stack{Bytes("bye")}, |
| 31 | prog: []byte{op.Put}, |
| 32 | postArg: stack{Bytes("bye"), Bytes("hello")}, |
| 33 | }, |
| 34 | { |
| 35 | name: "put ints", |
| 36 | preCon: stack{Int(2)}, |
| 37 | preArg: stack{Int(3)}, |
| 38 | prog: []byte{op.Put}, |
| 39 | postArg: stack{Int(3), Int(2)}, |
| 40 | }, |
| 41 | { |
| 42 | name: "put tuples", |
| 43 | preCon: stack{Tuple{Int(2), Bytes("tew")}}, |
| 44 | preArg: stack{Tuple{Bytes("i am argstack")}}, |
| 45 | prog: []byte{op.Put}, |
| 46 | postArg: stack{Tuple{Bytes("i am argstack")}, Tuple{Int(2), Bytes("tew")}}, |
| 47 | }, |
| 48 | { |
| 49 | name: "put fail", |
| 50 | prog: []byte{op.Put}, |
| 51 | wanterr: ErrUnderflow, |
| 52 | }, |
| 53 | { |
| 54 | name: "get bytes", |
| 55 | preCon: stack{Bytes("hello")}, |
| 56 | preArg: stack{Bytes("bye")}, |
| 57 | prog: []byte{op.Get}, |
| 58 | postCon: stack{Bytes("hello"), Bytes("bye")}, |
| 59 | }, |
| 60 | { |
| 61 | name: "get ints", |
| 62 | preCon: stack{Int(2)}, |
| 63 | preArg: stack{Int(3)}, |
| 64 | prog: []byte{op.Get}, |
| 65 | postCon: stack{Int(2), Int(3)}, |
| 66 | }, |
| 67 | { |
| 68 | name: "get tuples", |
nothing calls this directly
no test coverage detected