-
Notifications
You must be signed in to change notification settings - Fork 48
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
Leonardo/users relationship impl #260
Merged
Merged
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
989e47c
reviewed `profiles` folders organization
leobragaz 321420f
added relationship types and methods + tests
leobragaz c468f20
added relationships messages and tests + keys
leobragaz 813cce0
added msg delete relationship + tests
leobragaz 1dc2d05
started developing keeper methods
leobragaz ff38990
added keeper methods and handler
leobragaz e44cba4
edited the way relations are handled inside keeper,
leobragaz 22740ed
completed handler's and keeper's relationships methods
leobragaz 3dff7d7
fixed msgs and keeper tests
leobragaz f20fef7
added handler tests
leobragaz 3aa5a79
added querier method
leobragaz b0f0ee5
added cli tests
leobragaz d932f30
added simulation tests for relationships msgs
leobragaz b925022
added methods for genesis
leobragaz b6da0e0
added initialization of new data structures to init genesis
leobragaz 47725b6
Merge branch 'master' of https://github.com/desmos-labs/desmos into l…
leobragaz 493f2a6
merged with master
leobragaz ac79300
fixed sim tests
leobragaz 9f93900
raised gas to make sim tests pass
leobragaz c4923ca
added tests to raise coverage
leobragaz 8236487
Merge branch 'master' of https://github.com/desmos-labs/desmos into l…
leobragaz bcfe6dc
Merge branch 'master' of https://github.com/desmos-labs/desmos into l…
leobragaz 8f745a4
added docs lines to handler
leobragaz 851e748
added tests to raise coverage
leobragaz 479d8dd
fixed relationships as discussed in morning call
leobragaz fd9d43d
fixed sims tests
leobragaz 5735392
added relationships response
leobragaz 536623e
raise coverage
leobragaz 7d2ee3f
fixed refactoring errors
leobragaz 359bae7
fixed refactoring errors
leobragaz 91068ab
fixed refactoring errors
leobragaz 7f3a6bf
fixed refactoring errors
leobragaz 90c6679
moved all relationships related files
leobragaz 3d50e7e
added dontcover to sim files
leobragaz 31cd7cc
added new query for all relationships
leobragaz cc1366c
added a query to retrieve all the relationships
leobragaz ebc47f6
renamed query and message
leobragaz a720170
fixed PR's suggestions:
leobragaz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// +build cli_test | ||
|
||
//nolint | ||
package clitest | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/tests" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/desmos-labs/desmos/x/relationships/types" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestDesmosCLICreateMonoDirectionalRelationship(t *testing.T) { | ||
t.Parallel() | ||
f := InitFixtures(t) | ||
|
||
// Start Desmosd server | ||
proc := f.GDStart() | ||
defer proc.Stop(false) | ||
|
||
// Save key addresses for later use | ||
fooAddr := f.KeyAddress(keyFoo) | ||
|
||
// Later usage variables | ||
fooAcc := f.QueryAccount(fooAddr) | ||
startTokens := sdk.TokensFromConsensusPower(140) | ||
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom)) | ||
receiver, err := sdk.AccAddressFromBech32("desmos15ux5mc98jlhsg30dzwwv06ftjs82uy4g3t99ru") | ||
require.NoError(t, err) | ||
|
||
// Create mono directional relationship | ||
success, _, sterr := f.TxCreateRelationship(receiver, fooAddr, "-y") | ||
require.True(t, success) | ||
require.Empty(t, sterr) | ||
tests.WaitForNextNBlocksTM(1, f.Port) | ||
|
||
// Make sure relationship is created | ||
storedRelationships := f.QueryRelationships(fooAddr) | ||
require.NotEmpty(t, storedRelationships) | ||
expRelationship := types.NewRelationshipResponse([]sdk.AccAddress{receiver}) | ||
require.Equal(t, expRelationship, storedRelationships) | ||
|
||
// Delete the relationship to perform other tests | ||
success, _, sterr = f.TxDeleteUserRelationship(receiver, fooAddr, "-y") | ||
require.True(t, success) | ||
require.Empty(t, sterr) | ||
tests.WaitForNextNBlocksTM(1, f.Port) | ||
|
||
// Test --dry-tun | ||
success, _, _ = f.TxCreateRelationship(receiver, fooAddr, "--dry-run") | ||
require.True(t, success) | ||
|
||
// Test --generate-only | ||
success, stdout, stderr := f.TxCreateRelationship(receiver, fooAddr, "--generate-only=true") | ||
require.Empty(t, stderr) | ||
require.True(t, success) | ||
msg := unmarshalStdTx(f.T, stdout) | ||
require.NotZero(t, msg.Fee.Gas) | ||
require.Len(t, msg.Msgs, 1) | ||
require.Len(t, msg.GetSignatures(), 0) | ||
|
||
f.Cleanup() | ||
} | ||
|
||
func TestDesmosCLIDeleteRelationship(t *testing.T) { | ||
t.Parallel() | ||
f := InitFixtures(t) | ||
|
||
// Start Desmosd server | ||
proc := f.GDStart() | ||
defer proc.Stop(false) | ||
|
||
// Save key addresses for later use | ||
fooAddr := f.KeyAddress(keyFoo) | ||
|
||
// Later usage variables | ||
fooAcc := f.QueryAccount(fooAddr) | ||
startTokens := sdk.TokensFromConsensusPower(140) | ||
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom)) | ||
receiver, err := sdk.AccAddressFromBech32("desmos15ux5mc98jlhsg30dzwwv06ftjs82uy4g3t99ru") | ||
require.NoError(t, err) | ||
|
||
// Create mono directional relationship | ||
success, _, sterr := f.TxCreateRelationship(receiver, fooAddr, "-y") | ||
require.True(t, success) | ||
require.Empty(t, sterr) | ||
tests.WaitForNextNBlocksTM(1, f.Port) | ||
|
||
// Make sure relationship is created | ||
storedRelationships := f.QueryRelationships(fooAddr) | ||
require.NotEmpty(t, storedRelationships) | ||
expRelationship := types.NewRelationshipResponse([]sdk.AccAddress{receiver}) | ||
require.Equal(t, expRelationship, storedRelationships) | ||
|
||
// Delete the relationship to perform other tests | ||
success, _, sterr = f.TxDeleteUserRelationship(receiver, fooAddr, "-y") | ||
require.True(t, success) | ||
require.Empty(t, sterr) | ||
tests.WaitForNextNBlocksTM(1, f.Port) | ||
|
||
// Make sure relationship is deleted | ||
storedRelationships = f.QueryRelationships(fooAddr) | ||
require.Empty(t, storedRelationships) | ||
|
||
// Create mono directional relationship | ||
success, _, sterr = f.TxCreateRelationship(receiver, fooAddr, "-y") | ||
|
||
// Test --dry-tun | ||
success, _, _ = f.TxDeleteUserRelationship(receiver, fooAddr, "--dry-run") | ||
require.True(t, success) | ||
|
||
// Test --generate-only | ||
success, stdout, stderr := f.TxDeleteUserRelationship(receiver, fooAddr, "--generate-only=true") | ||
require.Empty(t, stderr) | ||
require.True(t, success) | ||
msg := unmarshalStdTx(f.T, stdout) | ||
require.NotZero(t, msg.Fee.Gas) | ||
require.Len(t, msg.Msgs, 1) | ||
require.Len(t, msg.GetSignatures(), 0) | ||
|
||
f.Cleanup() | ||
} |
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,38 @@ | ||||
# `MsgCreateRelationship` | ||||
This message allows you to create a mono directional relationship with a specified user. | ||||
Mono directional relationships are like the follow of today's social networks. | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
|
||||
## Structure | ||||
```json | ||||
{ | ||||
"type": "desmos/MsgCreateRelationship", | ||||
"value": { | ||||
"sender": "<Desmos address that's creating the relationship>", | ||||
"receiver": "<Desmos address that's receiving the relationship>" | ||||
} | ||||
} | ||||
``` | ||||
|
||||
### Attributes | ||||
| Attribute | Type | Description | | ||||
| :-------: | :----: | :-------- | | ||||
| `sender` | String | Desmos address of the user that is creating the relationship | | ||||
| `receiver`| String | Desmos address of the relationship's recipient | | ||||
|
||||
## Example | ||||
````json | ||||
{ | ||||
"type": "desmos/MsgCreateRelationship", | ||||
"value": { | ||||
"sender": "desmos1e209r8nc8qdkmqujahwrq4xrlxhk3fs9k7yzmw", | ||||
"receiver": "desmos13p5pamrljhza3fp4es5m3llgmnde5fzcpq6nud" | ||||
} | ||||
} | ||||
```` | ||||
|
||||
## Message action | ||||
The action associated to this message is the following: | ||||
|
||||
``` | ||||
create_relationship | ||||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.