Skip to content

[dot/rpc] implement RPC system_accountNextIndex#1376

Merged
edwardmack merged 16 commits intodevelopmentfrom
ed/rpc_accountNextIndex
Feb 17, 2021
Merged

[dot/rpc] implement RPC system_accountNextIndex#1376
edwardmack merged 16 commits intodevelopmentfrom
ed/rpc_accountNextIndex

Conversation

@edwardmack
Copy link
Copy Markdown
Contributor

@edwardmack edwardmack commented Feb 9, 2021

Changes

  • Implement system_accountNextIndex to lookup account nonce from state storage.

Tests

go test ./dot/rpc/... -run TestSystemModule_AccountNextIndex

Checklist

  • I have read CODE_OF_CONDUCT and CONTRIBUTING
  • I have provided as much information as possible and necessary
  • I have reviewed my own pull request before requesting a review
  • All integration tests and required coverage checks are passing

Issues

Comment on lines +174 to +175
if req == nil || len(req.String) == 0 {
return errors.New("Account address must be valid")
Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea.

Copy link
Copy Markdown
Contributor

@noot noot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

@edwardmack
Copy link
Copy Markdown
Contributor Author

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.

@edwardmack edwardmack requested review from RyRy79261, arijitAD and noot and removed request for anthdm February 16, 2021 16:40
Comment on lines +185 to +186
if sigNonce.Uint64() > nonce {
nonce = sigNonce.Uint64()
Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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.

require.Equal(t, expected, *res)
}

func TestSystemModule_AccountNextIndex(t *testing.T) {
Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

@noot noot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work!

@edwardmack edwardmack merged commit 409b3aa into development Feb 17, 2021
@edwardmack edwardmack deleted the ed/rpc_accountNextIndex branch February 17, 2021 22:04
github-actions bot pushed a commit that referenced this pull request Feb 17, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants