mirror of
https://github.com/btcsuite/btcd.git
synced 2024-11-19 01:40:07 +01:00
btcjson: add TestMempoolAcceptCmd
This commit is contained in:
parent
2ad8026a38
commit
ca4261f028
@ -1042,6 +1042,27 @@ func NewVerifyTxOutProofCmd(proof string) *VerifyTxOutProofCmd {
|
||||
}
|
||||
}
|
||||
|
||||
// TestMempoolAcceptCmd defines the testmempoolaccept JSON-RPC command.
|
||||
type TestMempoolAcceptCmd struct {
|
||||
// An array of hex strings of raw transactions.
|
||||
RawTxns []string
|
||||
|
||||
// Reject transactions whose fee rate is higher than the specified
|
||||
// value, expressed in BTC/kvB, optional, default="0.10".
|
||||
MaxFeeRate float64 `json:"omitempty"`
|
||||
}
|
||||
|
||||
// NewTestMempoolAcceptCmd returns a new instance which can be used to issue a
|
||||
// testmempoolaccept JSON-RPC command.
|
||||
func NewTestMempoolAcceptCmd(rawTxns []string,
|
||||
maxFeeRate float64) *TestMempoolAcceptCmd {
|
||||
|
||||
return &TestMempoolAcceptCmd{
|
||||
RawTxns: rawTxns,
|
||||
MaxFeeRate: maxFeeRate,
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
// No special flags for commands in this file.
|
||||
flags := UsageFlag(0)
|
||||
@ -1102,4 +1123,5 @@ func init() {
|
||||
MustRegisterCmd("verifychain", (*VerifyChainCmd)(nil), flags)
|
||||
MustRegisterCmd("verifymessage", (*VerifyMessageCmd)(nil), flags)
|
||||
MustRegisterCmd("verifytxoutproof", (*VerifyTxOutProofCmd)(nil), flags)
|
||||
MustRegisterCmd("testmempoolaccept", (*TestMempoolAcceptCmd)(nil), flags)
|
||||
}
|
||||
|
@ -1472,6 +1472,34 @@ func TestChainSvrCmds(t *testing.T) {
|
||||
marshalled: `{"jsonrpc":"1.0","method":"getzmqnotifications","params":[],"id":1}`,
|
||||
unmarshalled: &btcjson.GetZmqNotificationsCmd{},
|
||||
},
|
||||
{
|
||||
name: "testmempoolaccept",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("testmempoolaccept", []string{"rawhex"}, 0.1)
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewTestMempoolAcceptCmd([]string{"rawhex"}, 0.1)
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"testmempoolaccept","params":[["rawhex"],0.1],"id":1}`,
|
||||
unmarshalled: &btcjson.TestMempoolAcceptCmd{
|
||||
RawTxns: []string{"rawhex"},
|
||||
MaxFeeRate: 0.1,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "testmempoolaccept with maxfeerate",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("testmempoolaccept", []string{"rawhex"}, 0.01)
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewTestMempoolAcceptCmd([]string{"rawhex"}, 0.01)
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"testmempoolaccept","params":[["rawhex"],0.01],"id":1}`,
|
||||
unmarshalled: &btcjson.TestMempoolAcceptCmd{
|
||||
RawTxns: []string{"rawhex"},
|
||||
MaxFeeRate: 0.01,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
t.Logf("Running %d tests", len(tests))
|
||||
|
Loading…
Reference in New Issue
Block a user