Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cli/server/cli_dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func TestDBRestoreDump(t *testing.T) {

// Dump and compare.
dumpPath := filepath.Join(tmpDir, "testdump.acc")
incDumpPath := filepath.Join(tmpDir, "testincdump.acc")

t.Run("missing config", func(t *testing.T) {
e.RunWithError(t, "neo-go", "db", "dump", "--privnet",
Expand Down Expand Up @@ -104,13 +105,17 @@ func TestDBRestoreDump(t *testing.T) {
e.RunWithError(t, append(baseCmd, "something")...)
})

e.Run(t, baseCmd...)
e.Run(t, append(baseCmd, "--non-incremental", "--out", dumpPath)...)
e.Run(t, append(baseCmd, "--out", incDumpPath)...)

d1, err := os.ReadFile(inDump)
require.NoError(t, err)
d2, err := os.ReadFile(dumpPath)
require.NoError(t, err)
require.Equal(t, d1, d2, "dumps differ")
d3, err := os.ReadFile(incDumpPath)
require.NoError(t, err)
require.Equal(t, append([]byte{0, 0, 0, 0}, d1...), d3, "dumps differ")
}

func TestDBDumpRestoreIncremental(t *testing.T) {
Expand Down
9 changes: 7 additions & 2 deletions cli/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ func NewCommands() []*cli.Command {
Usage: "Dump blocks (starting with the genesis or specified block) to the file",
UsageText: "neo-go db dump [-o file] [-s start] [-c count] [--config-path path] [-p/-m/-t] [--config-file file] [--force-timestamp-logs]",
Action: dumpDB,
Flags: cfgCountOutFlags,
Flags: append(cfgCountOutFlags,
&cli.BoolFlag{
Name: "non-incremental",
Usage: "Force legacy (non-incremental) dump output",
},
),
},
{
Name: "dump-bin",
Expand Down Expand Up @@ -204,7 +209,7 @@ func dumpDB(ctx *cli.Context) error {
if count == 0 {
count = chainCount - start
}
if start != 0 {
if start != 0 || !ctx.Bool("non-incremental") {
writer.WriteU32LE(start)
}
writer.WriteU32LE(count)
Expand Down
1 change: 1 addition & 0 deletions cli/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ func TestRestoreDB(t *testing.T) {
cfgPath := set.String("config-path", goodCfg, "")
set.Bool("privnet", true, "")
set.Bool("debug", true, "")
set.Bool("non-incremental", true, "")
set.Int("start", 0, "")
set.Int("count", 1, "")
set.String("out", testDump, "")
Expand Down
Loading