Skip to content

Commit

Permalink
client/eth: Use bytes as string in key import.
Browse files Browse the repository at this point in the history
This change is needed because unlocking will use the bytes as a string.

Also set the simnet contract address.
  • Loading branch information
JoeGruffins authored Dec 11, 2021
1 parent bd1d3b2 commit fbff9b6
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 77 deletions.
39 changes: 0 additions & 39 deletions client/asset/eth/config.go

This file was deleted.

4 changes: 0 additions & 4 deletions client/asset/eth/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ var (
minGasTipCap = dexeth.GweiToWei(2)
)

// Check that Driver implements asset.Driver.
var _ asset.Driver = (*Driver)(nil)
var _ asset.Creator = (*Driver)(nil)

// Driver implements asset.Driver.
type Driver struct{}

Expand Down
28 changes: 0 additions & 28 deletions client/asset/eth/eth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,34 +185,6 @@ func (n *testNode) transactionConfirmations(context.Context, common.Hash) (uint3
return 0, nil
}

func TestLoadConfig(t *testing.T) {
tests := []struct {
name string
network dex.Network
wantErr bool
}{{
name: "ok",
network: dex.Simnet,
}, {
name: "mainnet not allowed",
network: dex.Mainnet,
wantErr: true,
}}

for _, test := range tests {
_, err := loadConfig(nil, test.network)
if test.wantErr {
if err == nil {
t.Fatalf("expected error for test %v", test.name)
}
continue
}
if err != nil {
t.Fatalf("unexpected error for test %v: %v", test.name, err)
}
}
}

func TestCheckForNewBlocks(t *testing.T) {
header0 := &types.Header{Number: new(big.Int)}
block0 := types.NewBlockWithHeader(header0)
Expand Down
3 changes: 1 addition & 2 deletions client/asset/eth/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package eth
import (
"bytes"
"crypto/ecdsa"
"encoding/hex"
"encoding/json"
"fmt"
"os"
Expand Down Expand Up @@ -271,7 +270,7 @@ func importKeyToNode(node *node.Node, privateKey, password []byte) error {
ks := backends[0].(*keystore.KeyStore)
accounts := ks.Accounts()
if len(accounts) == 0 {
_, err = ks.ImportECDSA(ecdsaPrivateKey, hex.EncodeToString(password))
_, err = ks.ImportECDSA(ecdsaPrivateKey, string(password))
return err
} else if len(accounts) == 1 {
address := crypto.PubkeyToAddress(ecdsaPrivateKey.PublicKey)
Expand Down
3 changes: 1 addition & 2 deletions client/asset/eth/nodeclient_harness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,10 @@ func setupWallet(walletDir, seed, listenAddress string) error {
"nodelistenaddr": listenAddress,
}
seedB, _ := hex.DecodeString(seed)
walletPass, _ := hex.DecodeString(pw)
createWalletParams := asset.CreateWalletParams{
Type: walletTypeGeth,
Seed: seedB,
Pass: walletPass,
Pass: []byte(pw),
Settings: settings,
DataDir: walletDir,
Net: dex.Simnet,
Expand Down
2 changes: 1 addition & 1 deletion client/cmd/dexcctl/simnet-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fi

if [ $ETH_ON -eq 0 ]; then
echo configuring Eth wallet
./dexcctl -p abc -p "" --simnet newwallet 60 geth "" '{"appDir":"~/dextest/eth/testnode"}'
./dexcctl -p abc -p "" --simnet newwallet 60 geth
fi

echo registering with DEX
Expand Down
2 changes: 1 addition & 1 deletion dex/networks/eth/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
ContractAddresses = map[uint32]map[dex.Network]common.Address{
0: {
dex.Mainnet: common.Address{},
dex.Simnet: common.Address{},
dex.Simnet: common.HexToAddress("0x2f68e723b8989ba1c6a9f03e42f33cb7dc9d606f"),
dex.Testnet: common.Address{},
},
}
Expand Down

0 comments on commit fbff9b6

Please sign in to comment.