-
Notifications
You must be signed in to change notification settings - Fork 258
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
Fix and test sr25519 signing in nostd #1872
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d2a11a8
Fix and test sr25519 signing in nostd
jsdw 511e222
Remove sr25519 signing test on nostd for thumbabi target
jsdw 77dd23e
Don't use sr25519 feature in nostd tests
jsdw c4c2ff3
Fix nits, remove WASM deps from nostd test, improve comments
jsdw 8dd4d1b
Change copypasted comment
jsdw 9f4ea8f
fmt
jsdw 013874f
Merge branch 'master' into jsdw-signer-nostd-fix
jsdw bbd4135
Update CI to account for signer tests
jsdw 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -291,6 +291,12 @@ jobs: | |
- name: Install cargo-nextest | ||
run: cargo install cargo-nextest | ||
|
||
- name: Run subxt-signer no-std tests | ||
uses: actions-rs/[email protected] | ||
with: | ||
command: test | ||
working-directory: signer/tests/no-std | ||
|
||
- name: Run tests | ||
uses: actions-rs/[email protected] | ||
with: | ||
|
@@ -416,7 +422,7 @@ jobs: | |
run: | | ||
wasm-pack test --headless --firefox | ||
wasm-pack test --headless --chrome | ||
working-directory: signer/wasm-tests | ||
working-directory: signer/tests/wasm | ||
|
||
- if: "failure()" | ||
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5 | ||
|
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
File renamed without changes.
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,19 @@ | ||
[package] | ||
name = "nostd-tests" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dev-dependencies] | ||
|
||
# This crate is not a part of the workspace, to ensure that no features | ||
# are enabled for it at the workspace level; which conflict with this test. | ||
subxt-signer = { path = "../../", default-features = false, features = [ | ||
"sr25519", | ||
"ecdsa", | ||
"unstable-eth", | ||
] } | ||
|
||
# this shouldn't be needed, it's in workspace.exclude, but still | ||
# I get the complaint unless I add it... | ||
[workspace] |
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,51 @@ | ||
#![no_std] | ||
|
||
use subxt_signer::{ecdsa, eth, sr25519}; | ||
|
||
// Run the tests by calling: | ||
// | ||
// ```text | ||
// cargo test | ||
// ``` | ||
// | ||
// These are independent of any other package to ensure that nothing | ||
// else enabled the same feature flag that subxt-signer needs to work ok | ||
// (subxt seems to, for instance). | ||
|
||
#[test] | ||
fn sr25519_signing_works() { | ||
let alice = sr25519::dev::alice(); | ||
|
||
// There's some non-determinism in the signing, so this ensures that | ||
// the rand stuff is configured properly to run ok in wasm. | ||
let signature = alice.sign(b"Hello there"); | ||
assert!(sr25519::verify( | ||
&signature, | ||
b"Hello there", | ||
&alice.public_key() | ||
)); | ||
} | ||
|
||
#[test] | ||
fn ecdsa_signing_works() { | ||
let alice = ecdsa::dev::alice(); | ||
|
||
// There's some non-determinism in the signing, so this ensures that | ||
// the rand stuff is configured properly to run ok in wasm. | ||
let signature = alice.sign(b"Hello there"); | ||
assert!(ecdsa::verify( | ||
&signature, | ||
b"Hello there", | ||
&alice.public_key() | ||
)); | ||
} | ||
|
||
#[test] | ||
fn eth_signing_works() { | ||
let alice = eth::dev::alith(); | ||
|
||
// There's some non-determinism in the signing, so this ensures that | ||
// the rand stuff is configured properly to run ok in wasm. | ||
let signature = alice.sign(b"Hello there"); | ||
assert!(eth::verify(&signature, b"Hello there", &alice.public_key())); | ||
} |
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,2 @@ | ||
/target | ||
Cargo.lock |
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
Oops, something went wrong.
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.
perhaps update the README in the signer crate that "sr25519 needs getrandom" which isn't supported on all platforms
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.
can we remove the getrandom feature flag now below?
https://github.com/paritytech/subxt/pull/1872/files#diff-8b295430b22e1459a5ea2f83b57cde4807b8380eac4528bfc639acb67733254cR84-R85
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 don't believe so because we have
web = ["getrandom/js"]
to enable the relevant getrandom feature if compiling for the web.(There's a separate conversation around whether this should be a thing of whether to make downstream consumers enable said feature flag instead, which is what getrandom suggests IIRC)