forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
makes ethereum tests configurable to inject db implementations (ether…
…eum#7) * makes ethereum tests configurable to inject db implementations * simplifies code by embedding pre state initialisation in factory
- Loading branch information
Showing
2 changed files
with
91 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package tests | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/core/state" | ||
"github.com/ethereum/go-ethereum/core/tracing" | ||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/ethereum/go-ethereum/core/vm" | ||
"github.com/holiman/uint256" | ||
) | ||
|
||
// TestStateDB allows for switching database implementation for running tests. | ||
// It is an extension of vm.StateDB with additional methods that were originally | ||
// available only at an implementation level of the geth database. | ||
// Not all methods have to be available in all implementations, and clients | ||
// should pair expected method outputs with the actual implementation. | ||
type TestStateDB interface { | ||
vm.StateDB | ||
|
||
// Database returns the underlying database. | ||
Database() state.Database | ||
|
||
// Logs returns the logs of the current transaction. | ||
Logs() []*types.Log | ||
|
||
SetLogger(l *tracing.Hooks) | ||
|
||
// SetBalance sets the balance of the given account. | ||
SetBalance(addr common.Address, amount *uint256.Int, reason tracing.BalanceChangeReason) | ||
|
||
// IntermediateRoot returns current state root hash. | ||
IntermediateRoot(deleteEmptyObjects bool) common.Hash | ||
|
||
// Commit commits the state to the underlying trie database and returns state root hash. | ||
Commit(block uint64, deleteEmptyObjects bool) (common.Hash, error) | ||
} | ||
|
||
// TestContextFactory is an interface for creating test configurations. | ||
type TestContextFactory interface { | ||
|
||
// NewTestStateDB creates a new StateTestState instance. | ||
NewTestStateDB(accounts types.GenesisAlloc) StateTestState | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters