mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
fix : test-integration
This commit is contained in:
parent
a8e85c4f87
commit
54acb92cb4
4 changed files with 33 additions and 15 deletions
|
|
@ -589,6 +589,15 @@ func (g *Genesis) MustCommit(db ethdb.Database) *types.Block {
|
|||
return block
|
||||
}
|
||||
|
||||
// GenesisBlockForTesting creates and writes a block in which addr has the given wei balance.
|
||||
func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big.Int) *types.Block {
|
||||
g := Genesis{
|
||||
Alloc: GenesisAlloc{addr: {Balance: balance}},
|
||||
BaseFee: big.NewInt(params.InitialBaseFee),
|
||||
}
|
||||
return g.MustCommit(db)
|
||||
}
|
||||
|
||||
// DefaultGenesisBlock returns the Ethereum main net genesis block.
|
||||
func DefaultGenesisBlock() *Genesis {
|
||||
return &Genesis{
|
||||
|
|
|
|||
|
|
@ -103,13 +103,8 @@ func (b *TestBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (b *TestBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error) {
|
||||
number := rawdb.ReadHeaderNumber(b.DB, hash)
|
||||
if number == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
receipts := rawdb.ReadReceipts(b.DB, hash, *number, params.TestChainConfig)
|
||||
func (b *TestBackend) GetLogs(ctx context.Context, hash common.Hash, number uint64) ([][]*types.Log, error) {
|
||||
receipts := rawdb.ReadReceipts(b.DB, hash, number, params.TestChainConfig)
|
||||
|
||||
logs := make([][]*types.Log, len(receipts))
|
||||
for i, receipt := range receipts {
|
||||
|
|
@ -175,3 +170,15 @@ func (b *TestBackend) ServiceFilter(ctx context.Context, session *bloombits.Matc
|
|||
func (b *TestBackend) SubscribeStateSyncEvent(ch chan<- core.StateSyncEvent) event.Subscription {
|
||||
return b.stateSyncFeed.Subscribe(ch)
|
||||
}
|
||||
|
||||
func (b *TestBackend) ChainConfig() *params.ChainConfig { panic("not implemented") }
|
||||
|
||||
func (b *TestBackend) CurrentHeader() *types.Header { panic("not implemented") }
|
||||
|
||||
func (b *TestBackend) GetBody(context.Context, common.Hash, rpc.BlockNumber) (*types.Body, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (b *TestBackend) PendingBlockAndReceipts() (*types.Block, types.Receipts) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func areDifferentHashes(receipts []map[string]interface{}) bool {
|
|||
}
|
||||
|
||||
// Test for GetTransactionReceiptsByBlock
|
||||
func testGetTransactionReceiptsByBlock(t *testing.T, publicBlockchainAPI *ethapi.PublicBlockChainAPI) {
|
||||
func testGetTransactionReceiptsByBlock(t *testing.T, publicBlockchainAPI *ethapi.BlockChainAPI) {
|
||||
// check 1 : zero transactions
|
||||
receiptsOut, err := publicBlockchainAPI.GetTransactionReceiptsByBlock(context.Background(), rpc.BlockNumberOrHashWithNumber(1))
|
||||
if err != nil {
|
||||
|
|
@ -101,7 +101,7 @@ func testGetTransactionReceiptsByBlock(t *testing.T, publicBlockchainAPI *ethapi
|
|||
}
|
||||
|
||||
// Test for GetTransactionByBlockNumberAndIndex
|
||||
func testGetTransactionByBlockNumberAndIndex(t *testing.T, publicTransactionPoolAPI *ethapi.PublicTransactionPoolAPI) {
|
||||
func testGetTransactionByBlockNumberAndIndex(t *testing.T, publicTransactionPoolAPI *ethapi.TransactionAPI) {
|
||||
// check 1 : False ( no transaction )
|
||||
tx := publicTransactionPoolAPI.GetTransactionByBlockNumberAndIndex(context.Background(), rpc.BlockNumber(1), 0)
|
||||
assert.Nil(t, tx)
|
||||
|
|
@ -249,7 +249,7 @@ func TestAPIs(t *testing.T) {
|
|||
|
||||
// Testing GetTransactionByBlockNumberAndIndex
|
||||
nonceLock := new(ethapi.AddrLocker)
|
||||
publicTransactionPoolAPI := ethapi.NewPublicTransactionPoolAPI(backend.APIBackend, nonceLock)
|
||||
publicTransactionPoolAPI := ethapi.NewTransactionAPI(backend.APIBackend, nonceLock)
|
||||
testGetTransactionByBlockNumberAndIndex(t, publicTransactionPoolAPI)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/consensus/misc"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/txpool"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
|
|
@ -219,7 +220,7 @@ func buildNextBlock(t *testing.T, _bor consensus.Engine, chain *core.BlockChain,
|
|||
ctx := context.Background()
|
||||
|
||||
// Finalize and seal the block
|
||||
block, _ := _bor.FinalizeAndAssemble(ctx, chain, b.header, state, b.txs, nil, b.receipts)
|
||||
block, _ := _bor.FinalizeAndAssemble(ctx, chain, b.header, state, b.txs, nil, b.receipts, []*types.Withdrawal{})
|
||||
|
||||
// Write state changes to db
|
||||
root, err := state.Commit(chain.Config().IsEIP158(b.header.Number))
|
||||
|
|
@ -227,7 +228,7 @@ func buildNextBlock(t *testing.T, _bor consensus.Engine, chain *core.BlockChain,
|
|||
panic(fmt.Sprintf("state write error: %v", err))
|
||||
}
|
||||
|
||||
if err := state.Database().TrieDB().Commit(root, false, nil); err != nil {
|
||||
if err := state.Database().TrieDB().Commit(root, false); err != nil {
|
||||
panic(fmt.Sprintf("trie write error: %v", err))
|
||||
}
|
||||
|
||||
|
|
@ -255,7 +256,7 @@ func (b *blockGen) addTxWithChain(bc *core.BlockChain, statedb *state.StateDB, t
|
|||
b.setCoinbase(coinbase)
|
||||
}
|
||||
|
||||
statedb.Prepare(tx.Hash(), len(b.txs))
|
||||
statedb.SetTxContext(tx.Hash(), len(b.txs))
|
||||
|
||||
receipt, err := core.ApplyTransaction(bc.Config(), bc, &b.header.Coinbase, b.gasPool, statedb, b.header, tx, &b.header.GasUsed, vm.Config{}, nil)
|
||||
if err != nil {
|
||||
|
|
@ -433,7 +434,8 @@ func InitGenesis(t *testing.T, faucets []*ecdsa.PrivateKey, fileLocation string,
|
|||
}
|
||||
|
||||
genesis.Config.ChainID = big.NewInt(15001)
|
||||
genesis.Config.EIP150Hash = common.Hash{}
|
||||
genesis.Config.EIP150Block = big.NewInt(0)
|
||||
|
||||
genesis.Config.Bor.Sprint["0"] = sprintSize
|
||||
|
||||
return genesis
|
||||
|
|
@ -466,7 +468,7 @@ func InitMiner(genesis *core.Genesis, privKey *ecdsa.PrivateKey, withoutHeimdall
|
|||
SyncMode: downloader.FullSync,
|
||||
DatabaseCache: 256,
|
||||
DatabaseHandles: 256,
|
||||
TxPool: core.DefaultTxPoolConfig,
|
||||
TxPool: txpool.DefaultConfig,
|
||||
GPO: ethconfig.Defaults.GPO,
|
||||
Ethash: ethconfig.Defaults.Ethash,
|
||||
Miner: miner.Config{
|
||||
|
|
|
|||
Loading…
Reference in a new issue