Skip to content

Commit

Permalink
test: signer client test should use a signer-sent message
Browse files Browse the repository at this point in the history
  • Loading branch information
kantai committed Jun 28, 2024
1 parent 3fa8b12 commit 4ad8e91
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions stacks-signer/src/client/stackerdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ mod tests {

use blockstack_lib::chainstate::nakamoto::{NakamotoBlock, NakamotoBlockHeader};
use clarity::util::hash::{MerkleTree, Sha512Trunc256Sum};
use libsigner::v0::messages::SignerMessage;
use libsigner::v0::messages::{BlockRejection, BlockResponse, RejectCode, SignerMessage};
use libsigner::BlockProposal;
use rand::{thread_rng, RngCore};

Expand Down Expand Up @@ -276,25 +276,26 @@ mod tests {
};
block.header.tx_merkle_root = tx_merkle_root;

let block_proposal = BlockProposal {
block,
burn_height: thread_rng().next_u64(),
reward_cycle: thread_rng().next_u64(),
let block_reject = BlockRejection {
reason: "Did not like it".into(),
reason_code: RejectCode::RejectedInPriorRound,
signer_signature_hash: block.header.signer_signature_hash(),
};
let signer_message = SignerMessage::BlockProposal(block_proposal);
let signer_message = SignerMessage::BlockResponse(BlockResponse::Rejected(block_reject));
let ack = StackerDBChunkAckData {
accepted: true,
reason: None,
metadata: None,
code: None,
};
let mock_server = mock_server_from_config(&config);
let h = spawn(move || stackerdb.send_message_with_retry(signer_message));
debug!("Spawning msg sender");
let h = spawn(move || stackerdb.send_message_with_retry(signer_message).unwrap());
let mut response_bytes = b"HTTP/1.1 200 OK\n\n".to_vec();
let payload = serde_json::to_string(&ack).expect("Failed to serialize ack");
response_bytes.extend(payload.as_bytes());
std::thread::sleep(Duration::from_millis(500));
write_response(mock_server, response_bytes.as_slice());
assert_eq!(ack, h.join().unwrap().unwrap());
assert_eq!(ack, h.join().unwrap());
}
}

0 comments on commit 4ad8e91

Please sign in to comment.