Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
ameba23 committed Aug 20, 2024
1 parent 3ef7fe8 commit fe93e35
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
7 changes: 4 additions & 3 deletions crates/threshold-signature-server/src/attestation/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ pub async fn attest(
let block_number =
rpc.chain_get_header(None).await?.ok_or_else(|| AttestationErr::BlockNumber)?.number;

let quote = create_quote(block_number, nonce, &signer, &x25519_secret).await?;
// We add 1 to the block number as this will be processed in the next block
let quote = create_quote(block_number + 1, nonce, &signer, &x25519_secret).await?;

// Submit the quote
let attest_tx = entropy::tx().attestation().attest(quote.clone());
let res = submit_transaction(&api, &rpc, &signer, &attest_tx, None).await;
println!("Succesfully submitted tx {:?}", res);
submit_transaction(&api, &rpc, &signer, &attest_tx, None).await?;

Ok(StatusCode::OK)
}
Expand Down
19 changes: 12 additions & 7 deletions crates/threshold-signature-server/src/attestation/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,17 @@ async fn test_attest() {
};
assert_eq!(nonce, [0; 32]);

// Wait a few blocks for hopefully something to happen
let block_number = rpc.chain_get_header(None).await.unwrap().unwrap().number;
run_to_block(&rpc, block_number + 10).await;
// Wait for the attestation to be handled
for _ in 0..10 {
let block_number = rpc.chain_get_header(None).await.unwrap().unwrap().number;
run_to_block(&rpc, block_number + 1).await;

// There should be no more pending attestation as the attestation has been handled
let pending_attestation_query =
entropy::storage().attestation().pending_attestations(&TSS_ACCOUNTS[0]);
assert!(query_chain(&api, &rpc, pending_attestation_query, None).await.unwrap().is_none());
// There should be no more pending attestation as the attestation has been handled
let pending_attestation_query =
entropy::storage().attestation().pending_attestations(&TSS_ACCOUNTS[0]);
if query_chain(&api, &rpc, pending_attestation_query, None).await.unwrap().is_none() {
return;
}
}
panic!("Waited 10 blocks and attestation is still pending");
}

0 comments on commit fe93e35

Please sign in to comment.