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
27 commits
Select commit Hold shift + click to select a range
e4364e3
First experiments with Sassafras equivocations report
davxy Sep 12, 2022
b267418
Preparation for sassafras client tests
davxy Sep 20, 2022
1292e86
Cleanup and first working client test with multiple peers
davxy Sep 23, 2022
d0c8bc2
Merge branch 'davxy-sassafras-protocol' into davxy/sassafras-protocol…
davxy Sep 24, 2022
0a20351
Dummy commit
davxy Sep 24, 2022
326ac44
Conflicts resolution
davxy Sep 24, 2022
5b43f28
Test code refactory
davxy Sep 27, 2022
2dd6086
Better submit-tickets extrinsic tag
davxy Sep 27, 2022
829b90b
Refactory of client tests
davxy Oct 6, 2022
a2d66b6
Aux data revert implementation
davxy Oct 6, 2022
ca4b563
Handle skipped epochs on block-import
davxy Oct 7, 2022
e7be289
Skipped epoch test and fix
davxy Oct 11, 2022
7690a5c
Fix to epoch start slot computation
davxy Oct 14, 2022
6c20538
Minor tweaks
davxy Oct 17, 2022
2361064
Trivial comments refactory
davxy Oct 24, 2022
a26a31e
Do not alter original epoch changes node on epoch skip
davxy Oct 24, 2022
f3ebc2b
Insert tickets aux data after block import
davxy Oct 24, 2022
84bfdff
Tests environment refactory
davxy Oct 24, 2022
cfe639e
Use in-memory keystore for tests
davxy Oct 24, 2022
51e81a2
Push lock file
davxy Oct 24, 2022
04e92f6
Use test accounts keyring
davxy Oct 24, 2022
193134a
Test for secondary slots claims
davxy Oct 24, 2022
8bd8aed
Improved tests after epoch changes tree fix
davxy Oct 25, 2022
76c24bd
Tests for blocks verification
davxy Oct 29, 2022
950020b
Next epoch tickets incremental sort
davxy Oct 29, 2022
94e9ee8
Incremental sortition test
davxy Oct 29, 2022
d1a7edd
Set proper tickets tx longevity
davxy Oct 29, 2022
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
Use in-memory keystore for tests
  • Loading branch information
davxy committed Oct 24, 2022
commit cfe639ea0dcbda16ac8c47fafdf632b76f93cb09
3 changes: 1 addition & 2 deletions client/consensus/sassafras/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ sc-block-builder = { version = "0.10.0-dev", path = "../../block-builder" }
sc-keystore = { version = "4.0.0-dev", path = "../../keystore" }
sc-network-test = { version = "0.8.0", path = "../../network/test" }
sp-timestamp = { version = "4.0.0-dev", path = "../../../primitives/timestamp" }
substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" }
tempfile = "3.1.0"
substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" }
31 changes: 14 additions & 17 deletions client/consensus/sassafras/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Sassafras testsuite
//! Sassafras client tests

#[allow(unused_imports)]
use super::*;
Expand All @@ -27,12 +27,12 @@ use std::sync::Arc;
use sc_block_builder::BlockBuilderProvider;
use sc_client_api::Finalizer;
use sc_consensus::{BlockImport, BoxJustificationImport};
use sc_keystore::LocalKeystore;
use sc_network_test::*;
use sp_application_crypto::key_types::SASSAFRAS;
use sp_blockchain::Error as TestError;
use sp_consensus::{DisableProofRecording, NoNetwork as DummyOracle, Proposal};
use sp_consensus_sassafras::inherents::InherentDataProvider;
use sp_keystore::testing::KeyStore as TestKeyStore;
use sp_runtime::{Digest, DigestItem};
use sp_timestamp::Timestamp;

Expand Down Expand Up @@ -345,17 +345,17 @@ fn importing_block_one_sets_genesis_epoch() {
// TODO-SASS-P2: test finalization prunes tree

#[test]
fn import_block_with_ticket_proof() {}
fn import_block_with_ticket_proof() {
let mut env = TestEnvironment::new(None);

let blocks = env.propose_and_import_blocks(BlockId::Number(0), 7);
}

#[test]
fn finalization_prunes_epoch_changes_tree() {}

#[test]
fn allows_to_skip_epochs() {
let mut env = TestEnvironment::new(None);

let epoch_changes = env.link.epoch_changes.clone();

// Test scenario.
// Epoch lenght: 6 slots
//
Expand All @@ -365,14 +365,15 @@ fn allows_to_skip_epochs() {
//
// As a recovery strategy, a fallback epoch 3 is created by reusing part of the
// configuration created for epoch 2.
let mut env = TestEnvironment::new(None);

let blocks = env.propose_and_import_blocks(BlockId::Number(0), 7);

// First block after the a skipped epoch (block #8 @ slot #19)
let block =
env.propose_and_import_block(BlockId::Hash(*blocks.last().unwrap()), Some(19.into()));

let epoch_changes = epoch_changes.shared_data();
let epoch_changes = env.link.epoch_changes.shared_data();
let epochs: Vec<_> = epoch_changes.tree().iter().collect();
assert_eq!(epochs.len(), 3);
assert_eq!(*epochs[0].0, blocks[0]);
Expand Down Expand Up @@ -603,13 +604,12 @@ impl TestNetFactory for SassafrasTestNet {
#[test]
fn sassafras_network_progress() {
let net = SassafrasTestNet::new(3);
let net = Arc::new(Mutex::new(net));

let peers = &[(0, "//Alice"), (1, "//Bob"), (2, "//Charlie")];

let net = Arc::new(Mutex::new(net));
let mut import_notifications = Vec::new();
let mut sassafras_futures = Vec::new();
let mut keystore_paths = Vec::new();
let mut sassafras_workers = Vec::new();

for (peer_id, seed) in peers {
let mut net = net.lock();
Expand All @@ -618,12 +618,9 @@ fn sassafras_network_progress() {
let backend = peer.client().as_backend();
let select_chain = peer.select_chain().expect("Full client has select_chain");

let keystore_path = tempfile::tempdir().expect("Creates keystore path");
let keystore: SyncCryptoStorePtr =
Arc::new(LocalKeystore::open(keystore_path.path(), None).expect("Creates keystore"));
let keystore = Arc::new(TestKeyStore::new());
SyncCryptoStore::sr25519_generate_new(&*keystore, SASSAFRAS, Some(seed))
.expect("Generates authority key");
keystore_paths.push(keystore_path);

let data = peer.data.as_ref().expect("sassafras link set up during initialization");

Expand Down Expand Up @@ -677,7 +674,7 @@ fn sassafras_network_progress() {
create_inherent_data_providers,
};
let sassafras_worker = start_sassafras(sassafras_params).unwrap();
sassafras_futures.push(sassafras_worker);
sassafras_workers.push(sassafras_worker);
}

block_on(future::select(
Expand All @@ -691,6 +688,6 @@ fn sassafras_network_progress() {
});
Poll::<()>::Pending
}),
future::select(future::join_all(import_notifications), future::join_all(sassafras_futures)),
future::select(future::join_all(import_notifications), future::join_all(sassafras_workers)),
));
}