Skip to content

Commit 332407a

Browse files
committed
Restore command
1 parent 5bf663f commit 332407a

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

server/v2/commands.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ var appBuildingCommands = [][]string{
186186
{"genesis", "export"},
187187
{"store", "restore"},
188188
{"store", "prune"},
189+
{"store", "export"},
189190
}
190191

191192
// IsAppRequired determines if a command requires a full application to be built by

store/v2/commitment/store.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,9 @@ loop:
563563
node.Value = []byte{}
564564
}
565565
}
566+
if node.Version == 0 {
567+
node.Version = int64(version)
568+
}
566569
err := importer.Add(node)
567570
if err != nil {
568571
return snapshotstypes.SnapshotItem{}, fmt.Errorf("failed to add node to importer: %w", err)

tests/systemtests/store_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import (
1515
const disabledLog = "--log_level=disabled"
1616

1717
func TestSnapshots(t *testing.T) {
18-
t.Skip("Not persisting properly on CI")
19-
2018
systest.Sut.ResetChain(t)
2119
cli := systest.NewCLIWrapper(t, systest.Sut, systest.Verbose)
2220
systest.Sut.StartChain(t)
@@ -28,7 +26,9 @@ func TestSnapshots(t *testing.T) {
2826

2927
node0Dir := systest.Sut.NodeDir(0)
3028
command := "store"
31-
restoreableDirs := []string{fmt.Sprintf("%s/data/application.db", node0Dir), fmt.Sprintf("%s/data/ss", node0Dir)}
29+
restoreableDirs := []string{
30+
fmt.Sprintf("%s/data/application.db", node0Dir),
31+
}
3232

3333
// export snapshot at height 5
3434
res := cli.RunCommandWithArgs(command, "export", "--height=5", fmt.Sprintf("--home=%s", node0Dir), disabledLog)
@@ -52,19 +52,18 @@ func TestSnapshots(t *testing.T) {
5252
res = cli.RunCommandWithArgs(command, "load", fmt.Sprintf("%s/5-3.tar.gz", node0Dir), fmt.Sprintf("--home=%s", node0Dir), disabledLog)
5353
require.DirExists(t, fmt.Sprintf("%s/data/snapshots/5/3", node0Dir))
5454

55-
// Restore from snapshots
55+
// Remove database
5656
for _, dir := range restoreableDirs {
5757
require.NoError(t, os.RemoveAll(dir))
5858
}
59-
// Remove database
60-
err := os.RemoveAll(fmt.Sprintf("%s/data/application.db", node0Dir))
61-
require.NoError(t, err)
62-
require.NoError(t, os.RemoveAll(fmt.Sprintf("%s/data/ss", node0Dir)))
6359

60+
// Restore from snapshots
6461
res = cli.RunCommandWithArgs(command, "restore", "5", "3", fmt.Sprintf("--home=%s", node0Dir), disabledLog)
6562
for _, dir := range restoreableDirs {
6663
require.DirExists(t, dir)
6764
}
65+
systest.Sut.StartChain(t)
66+
systest.Sut.AwaitNBlocks(t, 2)
6867
}
6968

7069
func TestPrune(t *testing.T) {

0 commit comments

Comments
 (0)