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

Function TestRandomCodeCrash

smartcontract/test/panic_test.go:40–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38)
39
40func TestRandomCodeCrash(t *testing.T) {
41 log.InitLog(4)
42 defer func() {
43 os.RemoveAll("Log")
44 }()
45
46 config := &Config{
47 Time: 10,
48 Height: 10,
49 Tx: &types.Transaction{},
50 }
51
52 var code []byte
53 defer func() {
54 if err := recover(); err != nil {
55 fmt.Printf("code %x \n", code)
56 }
57 }()
58
59 for i := 1; i < 10; i++ {
60 fmt.Printf("test round:%d \n", i)
61 code := make([]byte, i)
62 for j := 0; j < 10; j++ {
63 rand.Read(code)
64
65 sc := SmartContract{
66 Config: config,
67 Gas: 10000,
68 CacheDB: nil,
69 }
70 engine, _ := sc.NewExecuteEngine(code, types.InvokeNeo)
71 engine.Invoke()
72 }
73 }
74}
75
76func TestOpCodeDUP(t *testing.T) {
77 log.InitLog(4)

Callers

nothing calls this directly

Calls 3

NewExecuteEngineMethod · 0.95
InitLogFunction · 0.92
InvokeMethod · 0.65

Tested by

no test coverage detected