Skip to content

Commit cbe48ac

Browse files
committed
enable reloading, temporarily modify stake/unstake system test to test laod/reload
1 parent 69b5d1a commit cbe48ac

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

iavlx/commit_multi_tree.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,11 @@ func (db *CommitMultiTree) loadStore(key storetypes.StoreKey, typ storetypes.Sto
295295
switch typ {
296296
case storetypes.StoreTypeIAVL, storetypes.StoreTypeDB:
297297
dir := filepath.Join(db.dir, key.Name())
298-
if _, err := os.Stat(dir); !os.IsNotExist(err) {
299-
return nil, fmt.Errorf("store directory %s already exists, reloading isn't supported yet", dir)
300-
}
301-
err := os.MkdirAll(dir, 0o755)
302-
if err != nil {
303-
return nil, fmt.Errorf("failed to create store dir %s: %w", dir, err)
298+
if _, err := os.Stat(dir); os.IsNotExist(err) {
299+
err := os.MkdirAll(dir, 0o755)
300+
if err != nil {
301+
return nil, fmt.Errorf("failed to create store dir %s: %w", dir, err)
302+
}
304303
}
305304
return NewCommitTree(dir, db.opts, db.logger.With("store", key.Name()))
306305
case storetypes.StoreTypeTransient:

tests/systemtests/staking_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ func TestStakeUnstake(t *testing.T) {
3636
rsp = cli.Run("tx", "staking", "delegate", valAddr, "10000stake", "--from="+account1Addr, "--fees=1stake")
3737
systemtests.RequireTxSuccess(t, rsp)
3838

39+
sut.StopChain()
40+
sut.AwaitChainStopped()
41+
sut.StartChain(t)
42+
3943
t.Log(cli.QueryBalance(account1Addr, "stake"))
4044
assert.Equal(t, int64(9989999), cli.QueryBalance(account1Addr, "stake"))
4145

@@ -47,6 +51,10 @@ func TestStakeUnstake(t *testing.T) {
4751
rsp = cli.Run("tx", "staking", "unbond", valAddr, "5000stake", "--from="+account1Addr, "--fees=1stake")
4852
systemtests.RequireTxSuccess(t, rsp)
4953

54+
sut.StopChain()
55+
sut.AwaitChainStopped()
56+
sut.StartChain(t)
57+
5058
rsp = cli.CustomQuery("q", "staking", "delegation", account1Addr, valAddr)
5159
assert.Equal(t, "5000", gjson.Get(rsp, "delegation_response.balance.amount").String(), rsp)
5260
assert.Equal(t, "stake", gjson.Get(rsp, "delegation_response.balance.denom").String(), rsp)

0 commit comments

Comments
 (0)