This repository has been archived by the owner on Nov 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Update application registry when chains change. #42
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c8e16a4
different chains
b81dd88
Merge branch 'main' into bug/41/applications-stake-change
nodiesBlade 69bdf4b
update chains stake
37aa96f
Merge branch 'bug/41/applications-stake-change' of github.com:baaspoo…
a4f6f65
update
6de11ae
update comments
f311952
update to reflect same cahins different ordering
45a6efb
Merge branch 'main' into bug/41/applications-stake-change
nodiesBlade 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package apps_registry | ||
|
||
import ( | ||
"github.com/pokt-network/gateway-server/internal/apps_registry/models" | ||
pokt_models "github.com/pokt-network/gateway-server/pkg/pokt/pokt_v0/models" | ||
"testing" | ||
) | ||
|
||
func Test_arePoktApplicationSignersEqual(t *testing.T) { | ||
type args struct { | ||
slice1 []*models.PoktApplicationSigner | ||
slice2 []*models.PoktApplicationSigner | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want bool | ||
}{ | ||
{ | ||
name: "different length", | ||
args: args{ | ||
slice1: []*models.PoktApplicationSigner{}, | ||
slice2: []*models.PoktApplicationSigner{{NetworkApp: &pokt_models.PoktApplication{ | ||
Address: "123", | ||
Chains: []string{"123", "123"}, | ||
PublicKey: "", | ||
Status: 0, | ||
MaxRelays: 0, | ||
}}}, | ||
}, | ||
want: false, | ||
}, | ||
{ | ||
name: "different address", | ||
args: args{ | ||
slice1: []*models.PoktApplicationSigner{{NetworkApp: &pokt_models.PoktApplication{ | ||
Address: "1234", | ||
Chains: []string{"123", "123"}, | ||
PublicKey: "", | ||
Status: 0, | ||
MaxRelays: 0, | ||
}}}, | ||
slice2: []*models.PoktApplicationSigner{{NetworkApp: &pokt_models.PoktApplication{ | ||
Address: "123", | ||
Chains: []string{"123", "123"}, | ||
PublicKey: "", | ||
Status: 0, | ||
MaxRelays: 0, | ||
}}}, | ||
}, | ||
want: false, | ||
}, | ||
{ | ||
name: "different chains", | ||
args: args{ | ||
slice1: []*models.PoktApplicationSigner{{NetworkApp: &pokt_models.PoktApplication{ | ||
Address: "1234", | ||
Chains: []string{"123", "123"}, | ||
PublicKey: "", | ||
Status: 0, | ||
MaxRelays: 0, | ||
}}}, | ||
slice2: []*models.PoktApplicationSigner{{NetworkApp: &pokt_models.PoktApplication{ | ||
Address: "123", | ||
Chains: []string{"123"}, | ||
PublicKey: "", | ||
Status: 0, | ||
MaxRelays: 0, | ||
}}}, | ||
}, | ||
want: false, | ||
}, | ||
{ | ||
name: "same apps", | ||
args: args{ | ||
slice1: []*models.PoktApplicationSigner{{NetworkApp: &pokt_models.PoktApplication{ | ||
Address: "123", | ||
Chains: []string{"123", "123"}, | ||
PublicKey: "", | ||
Status: 0, | ||
MaxRelays: 0, | ||
}}}, | ||
slice2: []*models.PoktApplicationSigner{{NetworkApp: &pokt_models.PoktApplication{ | ||
Address: "123", | ||
Chains: []string{"123", "123"}, | ||
PublicKey: "", | ||
Status: 0, | ||
MaxRelays: 0, | ||
}}}, | ||
}, | ||
want: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := arePoktApplicationSignersEqual(tt.args.slice1, tt.args.slice2); got != tt.want { | ||
t.Errorf("arePoktApplicationSignersEqual() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
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.
@nodiesBlade what if the order of Chain IDs is different for two applications?
Let's say:
I don't know if
Chains
are ordered before assigning toPoktApplication
, but it is better not to rely on string concatenation equality.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.
+ worth adding a unit test for such a case.
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.
Due to the nature of blockchain and how hashing works, if the chains ordering change, i would argue the application is still technically different and we should recache it. and so that's why I took a little shortcut.
Though I'm glad you mentioned it as well, wouldn't mind adding the extra security. will push up some changes for it
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.
Yeah, I was talking only about the way Chains were compared.
Absolutely agree with what you say about Applications equivalency on different Chains order. No need to re-cache such.