-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
Empty file.
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 @@ | ||
MANIFEST-000000 |
Empty file.
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,6 @@ | ||
=============== Jan 5, 2024 (EST) =============== | ||
10:42:43.970756 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed | ||
10:42:44.004968 db@open opening | ||
10:42:44.005399 version@stat F·[] S·0B[] Sc·[] | ||
10:42:44.010304 db@janitor F·2 G·0 | ||
10:42:44.010345 db@open done T·5.349541ms |
Binary file not shown.
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
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 |
---|---|---|
@@ -1,11 +1,82 @@ | ||
package app | ||
|
||
import "testing" | ||
import ( | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/baseapp" | ||
"github.com/cosmos/cosmos-sdk/store/rootmulti" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/stretchr/testify/assert" | ||
dbm "github.com/tendermint/tm-db" | ||
) | ||
|
||
func TestWrapStoreLoader(t *testing.T) { | ||
var flag bool | ||
tests := []struct { | ||
name string | ||
storeLoader baseapp.StoreLoader | ||
wrapper StoreLoaderWrapper | ||
err string | ||
}{ | ||
{ | ||
name: "nil store loader is set with valid value", | ||
storeLoader: nil, | ||
wrapper: createMockStoreWrapper(&flag), | ||
}, | ||
{ | ||
name: "nil wrapper is handled", | ||
storeLoader: createMockStoreLoader(), | ||
wrapper: nil, | ||
err: "wrapper must not be nil", | ||
}, | ||
{ | ||
name: "contents of wrapper are called", | ||
storeLoader: createMockStoreLoader(), | ||
wrapper: createMockFlipWrapper(&flag), | ||
}, | ||
} | ||
|
||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
storeLoader := WrapStoreLoader(tc.wrapper, tc.storeLoader) | ||
db := dbm.GoLevelDB{} | ||
ms := rootmulti.NewStore(&db, nil) | ||
assert.NotNil(t, ms, "should create a new multistore for testing") | ||
flag = false | ||
|
||
err := storeLoader(ms) | ||
if len(tc.err) > 0 { | ||
assert.EqualError(t, err, tc.err, "should have correct error") | ||
assert.False(t, flag, "wrapper should not be executed") | ||
} else { | ||
assert.NoError(t, err, "should not return an error on success") | ||
assert.True(t, flag, "wrapper should execute and have correct logic") | ||
} | ||
|
||
}) | ||
} | ||
} | ||
|
||
func TestPruningWrapper(t *testing.T) { | ||
|
||
} | ||
|
||
func createMockStoreLoader() baseapp.StoreLoader { | ||
return func(ms sdk.CommitMultiStore) error { | ||
return nil | ||
} | ||
} | ||
|
||
func createMockFlipWrapper(flag *bool) StoreLoaderWrapper { | ||
return func(cms sdk.CommitMultiStore, sl baseapp.StoreLoader) error { | ||
*flag = !(*flag) | ||
return nil | ||
} | ||
} | ||
|
||
func createMockStoreWrapper(flag *bool) StoreLoaderWrapper { | ||
return func(cms sdk.CommitMultiStore, sl baseapp.StoreLoader) error { | ||
*flag = sl != nil | ||
return nil | ||
} | ||
} |