|
@@ -44,21 +44,21 @@ func tmpDatadirWithKeystore(t *testing.T) string {
|
|
|
|
|
|
|
|
func TestAccountListEmpty(t *testing.T) {
|
|
func TestAccountListEmpty(t *testing.T) {
|
|
|
geth := runGeth(t, "account", "list")
|
|
geth := runGeth(t, "account", "list")
|
|
|
- geth.expectExit()
|
|
|
|
|
|
|
+ geth.ExpectExit()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func TestAccountList(t *testing.T) {
|
|
func TestAccountList(t *testing.T) {
|
|
|
datadir := tmpDatadirWithKeystore(t)
|
|
datadir := tmpDatadirWithKeystore(t)
|
|
|
geth := runGeth(t, "account", "list", "--datadir", datadir)
|
|
geth := runGeth(t, "account", "list", "--datadir", datadir)
|
|
|
- defer geth.expectExit()
|
|
|
|
|
|
|
+ defer geth.ExpectExit()
|
|
|
if runtime.GOOS == "windows" {
|
|
if runtime.GOOS == "windows" {
|
|
|
- geth.expect(`
|
|
|
|
|
|
|
+ geth.Expect(`
|
|
|
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
|
|
|
Account #1: {f466859ead1932d743d622cb74fc058882e8648a} keystore://{{.Datadir}}\keystore\aaa
|
|
Account #1: {f466859ead1932d743d622cb74fc058882e8648a} keystore://{{.Datadir}}\keystore\aaa
|
|
|
Account #2: {289d485d9771714cce91d3393d764e1311907acc} keystore://{{.Datadir}}\keystore\zzz
|
|
Account #2: {289d485d9771714cce91d3393d764e1311907acc} keystore://{{.Datadir}}\keystore\zzz
|
|
|
`)
|
|
`)
|
|
|
} else {
|
|
} else {
|
|
|
- geth.expect(`
|
|
|
|
|
|
|
+ geth.Expect(`
|
|
|
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
|
|
|
Account #1: {f466859ead1932d743d622cb74fc058882e8648a} keystore://{{.Datadir}}/keystore/aaa
|
|
Account #1: {f466859ead1932d743d622cb74fc058882e8648a} keystore://{{.Datadir}}/keystore/aaa
|
|
|
Account #2: {289d485d9771714cce91d3393d764e1311907acc} keystore://{{.Datadir}}/keystore/zzz
|
|
Account #2: {289d485d9771714cce91d3393d764e1311907acc} keystore://{{.Datadir}}/keystore/zzz
|
|
@@ -68,20 +68,20 @@ Account #2: {289d485d9771714cce91d3393d764e1311907acc} keystore://{{.Datadir}}/k
|
|
|
|
|
|
|
|
func TestAccountNew(t *testing.T) {
|
|
func TestAccountNew(t *testing.T) {
|
|
|
geth := runGeth(t, "account", "new", "--lightkdf")
|
|
geth := runGeth(t, "account", "new", "--lightkdf")
|
|
|
- defer geth.expectExit()
|
|
|
|
|
- geth.expect(`
|
|
|
|
|
|
|
+ defer geth.ExpectExit()
|
|
|
|
|
+ geth.Expect(`
|
|
|
Your new account is locked with a password. Please give a password. Do not forget this password.
|
|
Your new account is locked with a password. Please give a password. Do not forget this password.
|
|
|
!! Unsupported terminal, password will be echoed.
|
|
!! Unsupported terminal, password will be echoed.
|
|
|
Passphrase: {{.InputLine "foobar"}}
|
|
Passphrase: {{.InputLine "foobar"}}
|
|
|
Repeat passphrase: {{.InputLine "foobar"}}
|
|
Repeat passphrase: {{.InputLine "foobar"}}
|
|
|
`)
|
|
`)
|
|
|
- geth.expectRegexp(`Address: \{[0-9a-f]{40}\}\n`)
|
|
|
|
|
|
|
+ geth.ExpectRegexp(`Address: \{[0-9a-f]{40}\}\n`)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func TestAccountNewBadRepeat(t *testing.T) {
|
|
func TestAccountNewBadRepeat(t *testing.T) {
|
|
|
geth := runGeth(t, "account", "new", "--lightkdf")
|
|
geth := runGeth(t, "account", "new", "--lightkdf")
|
|
|
- defer geth.expectExit()
|
|
|
|
|
- geth.expect(`
|
|
|
|
|
|
|
+ defer geth.ExpectExit()
|
|
|
|
|
+ geth.Expect(`
|
|
|
Your new account is locked with a password. Please give a password. Do not forget this password.
|
|
Your new account is locked with a password. Please give a password. Do not forget this password.
|
|
|
!! Unsupported terminal, password will be echoed.
|
|
!! Unsupported terminal, password will be echoed.
|
|
|
Passphrase: {{.InputLine "something"}}
|
|
Passphrase: {{.InputLine "something"}}
|
|
@@ -95,8 +95,8 @@ func TestAccountUpdate(t *testing.T) {
|
|
|
geth := runGeth(t, "account", "update",
|
|
geth := runGeth(t, "account", "update",
|
|
|
"--datadir", datadir, "--lightkdf",
|
|
"--datadir", datadir, "--lightkdf",
|
|
|
"f466859ead1932d743d622cb74fc058882e8648a")
|
|
"f466859ead1932d743d622cb74fc058882e8648a")
|
|
|
- defer geth.expectExit()
|
|
|
|
|
- geth.expect(`
|
|
|
|
|
|
|
+ defer geth.ExpectExit()
|
|
|
|
|
+ geth.Expect(`
|
|
|
Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3
|
|
Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3
|
|
|
!! Unsupported terminal, password will be echoed.
|
|
!! Unsupported terminal, password will be echoed.
|
|
|
Passphrase: {{.InputLine "foobar"}}
|
|
Passphrase: {{.InputLine "foobar"}}
|
|
@@ -108,8 +108,8 @@ Repeat passphrase: {{.InputLine "foobar2"}}
|
|
|
|
|
|
|
|
func TestWalletImport(t *testing.T) {
|
|
func TestWalletImport(t *testing.T) {
|
|
|
geth := runGeth(t, "wallet", "import", "--lightkdf", "testdata/guswallet.json")
|
|
geth := runGeth(t, "wallet", "import", "--lightkdf", "testdata/guswallet.json")
|
|
|
- defer geth.expectExit()
|
|
|
|
|
- geth.expect(`
|
|
|
|
|
|
|
+ defer geth.ExpectExit()
|
|
|
|
|
+ geth.Expect(`
|
|
|
!! Unsupported terminal, password will be echoed.
|
|
!! Unsupported terminal, password will be echoed.
|
|
|
Passphrase: {{.InputLine "foo"}}
|
|
Passphrase: {{.InputLine "foo"}}
|
|
|
Address: {d4584b5f6229b7be90727b0fc8c6b91bb427821f}
|
|
Address: {d4584b5f6229b7be90727b0fc8c6b91bb427821f}
|
|
@@ -123,8 +123,8 @@ Address: {d4584b5f6229b7be90727b0fc8c6b91bb427821f}
|
|
|
|
|
|
|
|
func TestWalletImportBadPassword(t *testing.T) {
|
|
func TestWalletImportBadPassword(t *testing.T) {
|
|
|
geth := runGeth(t, "wallet", "import", "--lightkdf", "testdata/guswallet.json")
|
|
geth := runGeth(t, "wallet", "import", "--lightkdf", "testdata/guswallet.json")
|
|
|
- defer geth.expectExit()
|
|
|
|
|
- geth.expect(`
|
|
|
|
|
|
|
+ defer geth.ExpectExit()
|
|
|
|
|
+ geth.Expect(`
|
|
|
!! Unsupported terminal, password will be echoed.
|
|
!! Unsupported terminal, password will be echoed.
|
|
|
Passphrase: {{.InputLine "wrong"}}
|
|
Passphrase: {{.InputLine "wrong"}}
|
|
|
Fatal: could not decrypt key with given passphrase
|
|
Fatal: could not decrypt key with given passphrase
|
|
@@ -137,19 +137,19 @@ func TestUnlockFlag(t *testing.T) {
|
|
|
"--datadir", datadir, "--nat", "none", "--nodiscover", "--dev",
|
|
"--datadir", datadir, "--nat", "none", "--nodiscover", "--dev",
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a",
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a",
|
|
|
"js", "testdata/empty.js")
|
|
"js", "testdata/empty.js")
|
|
|
- geth.expect(`
|
|
|
|
|
|
|
+ geth.Expect(`
|
|
|
Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3
|
|
Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3
|
|
|
!! Unsupported terminal, password will be echoed.
|
|
!! Unsupported terminal, password will be echoed.
|
|
|
Passphrase: {{.InputLine "foobar"}}
|
|
Passphrase: {{.InputLine "foobar"}}
|
|
|
`)
|
|
`)
|
|
|
- geth.expectExit()
|
|
|
|
|
|
|
+ geth.ExpectExit()
|
|
|
|
|
|
|
|
wantMessages := []string{
|
|
wantMessages := []string{
|
|
|
"Unlocked account",
|
|
"Unlocked account",
|
|
|
"=0xf466859ead1932d743d622cb74fc058882e8648a",
|
|
"=0xf466859ead1932d743d622cb74fc058882e8648a",
|
|
|
}
|
|
}
|
|
|
for _, m := range wantMessages {
|
|
for _, m := range wantMessages {
|
|
|
- if !strings.Contains(geth.stderrText(), m) {
|
|
|
|
|
|
|
+ if !strings.Contains(geth.StderrText(), m) {
|
|
|
t.Errorf("stderr text does not contain %q", m)
|
|
t.Errorf("stderr text does not contain %q", m)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -160,8 +160,8 @@ func TestUnlockFlagWrongPassword(t *testing.T) {
|
|
|
geth := runGeth(t,
|
|
geth := runGeth(t,
|
|
|
"--datadir", datadir, "--nat", "none", "--nodiscover", "--dev",
|
|
"--datadir", datadir, "--nat", "none", "--nodiscover", "--dev",
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a")
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a")
|
|
|
- defer geth.expectExit()
|
|
|
|
|
- geth.expect(`
|
|
|
|
|
|
|
+ defer geth.ExpectExit()
|
|
|
|
|
+ geth.Expect(`
|
|
|
Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3
|
|
Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3
|
|
|
!! Unsupported terminal, password will be echoed.
|
|
!! Unsupported terminal, password will be echoed.
|
|
|
Passphrase: {{.InputLine "wrong1"}}
|
|
Passphrase: {{.InputLine "wrong1"}}
|
|
@@ -180,14 +180,14 @@ func TestUnlockFlagMultiIndex(t *testing.T) {
|
|
|
"--datadir", datadir, "--nat", "none", "--nodiscover", "--dev",
|
|
"--datadir", datadir, "--nat", "none", "--nodiscover", "--dev",
|
|
|
"--unlock", "0,2",
|
|
"--unlock", "0,2",
|
|
|
"js", "testdata/empty.js")
|
|
"js", "testdata/empty.js")
|
|
|
- geth.expect(`
|
|
|
|
|
|
|
+ geth.Expect(`
|
|
|
Unlocking account 0 | Attempt 1/3
|
|
Unlocking account 0 | Attempt 1/3
|
|
|
!! Unsupported terminal, password will be echoed.
|
|
!! Unsupported terminal, password will be echoed.
|
|
|
Passphrase: {{.InputLine "foobar"}}
|
|
Passphrase: {{.InputLine "foobar"}}
|
|
|
Unlocking account 2 | Attempt 1/3
|
|
Unlocking account 2 | Attempt 1/3
|
|
|
Passphrase: {{.InputLine "foobar"}}
|
|
Passphrase: {{.InputLine "foobar"}}
|
|
|
`)
|
|
`)
|
|
|
- geth.expectExit()
|
|
|
|
|
|
|
+ geth.ExpectExit()
|
|
|
|
|
|
|
|
wantMessages := []string{
|
|
wantMessages := []string{
|
|
|
"Unlocked account",
|
|
"Unlocked account",
|
|
@@ -195,7 +195,7 @@ Passphrase: {{.InputLine "foobar"}}
|
|
|
"=0x289d485d9771714cce91d3393d764e1311907acc",
|
|
"=0x289d485d9771714cce91d3393d764e1311907acc",
|
|
|
}
|
|
}
|
|
|
for _, m := range wantMessages {
|
|
for _, m := range wantMessages {
|
|
|
- if !strings.Contains(geth.stderrText(), m) {
|
|
|
|
|
|
|
+ if !strings.Contains(geth.StderrText(), m) {
|
|
|
t.Errorf("stderr text does not contain %q", m)
|
|
t.Errorf("stderr text does not contain %q", m)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -207,7 +207,7 @@ func TestUnlockFlagPasswordFile(t *testing.T) {
|
|
|
"--datadir", datadir, "--nat", "none", "--nodiscover", "--dev",
|
|
"--datadir", datadir, "--nat", "none", "--nodiscover", "--dev",
|
|
|
"--password", "testdata/passwords.txt", "--unlock", "0,2",
|
|
"--password", "testdata/passwords.txt", "--unlock", "0,2",
|
|
|
"js", "testdata/empty.js")
|
|
"js", "testdata/empty.js")
|
|
|
- geth.expectExit()
|
|
|
|
|
|
|
+ geth.ExpectExit()
|
|
|
|
|
|
|
|
wantMessages := []string{
|
|
wantMessages := []string{
|
|
|
"Unlocked account",
|
|
"Unlocked account",
|
|
@@ -215,7 +215,7 @@ func TestUnlockFlagPasswordFile(t *testing.T) {
|
|
|
"=0x289d485d9771714cce91d3393d764e1311907acc",
|
|
"=0x289d485d9771714cce91d3393d764e1311907acc",
|
|
|
}
|
|
}
|
|
|
for _, m := range wantMessages {
|
|
for _, m := range wantMessages {
|
|
|
- if !strings.Contains(geth.stderrText(), m) {
|
|
|
|
|
|
|
+ if !strings.Contains(geth.StderrText(), m) {
|
|
|
t.Errorf("stderr text does not contain %q", m)
|
|
t.Errorf("stderr text does not contain %q", m)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -226,8 +226,8 @@ func TestUnlockFlagPasswordFileWrongPassword(t *testing.T) {
|
|
|
geth := runGeth(t,
|
|
geth := runGeth(t,
|
|
|
"--datadir", datadir, "--nat", "none", "--nodiscover", "--dev",
|
|
"--datadir", datadir, "--nat", "none", "--nodiscover", "--dev",
|
|
|
"--password", "testdata/wrong-passwords.txt", "--unlock", "0,2")
|
|
"--password", "testdata/wrong-passwords.txt", "--unlock", "0,2")
|
|
|
- defer geth.expectExit()
|
|
|
|
|
- geth.expect(`
|
|
|
|
|
|
|
+ defer geth.ExpectExit()
|
|
|
|
|
+ geth.Expect(`
|
|
|
Fatal: Failed to unlock account 0 (could not decrypt key with given passphrase)
|
|
Fatal: Failed to unlock account 0 (could not decrypt key with given passphrase)
|
|
|
`)
|
|
`)
|
|
|
}
|
|
}
|
|
@@ -238,14 +238,14 @@ func TestUnlockFlagAmbiguous(t *testing.T) {
|
|
|
"--keystore", store, "--nat", "none", "--nodiscover", "--dev",
|
|
"--keystore", store, "--nat", "none", "--nodiscover", "--dev",
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a",
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a",
|
|
|
"js", "testdata/empty.js")
|
|
"js", "testdata/empty.js")
|
|
|
- defer geth.expectExit()
|
|
|
|
|
|
|
+ defer geth.ExpectExit()
|
|
|
|
|
|
|
|
// Helper for the expect template, returns absolute keystore path.
|
|
// Helper for the expect template, returns absolute keystore path.
|
|
|
- geth.setTemplateFunc("keypath", func(file string) string {
|
|
|
|
|
|
|
+ geth.SetTemplateFunc("keypath", func(file string) string {
|
|
|
abs, _ := filepath.Abs(filepath.Join(store, file))
|
|
abs, _ := filepath.Abs(filepath.Join(store, file))
|
|
|
return abs
|
|
return abs
|
|
|
})
|
|
})
|
|
|
- geth.expect(`
|
|
|
|
|
|
|
+ geth.Expect(`
|
|
|
Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3
|
|
Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3
|
|
|
!! Unsupported terminal, password will be echoed.
|
|
!! Unsupported terminal, password will be echoed.
|
|
|
Passphrase: {{.InputLine "foobar"}}
|
|
Passphrase: {{.InputLine "foobar"}}
|
|
@@ -257,14 +257,14 @@ Your passphrase unlocked keystore://{{keypath "1"}}
|
|
|
In order to avoid this warning, you need to remove the following duplicate key files:
|
|
In order to avoid this warning, you need to remove the following duplicate key files:
|
|
|
keystore://{{keypath "2"}}
|
|
keystore://{{keypath "2"}}
|
|
|
`)
|
|
`)
|
|
|
- geth.expectExit()
|
|
|
|
|
|
|
+ geth.ExpectExit()
|
|
|
|
|
|
|
|
wantMessages := []string{
|
|
wantMessages := []string{
|
|
|
"Unlocked account",
|
|
"Unlocked account",
|
|
|
"=0xf466859ead1932d743d622cb74fc058882e8648a",
|
|
"=0xf466859ead1932d743d622cb74fc058882e8648a",
|
|
|
}
|
|
}
|
|
|
for _, m := range wantMessages {
|
|
for _, m := range wantMessages {
|
|
|
- if !strings.Contains(geth.stderrText(), m) {
|
|
|
|
|
|
|
+ if !strings.Contains(geth.StderrText(), m) {
|
|
|
t.Errorf("stderr text does not contain %q", m)
|
|
t.Errorf("stderr text does not contain %q", m)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -275,14 +275,14 @@ func TestUnlockFlagAmbiguousWrongPassword(t *testing.T) {
|
|
|
geth := runGeth(t,
|
|
geth := runGeth(t,
|
|
|
"--keystore", store, "--nat", "none", "--nodiscover", "--dev",
|
|
"--keystore", store, "--nat", "none", "--nodiscover", "--dev",
|
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a")
|
|
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a")
|
|
|
- defer geth.expectExit()
|
|
|
|
|
|
|
+ defer geth.ExpectExit()
|
|
|
|
|
|
|
|
// Helper for the expect template, returns absolute keystore path.
|
|
// Helper for the expect template, returns absolute keystore path.
|
|
|
- geth.setTemplateFunc("keypath", func(file string) string {
|
|
|
|
|
|
|
+ geth.SetTemplateFunc("keypath", func(file string) string {
|
|
|
abs, _ := filepath.Abs(filepath.Join(store, file))
|
|
abs, _ := filepath.Abs(filepath.Join(store, file))
|
|
|
return abs
|
|
return abs
|
|
|
})
|
|
})
|
|
|
- geth.expect(`
|
|
|
|
|
|
|
+ geth.Expect(`
|
|
|
Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3
|
|
Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3
|
|
|
!! Unsupported terminal, password will be echoed.
|
|
!! Unsupported terminal, password will be echoed.
|
|
|
Passphrase: {{.InputLine "wrong"}}
|
|
Passphrase: {{.InputLine "wrong"}}
|
|
@@ -292,5 +292,5 @@ Multiple key files exist for address f466859ead1932d743d622cb74fc058882e8648a:
|
|
|
Testing your passphrase against all of them...
|
|
Testing your passphrase against all of them...
|
|
|
Fatal: None of the listed files could be unlocked.
|
|
Fatal: None of the listed files could be unlocked.
|
|
|
`)
|
|
`)
|
|
|
- geth.expectExit()
|
|
|
|
|
|
|
+ geth.ExpectExit()
|
|
|
}
|
|
}
|