Skip to content
This repository was archived by the owner on May 21, 2024. It is now read-only.

Commit 9362fa6

Browse files
author
Jeannette
committed
Test error fixes
1 parent 11b23ae commit 9362fa6

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

core/blockchain.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,6 +2502,7 @@ func (bc *BlockChain) SetBlockValidatorAndProcessorForTesting(v Validator, p Pro
25022502
// It is thread-safe and can be called repeatedly without side effects.
25032503
func (bc *BlockChain) SetTrieFlushInterval(interval time.Duration) {
25042504
atomic.StoreInt64(&bc.flushInterval, int64(interval))
2505+
}
25052506

25062507
// SubscribeStateChangeEvent registers a subscription StateChangeEvent.
25072508
func (bc *BlockChain) SubscribeStateChangeEvent(ch chan<- StateChangeEvent) event.Subscription {

core/blockchain_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3450,7 +3450,7 @@ func testSendingStateChangeEvents(t *testing.T, numberOfEventsToSend int) {
34503450
newEventCh = make(chan bool)
34513451
)
34523452

3453-
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil)
3453+
blockchain, _ := NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil)
34543454
defer blockchain.Stop()
34553455

34563456
stateChangeCh := make(chan StateChangeEvent)

core/state/statedb.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ type StateChanges map[common.Address]ModifiedAccount
969969
func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, StateChanges, error) {
970970
// Short circuit in case any database failure occurred earlier.
971971
if s.dbErr != nil {
972-
return common.Hash{}, fmt.Errorf("commit aborted due to earlier error: %v", s.dbErr)
972+
return common.Hash{}, nil, fmt.Errorf("commit aborted due to earlier error: %v", s.dbErr)
973973
}
974974

975975
// Finalize any pending changes and merge everything into the tries
@@ -1040,10 +1040,8 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, StateChanges, er
10401040
if metrics.EnabledExpensive {
10411041
start = time.Now()
10421042
}
1043-
root, set, err := s.trie.Commit(true)
1044-
if err != nil {
1045-
return common.Hash{}, StateChanges{}, err
1046-
}
1043+
root, set := s.trie.Commit(true)
1044+
10471045
// Merge the dirty nodes of account trie into global set
10481046
if set != nil {
10491047
if err := nodes.Merge(set); err != nil {

core/state/statedb_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"testing/quick"
3131

3232
"github.com/ethereum/go-ethereum/common"
33+
//"github.com/ethereum/go-ethereum/crypto"
3334
"github.com/ethereum/go-ethereum/core/rawdb"
3435
"github.com/ethereum/go-ethereum/core/types"
3536
)
@@ -113,6 +114,11 @@ func TestStateChangesEmittedFromCommit(t *testing.T) {
113114
}
114115

115116
func getNewModifiedAccount() ModifiedAccount {
117+
//emptyRoot is the known root hash of an empty trie.
118+
//var emptyRoot = common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
119+
//var emptyCode = common.HexToHash("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
120+
//var emptyCodeHash = crypto.Keccak256Hash(nil)
121+
116122
return ModifiedAccount{
117123
Storage: make(map[common.Hash]common.Hash),
118124
StateAccount: types.StateAccount{

0 commit comments

Comments
 (0)