diff options
author | Felix Lange <fjl@twurst.com> | 2019-09-11 20:41:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-11 20:41:22 +0800 |
commit | 39b0b1a1a6506c8c25fcff56f4d70a85739dcb6a (patch) | |
tree | 9a490d5d860a2cefdeb4c3c60a9def3d88cabbe9 /les | |
parent | 91b73495098c7941e3eb1c58a702952bf5acf1a6 (diff) | |
download | go-tangerine-39b0b1a1a6506c8c25fcff56f4d70a85739dcb6a.tar go-tangerine-39b0b1a1a6506c8c25fcff56f4d70a85739dcb6a.tar.gz go-tangerine-39b0b1a1a6506c8c25fcff56f4d70a85739dcb6a.tar.bz2 go-tangerine-39b0b1a1a6506c8c25fcff56f4d70a85739dcb6a.tar.lz go-tangerine-39b0b1a1a6506c8c25fcff56f4d70a85739dcb6a.tar.xz go-tangerine-39b0b1a1a6506c8c25fcff56f4d70a85739dcb6a.tar.zst go-tangerine-39b0b1a1a6506c8c25fcff56f4d70a85739dcb6a.zip |
all: make unit tests work with Go 1.13 (#20053)
Most of these changes are related to the Go 1.13 changes to test binary
flag handling.
* cmd/geth: make attach tests more reliable
This makes the test wait for the endpoint to come up by polling
it instead of waiting for two seconds.
* tests: fix test binary flags for Go 1.13
Calling flag.Parse during package initialization is prohibited
as of Go 1.13 and causes test failures. Call it in TestMain instead.
* crypto/ecies: remove useless -dump flag in tests
* p2p/simulations: fix test binary flags for Go 1.13
Calling flag.Parse during package initialization is prohibited
as of Go 1.13 and causes test failures. Call it in TestMain instead.
* build: remove workaround for ./... vendor matching
This workaround was necessary for Go 1.8. The Go 1.9 release changed
the expansion rules to exclude vendored packages.
* Makefile: use relative path for GOBIN
This makes the "Run ./build/bin/..." line look nicer.
* les: fix test binary flags for Go 1.13
Calling flag.Parse during package initialization is prohibited
as of Go 1.13 and causes test failures. Call it in TestMain instead.
Diffstat (limited to 'les')
-rw-r--r-- | les/api_test.go | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/les/api_test.go b/les/api_test.go index 7d3b4ce5d..660af8eee 100644 --- a/les/api_test.go +++ b/les/api_test.go @@ -43,11 +43,25 @@ import ( "github.com/mattn/go-colorable" ) -/* -This test is not meant to be a part of the automatic testing process because it -runs for a long time and also requires a large database in order to do a meaningful -request performance test. When testServerDataDir is empty, the test is skipped. -*/ +// Additional command line flags for the test binary. +var ( + loglevel = flag.Int("loglevel", 0, "verbosity of logs") + simAdapter = flag.String("adapter", "exec", "type of simulation: sim|socket|exec|docker") +) + +func TestMain(m *testing.M) { + flag.Parse() + log.PrintOrigins(true) + log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*loglevel), log.StreamHandler(colorable.NewColorableStderr(), log.TerminalFormat(true)))) + // register the Delivery service which will run as a devp2p + // protocol when using the exec adapter + adapters.RegisterServices(services) + os.Exit(m.Run()) +} + +// This test is not meant to be a part of the automatic testing process because it +// runs for a long time and also requires a large database in order to do a meaningful +// request performance test. When testServerDataDir is empty, the test is skipped. const ( testServerDataDir = "" // should always be empty on the master branch @@ -377,29 +391,13 @@ func getCapacityInfo(ctx context.Context, t *testing.T, server *rpc.Client) (min return } -func init() { - flag.Parse() - // register the Delivery service which will run as a devp2p - // protocol when using the exec adapter - adapters.RegisterServices(services) - - log.PrintOrigins(true) - log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*loglevel), log.StreamHandler(colorable.NewColorableStderr(), log.TerminalFormat(true)))) -} - -var ( - adapter = flag.String("adapter", "exec", "type of simulation: sim|socket|exec|docker") - loglevel = flag.Int("loglevel", 0, "verbosity of logs") - nodes = flag.Int("nodes", 0, "number of nodes") -) - var services = adapters.Services{ "lesclient": newLesClientService, "lesserver": newLesServerService, } func NewNetwork() (*simulations.Network, func(), error) { - adapter, adapterTeardown, err := NewAdapter(*adapter, services) + adapter, adapterTeardown, err := NewAdapter(*simAdapter, services) if err != nil { return nil, adapterTeardown, err } |