Skip to content

Commit

Permalink
client,dex/testing: Code & script improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
xorzero777 committed Jul 10, 2023
1 parent 3ca5325 commit 987ac91
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 45 deletions.
13 changes: 6 additions & 7 deletions client/asset/firo/firo.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ func NewWallet(cfg *asset.WalletConfig, logger dex.Logger, network dex.Network)
Simnet: "28888",
}

var exw *btc.ExchangeWalletFullNode

cloneCFG := &btc.BTCCloneCFG{
WalletCFG: cfg,
MinNetworkVersion: minNetworkVersion,
Expand Down Expand Up @@ -168,21 +166,22 @@ func NewWallet(cfg *asset.WalletConfig, logger dex.Logger, network dex.Network)
AssetID: BipID,
FeeEstimator: estimateFee,
ExternalFeeEstimator: fetchExternalFee,
PrivKeyFunc: func(addr string) (*btcec.PrivateKey, error) {
return privKeyForAddress(exw, addr)
},
PrivKeyFunc: nil, // set only for walletTypeRPC below
}

switch cfg.Type {
case walletTypeRPC, walletTypeLegacy:
var exw *btc.ExchangeWalletFullNode
// override PrivKeyFunc - we Do need our own Firo dumpprivkey fn
cloneCFG.PrivKeyFunc = func(addr string) (*btcec.PrivateKey, error) {
return privKeyForAddress(exw, addr)
}
var err error
exw, err = btc.BTCCloneWallet(cloneCFG)
return exw, err
case walletTypeElectrum:
// override Ports - no default ports
cloneCFG.Ports = dexbtc.NetPorts{}
// electrum Does have a getbalance RPC
cloneCFG.LegacyBalance = false
return btc.ElectrumWallet(cloneCFG)
default:
return nil, fmt.Errorf("unknown wallet type %q for firo", cfg.Type)
Expand Down
8 changes: 4 additions & 4 deletions client/core/simnet_trade.go
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,10 @@ func bchWallet(wt SimWalletType, node string) (*tWallet, error) {
return btcCloneWallet(bch.BipID, node, wt)
}

func firoWallet(wt SimWalletType, node string) (*tWallet, error) {
return btcCloneWallet(firo.BipID, node, wt)
}

func ethWallet() (*tWallet, error) {
return &tWallet{
fund: true,
Expand Down Expand Up @@ -1713,10 +1717,6 @@ func dgbWallet(node string) (*tWallet, error) {
return btcCloneWallet(dgb.BipID, node, WTCoreClone)
}

func firoWallet(wt SimWalletType, node string) (*tWallet, error) {
return btcCloneWallet(firo.BipID, node, wt)
}

func zecWallet(node string) (*tWallet, error) {
return btcCloneWallet(zec.BipID, node, WTCoreClone)
}
Expand Down
35 changes: 1 addition & 34 deletions dex/testing/firo/harness.sh
Original file line number Diff line number Diff line change
@@ -1,41 +1,8 @@
#!/usr/bin/env bash

# This simnet harness sets up 4 Firo nodes and a set of herness controls
# This simnet harness sets up 4 Firo nodes and a set of harness controls
# Each node has a prepared, encrypted, empty wallet

# alpha/
# ├── alpha.conf
# └── regtest
# ├── wallet.dat

# beta/
# ├── beta.conf
# └── regtest
# ├── wallet.dat

# gamma/
# ├── gamma.conf
# └── regtest
# ├── wallet.dat

# delta/
# ├── delta.conf
# └── regtest
# ├── wallet.dat

# └── harness-ctl
# ├── alpha
# ├── beta
# ├── connect-alpha
# ├── delta
# ├── gamma
# ├── mine-alpha
# ├── mine-beta
# ├── quit
# ├── reorg
# ├── start-wallet
# └── stop-wallet

SYMBOL="firo"
DAEMON="firod"
CLI="firo-cli"
Expand Down
1 change: 1 addition & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ go test -c -o /dev/null -tags electrumlive ./client/asset/btc
go test -c -o /dev/null -tags harness ./client/asset/btc/livetest
go test -c -o /dev/null -tags harness ./client/asset/ltc
go test -c -o /dev/null -tags harness ./client/asset/bch
go test -c -o /dev/null -tags harness ./client/asset/firo
go test -c -o /dev/null -tags harness ./client/asset/eth
go test -c -o /dev/null -tags rpclive ./client/asset/eth
go test -c -o /dev/null -tags harness ./client/asset/zec
Expand Down

0 comments on commit 987ac91

Please sign in to comment.