Initial code to handle messages from processors

This commit is contained in:
Luke Parker
2023-04-25 03:14:42 -04:00
parent cc531d630e
commit 78d5372fb7
6 changed files with 137 additions and 35 deletions

View File

@@ -80,13 +80,13 @@ async fn dkg_test() {
tributary: &Tributary<MemDb, Transaction, LocalP2p>,
) -> (TributaryDb<MemDb>, MemProcessor) {
let mut scanner_db = TributaryDb(MemDb::new());
let mut processor = MemProcessor::new();
handle_new_blocks(&mut scanner_db, key, &mut processor, spec, &tributary.reader()).await;
let processor = MemProcessor::new();
handle_new_blocks(&mut scanner_db, key, &processor, spec, &tributary.reader()).await;
(scanner_db, processor)
}
// Instantiate a scanner and verify it has nothing to report
let (mut scanner_db, mut processor) = new_processor(&keys[0], &spec, &tributaries[0].1).await;
let (mut scanner_db, processor) = new_processor(&keys[0], &spec, &tributaries[0].1).await;
assert!(processor.0.read().await.is_empty());
// Publish the last commitment
@@ -96,8 +96,7 @@ async fn dkg_test() {
sleep(Duration::from_secs(Tributary::<MemDb, Transaction, LocalP2p>::block_time().into())).await;
// Verify the scanner emits a KeyGen::Commitments message
handle_new_blocks(&mut scanner_db, &keys[0], &mut processor, &spec, &tributaries[0].1.reader())
.await;
handle_new_blocks(&mut scanner_db, &keys[0], &processor, &spec, &tributaries[0].1.reader()).await;
{
let mut msgs = processor.0.write().await;
assert_eq!(msgs.pop_front().unwrap(), expected_commitments);
@@ -138,8 +137,7 @@ async fn dkg_test() {
}
// With just 4 sets of shares, nothing should happen yet
handle_new_blocks(&mut scanner_db, &keys[0], &mut processor, &spec, &tributaries[0].1.reader())
.await;
handle_new_blocks(&mut scanner_db, &keys[0], &processor, &spec, &tributaries[0].1.reader()).await;
assert!(processor.0.write().await.is_empty());
// Publish the final set of shares
@@ -170,8 +168,7 @@ async fn dkg_test() {
};
// Any scanner which has handled the prior blocks should only emit the new event
handle_new_blocks(&mut scanner_db, &keys[0], &mut processor, &spec, &tributaries[0].1.reader())
.await;
handle_new_blocks(&mut scanner_db, &keys[0], &processor, &spec, &tributaries[0].1.reader()).await;
{
let mut msgs = processor.0.write().await;
assert_eq!(msgs.pop_front().unwrap(), shares_for(0));