-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
utility for running core harness tests #1632
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
//go:build harness && lgpl | ||
|
||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
|
||
"decred.org/dcrdex/client/core" | ||
"decred.org/dcrdex/dex" | ||
) | ||
|
||
func main() { | ||
var baseSymbol, quoteSymbol, base1Node, quote1Node, base2Node, quote2Node, regAsset string | ||
var base1SPV, quote1SPV, base2SPV, quote2SPV, debug, trace, list bool | ||
var tests flagArray | ||
flag.Var(&tests, "t", "the test(s) to run. multiple --t flags OK") | ||
flag.StringVar(&baseSymbol, "base", "dcr", "the bot program to run") | ||
flag.StringVar("eSymbol, "quote", "btc", "the bot program to run") | ||
flag.StringVar(&base1Node, "base1node", "beta", "the harness node to connect to for the first client's base asset. only RPC wallets") | ||
flag.StringVar("e1Node, "quote1node", "beta", "the harness node to connect to for the first client's quote asset. only RPC wallets") | ||
flag.StringVar(&base2Node, "base2node", "gamma", "the harness node to connect to for the second client's base asset. only RPC wallets") | ||
flag.StringVar("e2Node, "quote2node", "gamma", "the harness node to connect to for the second client's quote asset. only RPC wallets") | ||
flag.StringVar(®Asset, "regasset", "", "the asset to use for registration. default is base asset") | ||
flag.BoolVar(&base1SPV, "base1spv", false, "use SPV wallet for the first client's base asset") | ||
flag.BoolVar("e1SPV, "quote1spv", false, "use SPV wallet for the first client's quote asset") | ||
flag.BoolVar(&base2SPV, "base2spv", false, "use SPV wallet for the second client's base asset") | ||
flag.BoolVar("e2SPV, "quote2spv", false, "use SPV wallet for the second client's quote asset") | ||
flag.BoolVar(&list, "list", false, "list available tests") | ||
flag.BoolVar(&debug, "debug", false, "log at logging level debug") | ||
flag.BoolVar(&trace, "trace", false, "log at logging level trace") | ||
flag.Parse() | ||
|
||
if list { | ||
for _, s := range core.SimTests() { | ||
fmt.Println(s) | ||
} | ||
return | ||
} | ||
|
||
logLevel := dex.LevelInfo | ||
switch { | ||
case trace: | ||
logLevel = dex.LevelTrace | ||
case debug: | ||
logLevel = dex.LevelDebug | ||
} | ||
|
||
if len(tests) == 0 { | ||
tests = []string{"success"} | ||
} | ||
|
||
if regAsset == "" { | ||
regAsset = baseSymbol | ||
} | ||
|
||
err := core.RunSimulationTest(&core.SimulationConfig{ | ||
BaseSymbol: baseSymbol, | ||
QuoteSymbol: quoteSymbol, | ||
RegistrationAsset: regAsset, | ||
Client1: &core.SimClient{ | ||
BaseSPV: base1SPV, | ||
QuoteSPV: quote1SPV, | ||
BaseNode: base1Node, | ||
QuoteNode: quote1Node, | ||
}, | ||
Client2: &core.SimClient{ | ||
BaseSPV: base2SPV, | ||
QuoteSPV: quote2SPV, | ||
BaseNode: base2Node, | ||
QuoteNode: quote2Node, | ||
}, | ||
Tests: tests, | ||
Logger: dex.StdOutLogger("T", logLevel), | ||
}) | ||
if err != nil { | ||
fmt.Println("ERROR:", err) | ||
} else { | ||
fmt.Println("SUCCESS!") | ||
} | ||
} | ||
|
||
type flagArray []string | ||
|
||
func (f *flagArray) String() string { | ||
return "my string representation" | ||
} | ||
|
||
func (f *flagArray) Set(value string) error { | ||
*f = append(*f, value) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
go build -tags lgpl,harness | ||
|
||
case $1 in | ||
|
||
dcrbtc) | ||
./simnet-trade-tests --base1node trading1 --base2node trading2 ${@:2} | ||
;; | ||
|
||
dcrbtcspv) | ||
./simnet-trade-tests --base1node trading1 --base2node trading2 --quote1spv ${@:2} | ||
;; | ||
|
||
bchdcr) | ||
./simnet-trade-tests --base bch --quote dcr --quote1node trading1 --quote2node trading2 \ | ||
--regasset dcr ${@:2} | ||
;; | ||
|
||
ltcdcr) | ||
./simnet-trade-tests --base ltc --quote dcr --quote1node trading1 --quote2node trading2 \ | ||
--regasset dcr ${@:2} | ||
;; | ||
|
||
dcrdoge) | ||
./simnet-trade-tests --base1node trading1 --base2node trading2 --quote doge ${@:2} | ||
;; | ||
|
||
dcreth) | ||
./simnet-trade-tests --base1node trading1 --base2node trading2 --quote eth ${@:2} | ||
;; | ||
|
||
help|--help|-h) | ||
./simnet-trade-tests --help | ||
cat <<EOF | ||
|
||
--------------------- | ||
|
||
The following pre-configured tests are available. Be sure to run the appropriate harnesses before running the dcrdex server harness. | ||
|
||
dcrbtc - RPC wallets on DCR-BTC market | ||
dcrbtcspv - Decred RPC wallet and Bitcoin SPV wallet on DCR-BTC market | ||
bchdcr - RPC wallets on BCH-DCR market | ||
ltcdcr - RPC wallets on LTC-DCR market | ||
dcrdoge - RPC wallets on DCR-DOGE market | ||
dcreth - Decred RPC wallet and Ethereum native wallet on DCR-ETH market | ||
|
||
--------------------- | ||
|
||
One or more of the following tests can be run by specifying one or more -t flags. Default is ['success']. | ||
|
||
EOF | ||
|
||
./simnet-trade-tests --list | ||
;; | ||
|
||
*) | ||
echo -n "unknown program" | ||
;; | ||
esac |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file needs the
chmod +x
. Also can it be namedrun.sh
?