Skip to content
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

rpc/jsonrpc/types: Add tests for new mix types. #3274

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions rpc/jsonrpc/types/chainsvrcmds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,17 @@ func TestChainSvrCmds(t *testing.T) {
marshalled: `{"jsonrpc":"1.0","method":"getmininginfo","params":[],"id":1}`,
unmarshalled: &GetMiningInfoCmd{},
},
{
name: "getmixpairrequests",
newCmd: func() (interface{}, error) {
return dcrjson.NewCmd(Method("getmixpairrequests"))
},
staticCmd: func() interface{} {
return NewGetMixPairRequestsCmd()
},
marshalled: `{"jsonrpc":"1.0","method":"getmixpairrequests","params":[],"id":1}`,
unmarshalled: &GetMixPairRequestsCmd{},
},
{
name: "getnetworkinfo",
newCmd: func() (interface{}, error) {
Expand Down Expand Up @@ -814,6 +825,20 @@ func TestChainSvrCmds(t *testing.T) {
marshalled: `{"jsonrpc":"1.0","method":"ping","params":[],"id":1}`,
unmarshalled: &PingCmd{},
},
{
name: "sendrawmixmessage",
newCmd: func() (interface{}, error) {
return dcrjson.NewCmd(Method("sendrawmixmessage"), "mixpairrequest", "1122")
},
staticCmd: func() interface{} {
return NewSendRawMixMessageCmd("mixpairrequest", "1122")
},
marshalled: `{"jsonrpc":"1.0","method":"sendrawmixmessage","params":["mixpairrequest","1122"],"id":1}`,
unmarshalled: &SendRawMixMessageCmd{
Command: "mixpairrequest",
Message: "1122",
},
},
{
name: "sendrawtransaction",
newCmd: func() (interface{}, error) {
Expand Down
4 changes: 2 additions & 2 deletions rpc/jsonrpc/types/chainsvrwscmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ func NewNotifyMixMessagesCmd() *NotifyMixMessagesCmd {
// StopNotifyMixMessagesCmd defines the stopnotifymixmessages JSON-RPC command.
type StopNotifyMixMessagesCmd struct{}

// StopNewNotifyMixMessagesCmd returns a new instance which can be used to issue a
// NewStopNewNotifyMixMessagesCmd returns a new instance which can be used to issue a
// stopnotifymixmessages JSON-RPC command.
func StopNewNotifyMixMessagesCmd() *StopNotifyMixMessagesCmd {
func NewStopNewNotifyMixMessagesCmd() *StopNotifyMixMessagesCmd {
return &StopNotifyMixMessagesCmd{}
}

Expand Down
22 changes: 22 additions & 0 deletions rpc/jsonrpc/types/chainsvrwscmds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,28 @@ func TestChainSvrWsCmds(t *testing.T) {
marshalled: `{"jsonrpc":"1.0","method":"stopnotifytspend","params":[],"id":1}`,
unmarshalled: &StopNotifyTSpendCmd{},
},
{
name: "notifymixmessages",
newCmd: func() (interface{}, error) {
return dcrjson.NewCmd(Method("notifymixmessages"))
},
staticCmd: func() interface{} {
return NewNotifyMixMessagesCmd()
},
marshalled: `{"jsonrpc":"1.0","method":"notifymixmessages","params":[],"id":1}`,
unmarshalled: &NotifyMixMessagesCmd{},
},
{
name: "stopnotifymixmessages",
newCmd: func() (interface{}, error) {
return dcrjson.NewCmd(Method("stopnotifymixmessages"))
},
staticCmd: func() interface{} {
return NewStopNewNotifyMixMessagesCmd()
},
marshalled: `{"jsonrpc":"1.0","method":"stopnotifymixmessages","params":[],"id":1}`,
unmarshalled: &StopNotifyMixMessagesCmd{},
},
{
name: "notifynewtransactions",
newCmd: func() (interface{}, error) {
Expand Down
14 changes: 14 additions & 0 deletions rpc/jsonrpc/types/chainsvrwsntfns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,20 @@ func TestChainSvrWsNtfns(t *testing.T) {
Tickets: map[string]string{"a": "b"},
},
},
{
name: "mixmessage",
newNtfn: func() (interface{}, error) {
return dcrjson.NewCmd(Method("mixmessage"), "mixpairrequest", "1122")
},
staticNtfn: func() interface{} {
return NewMixMessageNtfn("mixpairrequest", "1122")
},
marshalled: `{"jsonrpc":"1.0","method":"mixmessage","params":["mixpairrequest","1122"],"id":null}`,
unmarshalled: &MixMessageNtfn{
Command: "mixpairrequest",
Payload: "1122",
},
},
}

t.Logf("Running %d tests", len(tests))
Expand Down
Loading