-
Notifications
You must be signed in to change notification settings - Fork 121
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
loadtest: prepare for multiple consecutive runs #550
Changes from all commits
e43cd37
78eb5c2
5559c4d
af03764
e5d4a15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ import ( | |
"testing" | ||
"time" | ||
|
||
"github.com/btcsuite/btcd/btcutil" | ||
"github.com/btcsuite/btcd/chaincfg" | ||
"github.com/btcsuite/btcd/chaincfg/chainhash" | ||
"github.com/btcsuite/btcd/rpcclient" | ||
"github.com/btcsuite/btcd/wire" | ||
|
@@ -20,7 +22,9 @@ import ( | |
) | ||
|
||
var ( | ||
zeroHash chainhash.Hash | ||
zeroHash chainhash.Hash | ||
regtestMiningAddr = "n1VgRjYDzJT2TV72PnungWgWu18SWorXZS" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is seed generation by the nodes deterministic? Do we need to also move to simnet, so bitcoind won't wipe the chain on start up? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just to send to No, it's |
||
regtestParams = &chaincfg.RegressionNetParams | ||
) | ||
|
||
// CopyRequest is a helper function to copy a request so that we can modify it. | ||
|
@@ -101,9 +105,29 @@ func MineBlocks(t *testing.T, client *rpcclient.Client, | |
|
||
blocks := make([]*wire.MsgBlock, num) | ||
|
||
blockHashes, err := client.Generate(num) | ||
if err != nil { | ||
t.Fatalf("unable to generate blocks: %v", err) | ||
backend, err := client.BackendVersion() | ||
require.NoError(t, err) | ||
|
||
var blockHashes []*chainhash.Hash | ||
|
||
switch backend { | ||
case rpcclient.BitcoindPost19: | ||
addr, err := btcutil.DecodeAddress( | ||
regtestMiningAddr, regtestParams, | ||
) | ||
require.NoError(t, err) | ||
|
||
blockHashes, err = client.GenerateToAddress( | ||
int64(num), addr, nil, | ||
) | ||
require.NoError(t, err) | ||
|
||
case rpcclient.Btcd: | ||
blockHashes, err = client.Generate(num) | ||
require.NoError(t, err) | ||
|
||
default: | ||
require.Fail(t, "unknown chain backend: %v", backend) | ||
} | ||
|
||
for i, blockHash := range blockHashes { | ||
|
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.
Wouldn't this just fail the test either way?
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.
Yeah, but before it was a mixture of
require
and returning an error. And now we just dot.Fatalf()
directly instead of returning the error and then doingrequire.NoError()
outside.