-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix accounts trie remover config value
- Loading branch information
1 parent
f992a46
commit 07415bd
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
storage/databaseremover/factory/customDatabaseRemoverCreator.go
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,17 @@ | ||
package factory | ||
|
||
import ( | ||
"github.com/ElrondNetwork/elrond-go/config" | ||
"github.com/ElrondNetwork/elrond-go/storage" | ||
"github.com/ElrondNetwork/elrond-go/storage/databaseremover" | ||
"github.com/ElrondNetwork/elrond-go/storage/databaseremover/disabled" | ||
) | ||
|
||
// CreateCustomDatabaseRemover will handle the creation of a custom database remover based on the configuration | ||
func CreateCustomDatabaseRemover(storagePruningConfig config.StoragePruningConfig) (storage.CustomDatabaseRemoverHandler, error) { | ||
if storagePruningConfig.AccountsTrieCleanOldEpochsData { | ||
return databaseremover.NewCustomDatabaseRemover(storagePruningConfig) | ||
} | ||
|
||
return disabled.NewDisabledCustomDatabaseRemover(), nil | ||
} |
41 changes: 41 additions & 0 deletions
41
storage/databaseremover/factory/customDatabaseRemoverCreator_test.go
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,41 @@ | ||
package factory | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/ElrondNetwork/elrond-go/config" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCreateCustomDatabaseRemover(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("should create real custom database remover", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
storagePruningArgs := config.StoragePruningConfig{ | ||
AccountsTrieCleanOldEpochsData: true, | ||
AccountsTrieSkipRemovalCustomPattern: "%1", | ||
} | ||
|
||
removerInstance, err := CreateCustomDatabaseRemover(storagePruningArgs) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, "*databaseremover.customDatabaseRemover", fmt.Sprintf("%T", removerInstance)) | ||
}) | ||
|
||
t.Run("should create disabled custom database remover", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
storagePruningArgs := config.StoragePruningConfig{ | ||
AccountsTrieCleanOldEpochsData: false, | ||
AccountsTrieSkipRemovalCustomPattern: "%1", | ||
} | ||
|
||
removerInstance, err := CreateCustomDatabaseRemover(storagePruningArgs) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, "*disabled.disabledCustomDatabaseRemover", fmt.Sprintf("%T", removerInstance)) | ||
}) | ||
} |
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