Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
lint, rm dbErr
Browse files Browse the repository at this point in the history
  • Loading branch information
fedekunze committed Jan 5, 2022
1 parent ac2fa40 commit 6690f41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
19 changes: 8 additions & 11 deletions x/evm/keeper/statedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,15 @@ func (suite *KeeperTestSuite) TestEmpty() {
address common.Address
malleate func(vm.StateDB)
empty bool
expErr bool
}{
{"empty, account exists", suite.address, func(vm.StateDB) {}, true, false},
{"not empty, positive balance", suite.address, func(vmdb vm.StateDB) {
vmdb.AddBalance(suite.address, big.NewInt(100))
}, false, false},
{"empty, account doesn't exist", tests.GenerateAddress(), func(vm.StateDB) {}, true, false},
{"empty, account exists", suite.address, func(vm.StateDB) {}, true},
{
"not empty, positive balance",
suite.address,
func(vmdb vm.StateDB) { vmdb.AddBalance(suite.address, big.NewInt(100)) },
false,
},
{"empty, account doesn't exist", tests.GenerateAddress(), func(vm.StateDB) {}, true},
}

for _, tc := range testCases {
Expand All @@ -490,11 +492,6 @@ func (suite *KeeperTestSuite) TestEmpty() {
tc.malleate(vmdb)

suite.Require().Equal(tc.empty, vmdb.Empty(tc.address))
if tc.expErr {
suite.Require().Error(vmdb.Error())
} else {
suite.Require().NoError(vmdb.Error())
}
})
}
}
Expand Down
16 changes: 0 additions & 16 deletions x/evm/statedb/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ var _ vm.StateDB = &StateDB{}
type StateDB struct {
keeper Keeper
ctx sdk.Context
dbErr error

// Journal of state modifications. This is the backbone of
// Snapshot and RevertToSnapshot.
Expand Down Expand Up @@ -76,18 +75,6 @@ func (s *StateDB) Context() sdk.Context {
return s.ctx
}

// setError remembers the first non-nil error it is called with.
func (s *StateDB) setError(err error) {
if s.dbErr == nil {
s.dbErr = err
}
}

// Error returns the database error recorded.
func (s *StateDB) Error() error {
return s.dbErr
}

// AddLog adds a log, called by evm.
func (s *StateDB) AddLog(log *ethtypes.Log) {
s.journal.append(addLogChange{})
Expand Down Expand Up @@ -464,9 +451,6 @@ func (s *StateDB) RevertToSnapshot(revid int) {
// Commit writes the dirty states to keeper
// the StateDB object should be discarded after committed.
func (s *StateDB) Commit() error {
if s.dbErr != nil {
return fmt.Errorf("commit aborted due to earlier error: %v", s.dbErr)
}
for _, addr := range s.journal.sortedDirties() {
obj := s.stateObjects[addr]
if obj.suicided {
Expand Down

0 comments on commit 6690f41

Please sign in to comment.