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

Function TestInfiniteLoopCrash

smartcontract/test/infinite_loop_test.go:32–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30)
31
32func TestInfiniteLoopCrash(t *testing.T) {
33 evilBytecode := []byte(" e\xff\u007f\xffhm\xb7%\xa7AAAAAAAAAAAAAAAC\xef\xed\x04INVERT\x95ve")
34 dbFile := "test"
35 defer func() {
36 os.RemoveAll(dbFile)
37 }()
38 //testLevelDB, err := leveldbstore.NewLevelDBStore(dbFile)
39 //if err != nil {
40 // t.Fatal(err)
41 //}
42 //store := statestore.NewMemDatabase()
43 //testBatch := statestore.NewStateStoreBatch(store, testLevelDB)
44 config := &Config{
45 Time: 10,
46 Height: 10,
47 Tx: &types.Transaction{},
48 }
49 sc := SmartContract{
50 Config: config,
51 Gas: 10000,
52 CacheDB: nil,
53 }
54 engine, err := sc.NewExecuteEngine(evilBytecode, types.InvokeNeo)
55 if err != nil {
56 t.Fatal(err)
57 }
58 _, err = engine.Invoke()
59
60 assert.NotNil(t, err)
61}

Callers

nothing calls this directly

Calls 3

NewExecuteEngineMethod · 0.95
FatalMethod · 0.80
InvokeMethod · 0.65

Tested by

no test coverage detected