github.com/theQRL/go-zond@v0.2.1/cmd/devp2p/internal/zondtest/suite_test.go (about) 1 // Copyright 2021 The go-ethereum Authors 2 // This file is part of go-ethereum. 3 // 4 // go-ethereum is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // go-ethereum is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. 16 17 package zondtest 18 19 // TODO(now.youtrack.cloud/issue/TGZ-6) 20 /* 21 import ( 22 "time" 23 24 "github.com/theQRL/go-zond/node" 25 "github.com/theQRL/go-zond/p2p" 26 "github.com/theQRL/go-zond/zond" 27 "github.com/theQRL/go-zond/zond/zondconfig" 28 ) 29 30 var ( 31 genesisFile = "./testdata/genesis.json" 32 halfchainFile = "./testdata/halfchain.rlp" 33 fullchainFile = "./testdata/chain.rlp" 34 ) 35 36 TODO(now.youtrack.cloud/issue/TGZ-6) 37 /* 38 func TestZondSuite(t *testing.T) { 39 gzond, err := runGzond() 40 if err != nil { 41 t.Fatalf("could not run gzond: %v", err) 42 } 43 defer gzond.Close() 44 45 suite, err := NewSuite(gzond.Server().Self(), fullchainFile, genesisFile) 46 if err != nil { 47 t.Fatalf("could not create new test suite: %v", err) 48 } 49 for _, test := range suite.ZondTests() { 50 t.Run(test.Name, func(t *testing.T) { 51 result := utesting.RunTAP([]utesting.Test{{Name: test.Name, Fn: test.Fn}}, os.Stdout) 52 if result[0].Failed { 53 t.Fatal() 54 } 55 }) 56 } 57 } 58 59 func TestSnapSuite(t *testing.T) { 60 gzond, err := runGzond() 61 if err != nil { 62 t.Fatalf("could not run gzond: %v", err) 63 } 64 defer gzond.Close() 65 66 suite, err := NewSuite(gzond.Server().Self(), fullchainFile, genesisFile) 67 if err != nil { 68 t.Fatalf("could not create new test suite: %v", err) 69 } 70 for _, test := range suite.SnapTests() { 71 t.Run(test.Name, func(t *testing.T) { 72 result := utesting.RunTAP([]utesting.Test{{Name: test.Name, Fn: test.Fn}}, os.Stdout) 73 if result[0].Failed { 74 t.Fatal() 75 } 76 }) 77 } 78 } 79 80 // runGzond creates and starts a gzond node 81 func runGzond() (*node.Node, error) { 82 stack, err := node.New(&node.Config{ 83 P2P: p2p.Config{ 84 ListenAddr: "127.0.0.1:0", 85 NoDiscovery: true, 86 MaxPeers: 10, // in case a test requires multiple connections, can be changed in the future 87 NoDial: true, 88 }, 89 }) 90 if err != nil { 91 return nil, err 92 } 93 94 err = setupGzond(stack) 95 if err != nil { 96 stack.Close() 97 return nil, err 98 } 99 if err = stack.Start(); err != nil { 100 stack.Close() 101 return nil, err 102 } 103 return stack, nil 104 } 105 106 func setupGzond(stack *node.Node) error { 107 chain, err := loadChain(halfchainFile, genesisFile) 108 if err != nil { 109 return err 110 } 111 112 backend, err := zond.New(stack, &zondconfig.Config{ 113 Genesis: &chain.genesis, 114 NetworkId: chain.genesis.Config.ChainID.Uint64(), // 19763 115 DatabaseCache: 10, 116 TrieCleanCache: 10, 117 TrieDirtyCache: 16, 118 TrieTimeout: 60 * time.Minute, 119 SnapshotCache: 10, 120 }) 121 if err != nil { 122 return err 123 } 124 125 _, err = backend.BlockChain().InsertChain(chain.blocks[1:]) 126 return err 127 } 128 */