-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* validate chat before persisting * add comment to public key generation
- Loading branch information
Showing
11 changed files
with
128 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.43.0 | ||
0.43.1 |
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,72 @@ | ||
package protocol | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type ChatTestSuite struct { | ||
suite.Suite | ||
} | ||
|
||
func TestChatSuite(t *testing.T) { | ||
suite.Run(t, new(ChatTestSuite)) | ||
} | ||
|
||
func (s *ChatTestSuite) TestValidateChat() { | ||
testCases := []struct { | ||
Name string | ||
Valid bool | ||
Chat Chat | ||
}{ | ||
{ | ||
Name: "valid one to one chat", | ||
Valid: true, | ||
Chat: Chat{ | ||
ID: "0x0424a68f89ba5fcd5e0640c1e1f591d561fa4125ca4e2a43592bc4123eca10ce064e522c254bb83079ba404327f6eafc01ec90a1444331fe769d3f3a7f90b0dde1", | ||
Name: "", | ||
ChatType: ChatTypeOneToOne, | ||
}, | ||
}, | ||
{ | ||
Name: "valid public chat", | ||
Valid: true, | ||
Chat: Chat{ | ||
ID: "status", | ||
Name: "status", | ||
ChatType: ChatTypePublic, | ||
}, | ||
}, | ||
{ | ||
Name: "empty chatID", | ||
Valid: false, | ||
Chat: Chat{ | ||
ID: "", | ||
Name: "status", | ||
ChatType: ChatTypePublic, | ||
}, | ||
}, | ||
{ | ||
Name: "invalid one to one chat, wrong public key", | ||
Valid: false, | ||
Chat: Chat{ | ||
ID: "0xnotvalid", | ||
Name: "", | ||
ChatType: ChatTypeOneToOne, | ||
}, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
s.Run(tc.Name, func() { | ||
err := tc.Chat.Validate() | ||
if tc.Valid { | ||
s.Require().NoError(err) | ||
} else { | ||
s.Require().Error(err) | ||
} | ||
}) | ||
} | ||
|
||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
vendor/github.com/status-im/status-go/protocol/identity/alias/generate.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
vendor/github.com/status-im/status-go/protocol/persistence.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.