github.com/theQRL/go-zond@v0.2.1/cmd/devp2p/internal/zondtest/large.go (about)

     1  // Copyright 2020 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  	"crypto/rand"
    23  	"math/big"
    24  
    25  	"github.com/theQRL/go-zond/common"
    26  	"github.com/theQRL/go-zond/common/hexutil"
    27  	"github.com/theQRL/go-zond/core/types"
    28  )
    29  
    30  // largeNumber returns a very large big.Int.
    31  func largeNumber(megabytes int) *big.Int {
    32  	buf := make([]byte, megabytes*1024*1024)
    33  	rand.Read(buf)
    34  	bigint := new(big.Int)
    35  	bigint.SetBytes(buf)
    36  	return bigint
    37  }
    38  
    39  // largeBuffer returns a very large buffer.
    40  func largeBuffer(megabytes int) []byte {
    41  	buf := make([]byte, megabytes*1024*1024)
    42  	rand.Read(buf)
    43  	return buf
    44  }
    45  
    46  // largeString returns a very large string.
    47  func largeString(megabytes int) string {
    48  	buf := make([]byte, megabytes*1024*1024)
    49  	rand.Read(buf)
    50  	return hexutil.Encode(buf)
    51  }
    52  
    53  func largeBlock() *types.Block {
    54  	return types.NewBlockWithHeader(largeHeader())
    55  }
    56  
    57  // Returns a random hash
    58  func randHash() common.Hash {
    59  	var h common.Hash
    60  	rand.Read(h[:])
    61  	return h
    62  }
    63  
    64  func largeHeader() *types.Header {
    65  	return &types.Header{
    66  		Random:      randHash(),
    67  		ReceiptHash: randHash(),
    68  		TxHash:      randHash(),
    69  		Extra:       []byte{},
    70  		Bloom:       types.Bloom{},
    71  		GasUsed:     0,
    72  		Coinbase:    common.Address{},
    73  		GasLimit:    0,
    74  		Time:        1337,
    75  		ParentHash:  randHash(),
    76  		Root:        randHash(),
    77  		Number:      largeNumber(2),
    78  	}
    79  }
    80  */