Handle signing batches in the processor

Duplicates the existing signer for one tailored to batch signing.
This commit is contained in:
Luke Parker
2023-04-10 11:11:46 -04:00
parent 82c34dcc76
commit d323fc8b7b
13 changed files with 576 additions and 69 deletions

View File

@@ -49,7 +49,7 @@ async fn spend<C: Coin, D: Db>(
coin.mine_block().await;
}
match timeout(Duration::from_secs(30), scanner.events.recv()).await.unwrap().unwrap() {
ScannerEvent::Outputs(this_key, _, outputs) => {
ScannerEvent::Block(this_key, _, _, outputs) => {
assert_eq!(this_key, key);
assert_eq!(outputs.len(), 1);
// Make sure this is actually a change output
@@ -82,7 +82,7 @@ pub async fn test_addresses<C: Coin>(coin: C) {
// Verify the Scanner picked them up
let outputs =
match timeout(Duration::from_secs(30), scanner.events.recv()).await.unwrap().unwrap() {
ScannerEvent::Outputs(this_key, block, outputs) => {
ScannerEvent::Block(this_key, block, _, outputs) => {
assert_eq!(this_key, key);
assert_eq!(block, block_id);
assert_eq!(outputs.len(), 1);

View File

@@ -40,15 +40,18 @@ pub async fn test_scanner<C: Coin>(coin: C) {
let scanner = new_scanner().await;
// Receive funds
let block_id = coin.test_send(C::address(keys.group_key())).await.id();
let block = coin.test_send(C::address(keys.group_key())).await;
let block_id = block.id();
let block_time = block.time();
// Verify the Scanner picked them up
let verify_event = |mut scanner: ScannerHandle<C, MemDb>| async {
let outputs =
match timeout(Duration::from_secs(30), scanner.events.recv()).await.unwrap().unwrap() {
ScannerEvent::Outputs(key, block, outputs) => {
ScannerEvent::Block(key, block, time, outputs) => {
assert_eq!(key, keys.group_key());
assert_eq!(block, block_id);
assert_eq!(time, block_time);
assert_eq!(outputs.len(), 1);
assert_eq!(outputs[0].kind(), OutputType::External);
outputs

View File

@@ -27,12 +27,15 @@ pub async fn test_wallet<C: Coin>(coin: C) {
let (block_id, outputs) = {
scanner.rotate_key(coin.get_latest_block_number().await.unwrap(), key).await;
let block_id = coin.test_send(C::address(key)).await.id();
let block = coin.test_send(C::address(key)).await;
let block_id = block.id();
let block_time = block.time();
match timeout(Duration::from_secs(30), scanner.events.recv()).await.unwrap().unwrap() {
ScannerEvent::Outputs(this_key, block, outputs) => {
ScannerEvent::Block(this_key, block, time, outputs) => {
assert_eq!(this_key, key);
assert_eq!(block, block_id);
assert_eq!(time, block_time);
assert_eq!(outputs.len(), 1);
(block_id, outputs)
}
@@ -96,9 +99,10 @@ pub async fn test_wallet<C: Coin>(coin: C) {
}
match timeout(Duration::from_secs(30), scanner.events.recv()).await.unwrap().unwrap() {
ScannerEvent::Outputs(this_key, block_id, these_outputs) => {
ScannerEvent::Block(this_key, block_id, time, these_outputs) => {
assert_eq!(this_key, key);
assert_eq!(block_id, block.id());
assert_eq!(time, block.time());
assert_eq!(these_outputs, outputs);
}
}