MCPcopy Create free account
hub / github.com/chain/txvm / TestIntrospection

Function TestIntrospection

protocol/txvm/introspection_test.go:10–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestIntrospection(t *testing.T) {
11 cases := []struct {
12 name string
13 version int64
14 runlimit int64
15 seed []byte
16 opcode byte
17 stack stack
18 }{
19 {
20 name: "basic",
21 version: 3,
22 runlimit: 1000,
23 seed: make([]byte, 32),
24 opcode: op.Add,
25 stack: stack{Int(2), Int(10)},
26 },
27 {
28 name: "old",
29 version: 2,
30 runlimit: 50,
31 seed: []byte{0, 13, 0, 1, 0, 1, 15},
32 opcode: op.Put,
33 stack: stack{Int(2), Int(10)},
34 },
35 {
36 name: "new",
37 version: 100,
38 runlimit: 500000000,
39 seed: Bytes("some really long seed string"),
40 opcode: op.Mod,
41 stack: stack{Int(2), Int(10)},
42 },
43 }
44 for _, c := range cases {
45 t.Run(c.name, func(t *testing.T) {
46 v := &VM{
47 txVersion: c.version,
48 runlimit: c.runlimit,
49 contract: &contract{
50 seed: c.seed,
51 program: []byte{c.opcode},
52 stack: c.stack,
53 typecode: ContractCode,
54 },
55 argstack: stack{},
56 caller: emptySeed,
57 opcode: c.opcode,
58 }
59
60 if v.Runlimit() != c.runlimit {
61 t.Fatalf("Runlimit does not match expected. Got %v, wanted %v", v.Runlimit(), c.runlimit)
62 }
63
64 if !testutil.DeepEqual(v.Seed(), c.seed) {
65 t.Fatalf("Seed does not match expected value. Got %v, wanted %v", v.Seed(), c.seed)
66 }
67

Callers

nothing calls this directly

Calls 11

RunlimitMethod · 0.95
SeedMethod · 0.95
VersionMethod · 0.95
StackLenMethod · 0.95
StackItemMethod · 0.95
OpCodeMethod · 0.95
DeepEqualFunction · 0.92
IntTypeAlias · 0.85
BytesTypeAlias · 0.85
uninspectFunction · 0.85
inspectMethod · 0.65

Tested by

no test coverage detected