mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
core/state: add createcontract to journal fuzzing
This commit is contained in:
parent
10482a8fe0
commit
c3b8364e60
1 changed files with 21 additions and 0 deletions
|
|
@ -385,6 +385,27 @@ func newTestAction(addr common.Address, r *rand.Rand) testAction {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "CreateContract",
|
||||||
|
fn: func(a testAction, s *StateDB) {
|
||||||
|
if !s.Exist(addr) {
|
||||||
|
s.CreateAccount(addr)
|
||||||
|
}
|
||||||
|
contractHash := s.GetCodeHash(addr)
|
||||||
|
emptyCode := contractHash == (common.Hash{}) || contractHash == types.EmptyCodeHash
|
||||||
|
storageRoot := s.GetStorageRoot(addr)
|
||||||
|
emptyStorage := storageRoot == (common.Hash{}) || storageRoot == types.EmptyRootHash
|
||||||
|
if s.GetNonce(addr) == 0 && emptyCode && emptyStorage {
|
||||||
|
s.CreateContract(addr)
|
||||||
|
// We also set some code here, to prevent the
|
||||||
|
// CreateContract action from being performed twice in a row,
|
||||||
|
// which would cause a difference in state when unrolling
|
||||||
|
// the journal. (CreateContact assumes created was false prior to
|
||||||
|
// invocation, and the journal rollback sets it to false).
|
||||||
|
s.SetCode(addr, []byte{1})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "SelfDestruct",
|
name: "SelfDestruct",
|
||||||
fn: func(a testAction, s *StateDB) {
|
fn: func(a testAction, s *StateDB) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue