-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore custom messages that are not relevant to peerswap. Additionally, it refactors the existing message conversion logic for better clarity and maintainability. FIxes #305
- Loading branch information
1 parent
3cdcdbd
commit a671542
Showing
7 changed files
with
127 additions
and
134 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