Skip to content

Commit fae5716

Browse files
committed
cmd/geth: test for export command
1 parent ffaed99 commit fae5716

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

cmd/geth/exportcmd_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2016 The go-ethereum Authors
2+
// This file is part of go-ethereum.
3+
//
4+
// go-ethereum is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// go-ethereum is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
16+
17+
package main
18+
19+
import (
20+
"bytes"
21+
"fmt"
22+
"os"
23+
"testing"
24+
25+
"github.com/ethereum/go-ethereum/common"
26+
)
27+
28+
// TestExport does a basic test of "geth export", exporting the test-genesis.
29+
func TestExport(t *testing.T) {
30+
outfile := fmt.Sprintf("%v/testExport.out", os.TempDir())
31+
defer os.Remove(outfile)
32+
geth := runGeth(t, "--datadir", initGeth(t), "export", outfile)
33+
geth.WaitExit()
34+
if have, want := geth.ExitStatus(), 0; have != want {
35+
t.Errorf("exit error, have %d want %d", have, want)
36+
}
37+
have, err := os.ReadFile(outfile)
38+
if err != nil {
39+
t.Fatal(err)
40+
}
41+
want := common.FromHex("0xf9026bf90266a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a08758259b018f7bce3d2be2ddb62f325eaeea0a0c188cf96623eab468a4413e03a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180837a12008080b875000000000000000000000000000000000000000000000000000000000000000002f0d131f1f97aef08aec6e3291b957d9efe71050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000880000000000000000c0c0")
42+
if !bytes.Equal(have, want) {
43+
t.Fatalf("wrong content exported")
44+
}
45+
}

core/rawdb/accessors_metadata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
package rawdb
1818

1919
import (
20+
"bytes"
2021
"encoding/json"
2122
"time"
2223

23-
"bytes"
2424
"github.com/ethereum/go-ethereum/common"
2525
"github.com/ethereum/go-ethereum/ethdb"
2626
"github.com/ethereum/go-ethereum/log"

0 commit comments

Comments
 (0)