2020-11-24 18:09:17 +03:00
|
|
|
// Copyright 2020 The go-ethereum Authors
|
2022-05-24 21:39:40 +03:00
|
|
|
// This file is part of go-ethereum.
|
2020-11-24 18:09:17 +03:00
|
|
|
//
|
2022-05-24 21:39:40 +03:00
|
|
|
// go-ethereum is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
2020-11-24 18:09:17 +03:00
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
2022-05-24 21:39:40 +03:00
|
|
|
// go-ethereum is distributed in the hope that it will be useful,
|
2020-11-24 18:09:17 +03:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2022-05-24 21:39:40 +03:00
|
|
|
// GNU General Public License for more details.
|
2020-11-24 18:09:17 +03:00
|
|
|
//
|
2022-05-24 21:39:40 +03:00
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
2020-11-24 18:09:17 +03:00
|
|
|
|
|
|
|
package ethtest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/rand"
|
|
|
|
"math/big"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
|
|
|
"github.com/ethereum/go-ethereum/core/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// largeNumber returns a very large big.Int.
|
|
|
|
func largeNumber(megabytes int) *big.Int {
|
|
|
|
buf := make([]byte, megabytes*1024*1024)
|
|
|
|
rand.Read(buf)
|
|
|
|
bigint := new(big.Int)
|
|
|
|
bigint.SetBytes(buf)
|
|
|
|
return bigint
|
|
|
|
}
|
|
|
|
|
|
|
|
// largeBuffer returns a very large buffer.
|
|
|
|
func largeBuffer(megabytes int) []byte {
|
|
|
|
buf := make([]byte, megabytes*1024*1024)
|
|
|
|
rand.Read(buf)
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
|
|
|
// largeString returns a very large string.
|
|
|
|
func largeString(megabytes int) string {
|
|
|
|
buf := make([]byte, megabytes*1024*1024)
|
|
|
|
rand.Read(buf)
|
|
|
|
return hexutil.Encode(buf)
|
|
|
|
}
|
|
|
|
|
|
|
|
func largeBlock() *types.Block {
|
|
|
|
return types.NewBlockWithHeader(largeHeader())
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns a random hash
|
|
|
|
func randHash() common.Hash {
|
|
|
|
var h common.Hash
|
|
|
|
rand.Read(h[:])
|
|
|
|
return h
|
|
|
|
}
|
|
|
|
|
|
|
|
func largeHeader() *types.Header {
|
|
|
|
return &types.Header{
|
|
|
|
MixDigest: randHash(),
|
|
|
|
ReceiptHash: randHash(),
|
|
|
|
TxHash: randHash(),
|
|
|
|
Nonce: types.BlockNonce{},
|
|
|
|
Extra: []byte{},
|
|
|
|
Bloom: types.Bloom{},
|
|
|
|
GasUsed: 0,
|
|
|
|
Coinbase: common.Address{},
|
|
|
|
GasLimit: 0,
|
2021-04-28 09:48:07 +03:00
|
|
|
UncleHash: types.EmptyUncleHash,
|
2020-11-24 18:09:17 +03:00
|
|
|
Time: 1337,
|
|
|
|
ParentHash: randHash(),
|
|
|
|
Root: randHash(),
|
|
|
|
Number: largeNumber(2),
|
|
|
|
Difficulty: largeNumber(2),
|
|
|
|
}
|
|
|
|
}
|