Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bc28c60
Add documentation to signed transactions and actually make them work.
tomusdrw Nov 25, 2019
a645b90
Fix naming and bounds.
tomusdrw Nov 25, 2019
f8c9540
Forgotten import.
tomusdrw Nov 25, 2019
f85b890
Merge branch 'master' into td-signed-transactions
tomusdrw Dec 2, 2019
3f38218
Merge branch 'master' into td-signed-transactions
tomusdrw Dec 3, 2019
d715f64
Remove warning.
tomusdrw Dec 3, 2019
0c4c037
Make accounts optional, fix logic.
tomusdrw Dec 3, 2019
dc8d71c
Split the method to avoid confusing type error message.
tomusdrw Dec 3, 2019
173cf6c
Move executor tests to integration.
tomusdrw Nov 28, 2019
90a00fd
Add submit transactions tests.
tomusdrw Dec 3, 2019
901dbdb
Merge branch 'master' into td-signed-transactions
tomusdrw Dec 10, 2019
d103fa1
Make `submit_transaction` tests compile
HCastano Dec 19, 2019
99c54b7
Remove a file that was accidently committed
HCastano Dec 19, 2019
dbc81dd
Merge branch 'master' into td-signed-transactions
tomusdrw Dec 20, 2019
9eb7a2e
Add can_sign helper function.
tomusdrw Dec 20, 2019
0ccb951
Fix compilation.
tomusdrw Dec 20, 2019
73a936c
Add a key to keystore.
tomusdrw Dec 20, 2019
d776d50
Fix the tests.
tomusdrw Dec 20, 2019
0ac61d7
Remove env_logger.
tomusdrw Dec 20, 2019
8755539
Fix sending multiple transactions.
tomusdrw Dec 20, 2019
fc6b5fe
Remove commented code.
tomusdrw Dec 20, 2019
af1782e
Bring back criterion.
tomusdrw Dec 20, 2019
58673bf
Merge branch 'master' into td-signed-transactions
tomusdrw Dec 23, 2019
bacf48c
Remove stray debug log.
tomusdrw Dec 23, 2019
b3c8726
Merge branch 'master' into td-signed-transactions
gavofyork Jan 3, 2020
da816e2
Apply suggestions from code review
tomusdrw Jan 6, 2020
a2c6d09
Make sure to initialize block correctly.
tomusdrw Jan 8, 2020
af5724c
Initialize block for offchain workers.
tomusdrw Jan 8, 2020
3eda535
Add test for transaction validity.
tomusdrw Jan 8, 2020
765f96f
Merge branch 'master' into td-signed-transactions
tomusdrw Jan 8, 2020
6bafaff
Fix tests.
tomusdrw Jan 8, 2020
021f586
Review suggestions.
tomusdrw Jan 8, 2020
3ac00ff
Remove redundant comment.
tomusdrw Jan 8, 2020
7f38d4c
Make sure to use correct block number of authoring.
tomusdrw Jan 8, 2020
afb99f9
Change the runtime API.
tomusdrw Jan 9, 2020
a945a8c
Support both versions.
tomusdrw Jan 9, 2020
4c66a45
Bump spec version, fix RPC test.
tomusdrw Jan 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make submit_transaction tests compile
  • Loading branch information
HCastano committed Dec 19, 2019
commit d103fa19f735db6c75407bea115279a6d74148d6
4 changes: 2 additions & 2 deletions bin/node/executor/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ fn full_native_block_import_works_with_changes_trie() {
None,
).0.unwrap();

assert!(t.ext().storage_changes_root(GENESIS_HASH.into()).unwrap().is_some());
assert!(t.ext().storage_changes_root(&GENESIS_HASH).unwrap().is_some());
}

#[test]
Expand All @@ -799,7 +799,7 @@ fn full_wasm_block_import_works_with_changes_trie() {
None,
).0.unwrap();

assert!(t.ext().storage_changes_root(GENESIS_HASH.into()).unwrap().is_some());
assert!(t.ext().storage_changes_root(&GENESIS_HASH).unwrap().is_some());
}

#[test]
Expand Down
11 changes: 8 additions & 3 deletions bin/node/executor/tests/submit_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
use node_runtime::{
Call, Runtime, SubmitTransaction,
};
use primitives::testing::{KeyStore, ED25519, SR25519};
use primitives::traits::{KeystoreExt, BareCryptoStorePtr};
use primitives::offchain::{
TransactionPoolExt,
testing::TestTransactionPoolExt,
Expand Down Expand Up @@ -56,10 +58,13 @@ fn should_submit_signed_transaction() {
let (pool, state) = TestTransactionPoolExt::new();
t.register_extension(TransactionPoolExt::new(pool));

let mut keystore = KeyStore::new();
t.register_extension(KeystoreExt(keystore));

t.execute_with(|| {
let call = balances::Call::transfer(Default::default());
let results = SubmitSignedTransaction<Runtime, Call>
::submit_signed(call, vec![]);
let call = balances::Call::transfer(Default::default(), Default::default());
let results =
<SubmitTransaction as SubmitSignedTransaction<Runtime, Call>>::submit_signed(call);

let len = results.len();
assert_eq!(len, 3);
Expand Down
4 changes: 3 additions & 1 deletion bin/node/testing/src/keyring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ use sp_runtime::generic::Era;
use codec::Encode;

/// Alice's account id.
pub fn alice() -> AccountId { AccountKeyring::Alice.into() }
pub fn alice() -> AccountId {
AccountKeyring::Alice.into()
}

/// Bob's account id.
pub fn bob() -> AccountId {
Expand Down
138 changes: 138 additions & 0 deletions diff.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
diff --git a/bin/node/executor/Cargo.toml b/bin/node/executor/Cargo.toml
index f5e04960b..7302cda4d 100644
--- a/bin/node/executor/Cargo.toml
+++ b/bin/node/executor/Cargo.toml
@@ -23,6 +23,7 @@ criterion = "0.3.0"
grandpa = { package = "pallet-grandpa", path = "../../../frame/grandpa" }
imonline = { package = "pallet-im-online", path = "../../../frame/im-online" }
indices = { package = "pallet-indices", path = "../../../frame/indices" }
+# keyring = { package = "sp-keyring", path = "../../../primitives/keyring" }
node-testing = { path = "../testing" }
runtime_support = { package = "frame-support", path = "../../../frame/support" }
session = { package = "pallet-session", path = "../../../frame/session" }
diff --git a/bin/node/executor/tests/basic.rs b/bin/node/executor/tests/basic.rs
index 4be7edb1c..0391cf80c 100644
--- a/bin/node/executor/tests/basic.rs
+++ b/bin/node/executor/tests/basic.rs
@@ -783,7 +783,7 @@ fn full_native_block_import_works_with_changes_trie() {
None,
).0.unwrap();

- assert!(t.ext().storage_changes_root(GENESIS_HASH.into()).unwrap().is_some());
+ assert!(t.ext().storage_changes_root(&GENESIS_HASH).unwrap().is_some());
}

#[test]
@@ -799,7 +799,7 @@ fn full_wasm_block_import_works_with_changes_trie() {
None,
).0.unwrap();

- assert!(t.ext().storage_changes_root(GENESIS_HASH.into()).unwrap().is_some());
+ assert!(t.ext().storage_changes_root(&GENESIS_HASH).unwrap().is_some());
}

#[test]
diff --git a/bin/node/executor/tests/submit_transaction.rs b/bin/node/executor/tests/submit_transaction.rs
index d9816e204..065870e6e 100644
--- a/bin/node/executor/tests/submit_transaction.rs
+++ b/bin/node/executor/tests/submit_transaction.rs
@@ -17,11 +17,15 @@
use node_runtime::{
Call, Runtime, SubmitTransaction,
};
+use primitives::traits::{KeystoreExt, BareCryptoStorePtr};
use primitives::offchain::{
TransactionPoolExt,
testing::TestTransactionPoolExt,
};
+use primitives::testing::KeyStore;
use system::offchain::{SubmitSignedTransaction, SubmitUnsignedTransaction};
+use node_testing::keyring;
+

mod common;
use self::common::*;
@@ -50,16 +54,34 @@ fn should_submit_unsigned_transaction() {
});
}

+use primitives::testing::{ED25519, SR25519};
#[test]
fn should_submit_signed_transaction() {
let mut t = new_test_ext(COMPACT_CODE, false);
let (pool, state) = TestTransactionPoolExt::new();
t.register_extension(TransactionPoolExt::new(pool));

+ let alice = keyring::alice();
+ let bob = keyring::bob();
+
+ let mut keystore = KeyStore::new();
+
+ let charlie = keystore.write().sr25519_generate_new(SR25519, Some("//beep")).unwrap();
+ dbg!(&charlie);
+ // let _ = keystore.write().sr25519_key_pair(SR25519, alice).unwrap();
+ dbg!(keystore.read().sr25519_public_keys(SR25519));
+
+ t.register_extension(KeystoreExt(keystore));
+
t.execute_with(|| {
- let call = balances::Call::transfer(Default::default());
- let results = SubmitSignedTransaction<Runtime, Call>
- ::submit_signed(call, vec![]);
+ let call = balances::Call::transfer(Default::default(), Default::default());
+ dbg!(&call);
+
+ // This should submit Txs from all local accounts (which should be in the keystore)
+ // This mean we should have three local accounts right now (but we have 0)
+ let results =
+ <SubmitTransaction as SubmitSignedTransaction<Runtime, Call>>::submit_signed(call);
+ dbg!(&results);

let len = results.len();
assert_eq!(len, 3);
@@ -67,3 +89,18 @@ fn should_submit_signed_transaction() {
assert_eq!(state.read().transactions.len(), len);
});
}
+
+#[test]
+#[ignore]
+fn should_check_bug_that_tomek_described() {
+ let mut t = new_test_ext(COMPACT_CODE, false);
+ let (pool, state) = TestTransactionPoolExt::new();
+ t.register_extension(TransactionPoolExt::new(pool));
+
+ let mut keystore = KeyStore::new();
+ t.register_extension(KeystoreExt(keystore));
+
+ t.execute_with(|| {
+ // -- call submit_sign twice --
+ });
+}
diff --git a/bin/node/testing/src/keyring.rs b/bin/node/testing/src/keyring.rs
index 53dac6809..55b21cb34 100644
--- a/bin/node/testing/src/keyring.rs
+++ b/bin/node/testing/src/keyring.rs
@@ -23,7 +23,9 @@ use sp_runtime::generic::Era;
use codec::Encode;

/// Alice's account id.
-pub fn alice() -> AccountId { AccountKeyring::Alice.into() }
+pub fn alice() -> AccountId {
+ AccountKeyring::Alice.into()
+}

/// Bob's account id.
pub fn bob() -> AccountId {
diff --git a/frame/system/src/offchain.rs b/frame/system/src/offchain.rs
index 8c8e15021..b0a0b210d 100644
--- a/frame/system/src/offchain.rs
+++ b/frame/system/src/offchain.rs
@@ -228,7 +228,6 @@ pub trait SubmitSignedTransaction<T: crate::Trait, Call> {
}
}

-
/// A default type used to submit transactions to the pool.
///
/// This is passed into each runtime as an opaque associated type that can have either of:
1 change: 0 additions & 1 deletion frame/system/src/offchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ pub trait SubmitSignedTransaction<T: crate::Trait, Call> {
}
}


/// A default type used to submit transactions to the pool.
///
/// This is passed into each runtime as an opaque associated type that can have either of:
Expand Down