Skip to content
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 author_insertKey #765

Merged
merged 8 commits into from
Apr 10, 2020

Conversation

edwardmack
Copy link
Member

@edwardmack edwardmack commented Apr 9, 2020

This PR introduces implementation of RPC call author_insertKey, which inserts the given key into the core keystore. Defined in https://github.com/w3f/PSPs/blob/psp-rpc-api/psp-002.md#author_insertKey

Changes

  • Implement RPC method author_insertKey
  • Create tests for author_insertKey

Tests:

go test ./dot/rpc/...

AND

curl -H "Content-Type: application/json" -X POST http://127.0.0.1:8545 -d '{"id":1, "jsonrpc":"2.0", "method": "author_insertKey", "params":["babe", "0xb7e9185065667390d2ad952a5324e8c365c9bf503dcf97c67a5ce861afe97309", "0x6246ddf254e0b4b4e7dffefc8adf69d212b98ac2b579c362b473fec8c40b4c0a"]}'

Issues:

@noot
Copy link
Contributor

noot commented Apr 9, 2020

@edwardmack I think just putting them into the keystore as you're doing right now is okay, and yeah they should be sr25519 keys. in the future we should probably have separate keystores for babe, grandpa, etc. let's make an issue for that

@edwardmack edwardmack marked this pull request as ready for review April 10, 2020 16:23
}

// newTestService creates a new test core service
func newTestService(t *testing.T, cfg *core.Config) *core.Service {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we could move this to dot/core/test_helpers.go and export it? just so we don't need to duplicate code

Copy link
Member 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
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.

looking good!

Copy link
Contributor

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

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

This looks good to me. Nice work!

@edwardmack edwardmack merged commit 3f02bed into development Apr 10, 2020
@edwardmack edwardmack deleted the ed/312-rpc-author_insertKey branch April 10, 2020 17:40
ryanchristo pushed a commit that referenced this pull request Jun 24, 2020
* add InsertKey interface

* implement author_insertKey

* lint issues

* added tests for author_insertKey

* remove unnecessary logging

* fix imports merge conflict

* move newTestSerice to test_helper.go and make public
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.

3 participants