|
|
@ -43,11 +43,13 @@ func tmpDatadirWithKeystore(t *testing.T) string { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestAccountListEmpty(t *testing.T) { |
|
|
|
func TestAccountListEmpty(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
geth := runGeth(t, "account", "list") |
|
|
|
geth := runGeth(t, "account", "list") |
|
|
|
geth.ExpectExit() |
|
|
|
geth.ExpectExit() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestAccountList(t *testing.T) { |
|
|
|
func TestAccountList(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
datadir := tmpDatadirWithKeystore(t) |
|
|
|
datadir := tmpDatadirWithKeystore(t) |
|
|
|
var want = ` |
|
|
|
var want = ` |
|
|
|
Account #0: {7ef5a6135f1fd6a02593eedc869c6d41d934aef8} keystore://{{.Datadir}}/keystore/UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8
|
|
|
|
Account #0: {7ef5a6135f1fd6a02593eedc869c6d41d934aef8} keystore://{{.Datadir}}/keystore/UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8
|
|
|
@ -74,6 +76,7 @@ Account #2: {289d485d9771714cce91d3393d764e1311907acc} keystore://{{.Datadir}}\k |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestAccountNew(t *testing.T) { |
|
|
|
func TestAccountNew(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
geth := runGeth(t, "account", "new", "--lightkdf") |
|
|
|
geth := runGeth(t, "account", "new", "--lightkdf") |
|
|
|
defer geth.ExpectExit() |
|
|
|
defer geth.ExpectExit() |
|
|
|
geth.Expect(` |
|
|
|
geth.Expect(` |
|
|
@ -96,6 +99,7 @@ Path of the secret key file: .*UTC--.+--[0-9a-f]{40} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestAccountImport(t *testing.T) { |
|
|
|
func TestAccountImport(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
tests := []struct{ name, key, output string }{ |
|
|
|
tests := []struct{ name, key, output string }{ |
|
|
|
{ |
|
|
|
{ |
|
|
|
name: "correct account", |
|
|
|
name: "correct account", |
|
|
@ -118,6 +122,7 @@ func TestAccountImport(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestAccountHelp(t *testing.T) { |
|
|
|
func TestAccountHelp(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
geth := runGeth(t, "account", "-h") |
|
|
|
geth := runGeth(t, "account", "-h") |
|
|
|
geth.WaitExit() |
|
|
|
geth.WaitExit() |
|
|
|
if have, want := geth.ExitStatus(), 0; have != want { |
|
|
|
if have, want := geth.ExitStatus(), 0; have != want { |
|
|
@ -147,6 +152,7 @@ func importAccountWithExpect(t *testing.T, key string, expected string) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestAccountNewBadRepeat(t *testing.T) { |
|
|
|
func TestAccountNewBadRepeat(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
geth := runGeth(t, "account", "new", "--lightkdf") |
|
|
|
geth := runGeth(t, "account", "new", "--lightkdf") |
|
|
|
defer geth.ExpectExit() |
|
|
|
defer geth.ExpectExit() |
|
|
|
geth.Expect(` |
|
|
|
geth.Expect(` |
|
|
@ -159,6 +165,7 @@ Fatal: Passwords do not match |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestAccountUpdate(t *testing.T) { |
|
|
|
func TestAccountUpdate(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
datadir := tmpDatadirWithKeystore(t) |
|
|
|
datadir := tmpDatadirWithKeystore(t) |
|
|
|
geth := runGeth(t, "account", "update", |
|
|
|
geth := runGeth(t, "account", "update", |
|
|
|
"--datadir", datadir, "--lightkdf", |
|
|
|
"--datadir", datadir, "--lightkdf", |
|
|
@ -175,6 +182,7 @@ Repeat password: {{.InputLine "foobar2"}} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestWalletImport(t *testing.T) { |
|
|
|
func TestWalletImport(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
geth := runGeth(t, "wallet", "import", "--lightkdf", "testdata/guswallet.json") |
|
|
|
geth := runGeth(t, "wallet", "import", "--lightkdf", "testdata/guswallet.json") |
|
|
|
defer geth.ExpectExit() |
|
|
|
defer geth.ExpectExit() |
|
|
|
geth.Expect(` |
|
|
|
geth.Expect(` |
|
|
@ -190,6 +198,7 @@ Address: {d4584b5f6229b7be90727b0fc8c6b91bb427821f} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestWalletImportBadPassword(t *testing.T) { |
|
|
|
func TestWalletImportBadPassword(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
geth := runGeth(t, "wallet", "import", "--lightkdf", "testdata/guswallet.json") |
|
|
|
geth := runGeth(t, "wallet", "import", "--lightkdf", "testdata/guswallet.json") |
|
|
|
defer geth.ExpectExit() |
|
|
|
defer geth.ExpectExit() |
|
|
|
geth.Expect(` |
|
|
|
geth.Expect(` |
|
|
@ -200,6 +209,7 @@ Fatal: could not decrypt key with given password |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestUnlockFlag(t *testing.T) { |
|
|
|
func TestUnlockFlag(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t), |
|
|
|
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t), |
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "console", "--exec", "loadScript('testdata/empty.js')") |
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "console", "--exec", "loadScript('testdata/empty.js')") |
|
|
|
geth.Expect(` |
|
|
|
geth.Expect(` |
|
|
@ -222,6 +232,7 @@ undefined |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestUnlockFlagWrongPassword(t *testing.T) { |
|
|
|
func TestUnlockFlagWrongPassword(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t), |
|
|
|
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t), |
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "console", "--exec", "loadScript('testdata/empty.js')") |
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "console", "--exec", "loadScript('testdata/empty.js')") |
|
|
|
|
|
|
|
|
|
|
@ -240,6 +251,7 @@ Fatal: Failed to unlock account f466859ead1932d743d622cb74fc058882e8648a (could |
|
|
|
|
|
|
|
|
|
|
|
// https://github.com/ethereum/go-ethereum/issues/1785
|
|
|
|
// https://github.com/ethereum/go-ethereum/issues/1785
|
|
|
|
func TestUnlockFlagMultiIndex(t *testing.T) { |
|
|
|
func TestUnlockFlagMultiIndex(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t), |
|
|
|
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t), |
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--unlock", "0,2", "console", "--exec", "loadScript('testdata/empty.js')") |
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--unlock", "0,2", "console", "--exec", "loadScript('testdata/empty.js')") |
|
|
|
|
|
|
|
|
|
|
@ -266,6 +278,7 @@ undefined |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestUnlockFlagPasswordFile(t *testing.T) { |
|
|
|
func TestUnlockFlagPasswordFile(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t), |
|
|
|
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t), |
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--password", "testdata/passwords.txt", "--unlock", "0,2", "console", "--exec", "loadScript('testdata/empty.js')") |
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--password", "testdata/passwords.txt", "--unlock", "0,2", "console", "--exec", "loadScript('testdata/empty.js')") |
|
|
|
|
|
|
|
|
|
|
@ -287,6 +300,7 @@ undefined |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestUnlockFlagPasswordFileWrongPassword(t *testing.T) { |
|
|
|
func TestUnlockFlagPasswordFileWrongPassword(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t), |
|
|
|
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t), |
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--password", |
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--password", |
|
|
|
"testdata/wrong-passwords.txt", "--unlock", "0,2") |
|
|
|
"testdata/wrong-passwords.txt", "--unlock", "0,2") |
|
|
@ -297,6 +311,7 @@ Fatal: Failed to unlock account 0 (could not decrypt key with given password) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestUnlockFlagAmbiguous(t *testing.T) { |
|
|
|
func TestUnlockFlagAmbiguous(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
store := filepath.Join("..", "..", "accounts", "keystore", "testdata", "dupes") |
|
|
|
store := filepath.Join("..", "..", "accounts", "keystore", "testdata", "dupes") |
|
|
|
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t), |
|
|
|
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t), |
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--keystore", |
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--keystore", |
|
|
@ -336,6 +351,7 @@ undefined |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestUnlockFlagAmbiguousWrongPassword(t *testing.T) { |
|
|
|
func TestUnlockFlagAmbiguousWrongPassword(t *testing.T) { |
|
|
|
|
|
|
|
t.Parallel() |
|
|
|
store := filepath.Join("..", "..", "accounts", "keystore", "testdata", "dupes") |
|
|
|
store := filepath.Join("..", "..", "accounts", "keystore", "testdata", "dupes") |
|
|
|
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t), |
|
|
|
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t), |
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--keystore", |
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--keystore", |
|
|
|