Skip to content

Commit

Permalink
Add accounts.Wallet interface test
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
  • Loading branch information
ggwpez committed Jul 20, 2021
1 parent 1365b41 commit d6c3b60
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions hdwallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"
"testing"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -64,6 +65,8 @@ func TestWallet(t *testing.T) {
if err != nil {
t.Error(err)
}
// Check that Wallet implements the accounts.Wallet interface.
var _ accounts.Wallet = wallet

path, err := ParseDerivationPath("m/44'/60'/0'/0/0")
if err != nil {
Expand Down Expand Up @@ -163,7 +166,7 @@ func TestWallet(t *testing.T) {

tx := types.NewTransaction(nonce, toAddress, value, gasLimit, gasPrice, data)

signedTx, err := wallet.SignTx(account, tx, nil, nil)
signedTx, err := wallet.SignTx(account, tx, nil)
if err != nil {
t.Error(err)
}
Expand All @@ -179,15 +182,15 @@ func TestWallet(t *testing.T) {
t.Error("expected s value")
}

signedTx2, err := wallet.SignTxWithPassphrase(account, "", tx, nil, nil)
signedTx2, err := wallet.SignTxWithPassphrase(account, "", tx, nil)
if err != nil {
t.Error(err)
}
if signedTx.Hash() != signedTx2.Hash() {
t.Error("expected match")
}

signedTx3, err := wallet.SignTxEIP155(account, tx, big.NewInt(42), big.NewInt(10))
signedTx3, err := wallet.SignTxEIP155(account, tx, big.NewInt(41))
if err != nil {
t.Error(err)
}
Expand Down

0 comments on commit d6c3b60

Please sign in to comment.