-
Notifications
You must be signed in to change notification settings - Fork 116
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
[dot/rpc] implement RPC system_accountNextIndex #1376
Conversation
dot/rpc/modules/system.go
Outdated
if req == nil || len(req.String) == 0 { | ||
return errors.New("Account address must be valid") |
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.
maybe move this to the top of the function so it checks it first?
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.
good idea.
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!
Added check of pending transactions before looking in storage. codeclimate is complaining, so please take a re-look at this and let me know suggestions for cleaning it up. |
if sigNonce.Uint64() > nonce { | ||
nonce = sigNonce.Uint64() |
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.
wouldn't the nonce always be greater unless it's 0, in which case it's fine to directly set 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.
Yes, but there may be more than one tx signed by that user in the tx pool, so did this to make sure we have the maximum nonce.
dot/rpc/modules/system_test.go
Outdated
res := new(interface{}) | ||
err := sys.Properties(nil, nil, res) | ||
require.NoError(t, err) | ||
require.Equal(t, expected, *res) | ||
} | ||
|
||
func TestSystemModule_AccountNextIndex(t *testing.T) { |
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.
is it possible to add a test for the non-pending 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.
Yes, I've added tests.
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.
nice work!
Edward Mack: [dot/rpc] implement RPC system_accountNextIndex (#1376) * stub AccountNextIndex * implement rpc system_accountNextIndex * lint * update testService_Methods * move parmeter check * add TransactionStateAPI to RPC systemModule * add check of pending transactions ot accountNextIndex * add test for pending tranactions * run lint * add tests
Changes
Tests
Checklist
Issues