aboutsummaryrefslogtreecommitdiffstats
path: root/internal/guide
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-02-13 21:03:16 +0800
committerGitHub <noreply@github.com>2017-02-13 21:03:16 +0800
commitf8f428cc18c5f70814d7b3937128781bac14bffd (patch)
treed93d285d2ec22bd8ed646695c3db116c69fa3329 /internal/guide
parente23e86921b55cb1ee2fca6b6fb9ed91f5532f9fd (diff)
parente99c788155ddd754c73d2c81b6051dcbd42e6575 (diff)
downloaddexon-f8f428cc18c5f70814d7b3937128781bac14bffd.tar
dexon-f8f428cc18c5f70814d7b3937128781bac14bffd.tar.gz
dexon-f8f428cc18c5f70814d7b3937128781bac14bffd.tar.bz2
dexon-f8f428cc18c5f70814d7b3937128781bac14bffd.tar.lz
dexon-f8f428cc18c5f70814d7b3937128781bac14bffd.tar.xz
dexon-f8f428cc18c5f70814d7b3937128781bac14bffd.tar.zst
dexon-f8f428cc18c5f70814d7b3937128781bac14bffd.zip
Merge pull request #3592 from karalabe/hw-wallets
accounts: initial support for Ledger hardware wallets
Diffstat (limited to 'internal/guide')
-rw-r--r--internal/guide/guide_test.go35
1 files changed, 18 insertions, 17 deletions
diff --git a/internal/guide/guide_test.go b/internal/guide/guide_test.go
index 8f89037bd..9c7ad16d1 100644
--- a/internal/guide/guide_test.go
+++ b/internal/guide/guide_test.go
@@ -24,13 +24,14 @@ package guide
import (
"io/ioutil"
+ "math/big"
"os"
"path/filepath"
"testing"
"time"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/accounts/keystore"
+ "github.com/ethereum/go-ethereum/core/types"
)
// Tests that the account management snippets work correctly.
@@ -42,59 +43,59 @@ func TestAccountManagement(t *testing.T) {
}
defer os.RemoveAll(workdir)
- // Create an encrypted keystore manager with standard crypto parameters
- am := accounts.NewManager(filepath.Join(workdir, "keystore"), accounts.StandardScryptN, accounts.StandardScryptP)
+ // Create an encrypted keystore with standard crypto parameters
+ ks := keystore.NewKeyStore(filepath.Join(workdir, "keystore"), keystore.StandardScryptN, keystore.StandardScryptP)
// Create a new account with the specified encryption passphrase
- newAcc, err := am.NewAccount("Creation password")
+ newAcc, err := ks.NewAccount("Creation password")
if err != nil {
t.Fatalf("Failed to create new account: %v", err)
}
// Export the newly created account with a different passphrase. The returned
// data from this method invocation is a JSON encoded, encrypted key-file
- jsonAcc, err := am.Export(newAcc, "Creation password", "Export password")
+ jsonAcc, err := ks.Export(newAcc, "Creation password", "Export password")
if err != nil {
t.Fatalf("Failed to export account: %v", err)
}
// Update the passphrase on the account created above inside the local keystore
- if err := am.Update(newAcc, "Creation password", "Update password"); err != nil {
+ if err := ks.Update(newAcc, "Creation password", "Update password"); err != nil {
t.Fatalf("Failed to update account: %v", err)
}
// Delete the account updated above from the local keystore
- if err := am.Delete(newAcc, "Update password"); err != nil {
+ if err := ks.Delete(newAcc, "Update password"); err != nil {
t.Fatalf("Failed to delete account: %v", err)
}
// Import back the account we've exported (and then deleted) above with yet
// again a fresh passphrase
- if _, err := am.Import(jsonAcc, "Export password", "Import password"); err != nil {
+ if _, err := ks.Import(jsonAcc, "Export password", "Import password"); err != nil {
t.Fatalf("Failed to import account: %v", err)
}
// Create a new account to sign transactions with
- signer, err := am.NewAccount("Signer password")
+ signer, err := ks.NewAccount("Signer password")
if err != nil {
t.Fatalf("Failed to create signer account: %v", err)
}
- txHash := common.HexToHash("0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")
+ tx, chain := new(types.Transaction), big.NewInt(1)
// Sign a transaction with a single authorization
- if _, err := am.SignWithPassphrase(signer, "Signer password", txHash.Bytes()); err != nil {
+ if _, err := ks.SignTxWithPassphrase(signer, "Signer password", tx, chain); err != nil {
t.Fatalf("Failed to sign with passphrase: %v", err)
}
// Sign a transaction with multiple manually cancelled authorizations
- if err := am.Unlock(signer, "Signer password"); err != nil {
+ if err := ks.Unlock(signer, "Signer password"); err != nil {
t.Fatalf("Failed to unlock account: %v", err)
}
- if _, err := am.Sign(signer.Address, txHash.Bytes()); err != nil {
+ if _, err := ks.SignTx(signer, tx, chain); err != nil {
t.Fatalf("Failed to sign with unlocked account: %v", err)
}
- if err := am.Lock(signer.Address); err != nil {
+ if err := ks.Lock(signer.Address); err != nil {
t.Fatalf("Failed to lock account: %v", err)
}
// Sign a transaction with multiple automatically cancelled authorizations
- if err := am.TimedUnlock(signer, "Signer password", time.Second); err != nil {
+ if err := ks.TimedUnlock(signer, "Signer password", time.Second); err != nil {
t.Fatalf("Failed to time unlock account: %v", err)
}
- if _, err := am.Sign(signer.Address, txHash.Bytes()); err != nil {
+ if _, err := ks.SignTx(signer, tx, chain); err != nil {
t.Fatalf("Failed to sign with time unlocked account: %v", err)
}
}