-
Notifications
You must be signed in to change notification settings - Fork 44
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 #315 from ElementsProject/custom-message-ignore
ignore non-peerswap related custom messages
- Loading branch information
Showing
7 changed files
with
127 additions
and
133 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,37 @@ | ||
package messages | ||
|
||
import "testing" | ||
|
||
func TestPeerswapCustomMessageType(t *testing.T) { | ||
t.Parallel() | ||
tests := map[string]struct { | ||
msgType string | ||
want MessageType | ||
wantErr bool | ||
}{ | ||
"swapinrequest": {msgType: MessageTypeToHexString(MESSAGETYPE_SWAPINREQUEST), want: MESSAGETYPE_SWAPINREQUEST}, | ||
"swapoutrequest": {msgType: MessageTypeToHexString(MESSAGETYPE_SWAPOUTREQUEST), want: MESSAGETYPE_SWAPOUTREQUEST}, | ||
"swapinagreement": {msgType: MessageTypeToHexString(MESSAGETYPE_SWAPINAGREEMENT), want: MESSAGETYPE_SWAPINAGREEMENT}, | ||
"swapoutagreement": {msgType: MessageTypeToHexString(MESSAGETYPE_SWAPOUTAGREEMENT), want: MESSAGETYPE_SWAPOUTAGREEMENT}, | ||
"openintxbroadcasted": {msgType: MessageTypeToHexString(MESSAGETYPE_OPENINGTXBROADCASTED), want: MESSAGETYPE_OPENINGTXBROADCASTED}, | ||
"canceled": {msgType: MessageTypeToHexString(MESSAGETYPE_CANCELED), want: MESSAGETYPE_CANCELED}, | ||
"coopclose": {msgType: MessageTypeToHexString(MESSAGETYPE_COOPCLOSE), want: MESSAGETYPE_COOPCLOSE}, | ||
"poll": {msgType: MessageTypeToHexString(MESSAGETYPE_POLL), want: MESSAGETYPE_POLL}, | ||
"request_poll": {msgType: MessageTypeToHexString(MESSAGETYPE_REQUEST_POLL), want: MESSAGETYPE_REQUEST_POLL}, | ||
"invalid": {msgType: "invalid", wantErr: true}, | ||
} | ||
for name, tt := range tests { | ||
tt := tt | ||
t.Run(name, func(t *testing.T) { | ||
t.Parallel() | ||
got, err := PeerswapCustomMessageType(tt.msgType) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("PeerswapCustomMessageType() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if got != tt.want { | ||
t.Errorf("PeerswapCustomMessageType() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
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