-
Notifications
You must be signed in to change notification settings - Fork 242
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
Direct settings updates (API) #5237
Conversation
Jenkins BuildsClick to see older builds (32)
|
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.
Looks good. I'd just add some simple validation, since it comes from user inputs
@@ -20,10 +20,18 @@ func (m *Messenger) SetLogLevel(request *requests.SetLogLevel) error { | |||
return nodecfg.SetLogLevel(m.database, request.LogLevel) | |||
} | |||
|
|||
func (m *Messenger) SetMaxLogBackups(request *requests.SetMaxLogBackups) error { | |||
return nodecfg.SetMaxLogBackups(m.database, request.MaxLogBackups) |
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.
I wonder if we should do some validations on the request first? Like make sure MaxLogBackups
is not empty and not smaller than 0?
We have a couple Validate()
functions in the code to check the content of the requests
. You can take inspiration (copy paste 😄 )
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.
we should make it an uint, that's going to be granted that is 0 or greater
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.
Fixed
func (m *Messenger) SetCustomNodes(request *requests.SetCustomNodes) error { | ||
return nodecfg.SetWakuV2CustomNodes(m.database, request.CustomNodes) | ||
} | ||
|
||
func (m *Messenger) SaveNewWakuNode(request *requests.SaveNewWakuNode) error { | ||
return nodecfg.SaveNewWakuNode(m.database, request.NodeAddress) |
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.
Same thing here
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.
Added a fix.
I think it's a general check and we shouldn't be testing these here:
peer.AddrInfoFromP2pAddr
addr.ValueForProtocol
@friofry, can you please add a test for the new functions? This doesn't look good 🙂 ![]() |
package requests | ||
|
||
type SaveNewWakuNode struct { | ||
NodeAddress string `json:"nodeAddress"` |
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.
you want to validate this most likely
@friofry I think you forgot to push. There were no new changes |
3fcf2ec
to
5598aa1
Compare
Hey @igor-sirotin |
Yes, my mistake, it should be pushed now |
Added |
I don't mean that it should be 50. I mean it shouldn't be 0 😄 We discussed your PR today with the Snow Blowers crew, as a good example of when 50% threshold might not be reached because most of the added code is some wrapper functions. We're aware of this and We will exclude such API files from calculation for test coverage. Nevertheless, it's not expected to cover the 50% threshold now, my comment is actually about the We have many |
Now I got it, thanks for the example! I'll add a test for all these "direct" settings updaters |
230f96d
to
cdb936d
Compare
Done 👍 Added node_config_persistence_test.go |
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.
Thanks for the test, looks good! 👍
Left a few minor suggestions
} | ||
|
||
func (s *MessengerValidateRequestSuite) TestSaveNewWakuNodeRequestValidate_Enrtree() { | ||
alice := s.newMessenger() |
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.
- You can reuse
m
fromMessengerBaseTestSuite
- IF that one is not enough and you need to create another messenger instance, then use
newTestMessenger
var testWakuNodeEnrtree = "enrtree://AL65EKLJAUXKKPG43HVTML5EFFWEZ7L4LOKTLZCLJASG4DSESQZEC@prod.status.nodes.status.im" | ||
var testWakuNodeMultiaddr = "/ip4/127.0.0.1/tcp/34012" |
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.
var testWakuNodeEnrtree = "enrtree://AL65EKLJAUXKKPG43HVTML5EFFWEZ7L4LOKTLZCLJASG4DSESQZEC@prod.status.nodes.status.im" | |
var testWakuNodeMultiaddr = "/ip4/127.0.0.1/tcp/34012" | |
const ( | |
testWakuNodeEnrtree = "enrtree://AL65EKLJAUXKKPG43HVTML5EFFWEZ7L4LOKTLZCLJASG4DSESQZEC@prod.status.nodes.status.im" | |
testWakuNodeMultiaddr = "/ip4/127.0.0.1/tcp/34012" | |
) |
config, err := nodecfg.GetNodeConfigFromDB(s.db) | ||
s.Require().NoError(err) | ||
s.config = config |
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.
config, err := nodecfg.GetNodeConfigFromDB(s.db) | |
s.Require().NoError(err) | |
s.config = config | |
s.config, err = nodecfg.GetNodeConfigFromDB(s.db) | |
s.Require().NoError(err) |
054e5b3
to
721896d
Compare
* add waku nodeaddr and max log backups validation * Allow to set new waku node * Allow to set custom max backups * add tests
721896d
to
d2d463b
Compare
Adds 2 API endpoints for direct settings modification see status-im/status-desktop#12918
Closes status-im/status-desktop#12918
Further changes: