forked from btcsuite/btcwallet
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request btcsuite#910 from yyforyongyu/add-mempool-lookup
chain: add mempool lookup for outpoints
- Loading branch information
Showing
7 changed files
with
226 additions
and
42 deletions.
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
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
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,58 @@ | ||
package chain | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/btcsuite/btcd/chaincfg" | ||
"github.com/btcsuite/btcd/rpcclient" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestValidateConfig checks the `validate` method on the RPCClientConfig | ||
// behaves as expected. | ||
func TestValidateConfig(t *testing.T) { | ||
t.Parallel() | ||
|
||
rt := require.New(t) | ||
|
||
// ReconnectAttempts must be positive. | ||
cfg := &RPCClientConfig{ | ||
ReconnectAttempts: -1, | ||
} | ||
rt.ErrorContains(cfg.validate(), "reconnectAttempts") | ||
|
||
// Must specify a chain params. | ||
cfg = &RPCClientConfig{ | ||
ReconnectAttempts: 1, | ||
} | ||
rt.ErrorContains(cfg.validate(), "chain params") | ||
|
||
// Must specify a connection config. | ||
cfg = &RPCClientConfig{ | ||
ReconnectAttempts: 1, | ||
Chain: &chaincfg.Params{}, | ||
} | ||
rt.ErrorContains(cfg.validate(), "conn config") | ||
|
||
// Must specify a certificate when using TLS. | ||
cfg = &RPCClientConfig{ | ||
ReconnectAttempts: 1, | ||
Chain: &chaincfg.Params{}, | ||
Conn: &rpcclient.ConnConfig{}, | ||
} | ||
rt.ErrorContains(cfg.validate(), "certs") | ||
|
||
// Validate config. | ||
cfg = &RPCClientConfig{ | ||
ReconnectAttempts: 1, | ||
Chain: &chaincfg.Params{}, | ||
Conn: &rpcclient.ConnConfig{ | ||
DisableTLS: true, | ||
}, | ||
} | ||
rt.NoError(cfg.validate()) | ||
|
||
// When a nil config is provided, it should return an error. | ||
_, err := NewRPCClientWithConfig(nil) | ||
rt.ErrorContains(err, "missing rpc config") | ||
} |
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