Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseAbram committed Oct 7, 2024
1 parent 7ae965e commit cfdd990
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
Binary file modified crates/client/entropy_metadata.scale
Binary file not shown.
4 changes: 2 additions & 2 deletions crates/threshold-signature-server/src/attestation/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ use crate::{
AppState,
};
use axum::{body::Bytes, extract::State, http::StatusCode};
use entropy_kvdb::kv_manager::{KvManager};
use entropy_kvdb::kv_manager::KvManager;
use entropy_shared::OcwMessageAttestationRequest;
use parity_scale_codec::Decode;
use sp_core::Pair;
use subxt::{tx::PairSigner};
use subxt::tx::PairSigner;
use x25519_dalek::StaticSecret;

/// HTTP POST endpoint to initiate a TDX attestation.
Expand Down
39 changes: 37 additions & 2 deletions crates/threshold-signature-server/src/attestation/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,22 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::{
attestation::api::validate_new_attest,
chain_api::{entropy, get_api, get_rpc},
helpers::{
substrate::query_chain,
tests::{initialize_test_logger, run_to_block, spawn_testing_validators, ChainSpecType},
tests::{
initialize_test_logger, run_to_block, setup_client, spawn_testing_validators,
ChainSpecType,
},
},
launch::LATEST_BLOCK_NUMBER_ATTEST,
};
use entropy_kvdb::clean_tests;
use entropy_shared::OcwMessageAttestationRequest;
use entropy_testing_utils::{
constants::TSS_ACCOUNTS, substrate_context::test_node_process_stationary,
constants::TSS_ACCOUNTS,
substrate_context::{test_context_stationary, test_node_process_stationary},
};
use serial_test::serial;

Expand Down Expand Up @@ -64,3 +71,31 @@ async fn test_attest() {
}
panic!("Waited 10 blocks and attestation is still pending");
}

#[tokio::test]
#[serial]
async fn test_attest_validation_fail() {
initialize_test_logger().await;
clean_tests();

let cxt = test_context_stationary().await;
let rpc = get_rpc(&cxt.node_proc.ws_url).await.unwrap();
let kv = setup_client().await;

let block_number = rpc.chain_get_header(None).await.unwrap().unwrap().number + 1;
let ocw_message = OcwMessageAttestationRequest { tss_account_ids: vec![], block_number };
let err_stale_data =
validate_new_attest(block_number, &ocw_message, &kv).await.map_err(|e| e.to_string());
assert_eq!(err_stale_data, Err("Data is stale".to_string()));
run_to_block(&rpc, block_number).await;

// manipulates kvdb to get to repeated data error
kv.kv().delete(LATEST_BLOCK_NUMBER_ATTEST).await.unwrap();
let reservation = kv.kv().reserve_key(LATEST_BLOCK_NUMBER_ATTEST.to_string()).await.unwrap();
kv.kv().put(reservation, (block_number + 5).to_be_bytes().to_vec()).await.unwrap();

let err_repeated_data =
validate_new_attest(block_number, &ocw_message, &kv).await.map_err(|e| e.to_string());
assert_eq!(err_repeated_data, Err("Data is repeated".to_string()));
clean_tests();
}
2 changes: 1 addition & 1 deletion crates/threshold-signature-server/src/user/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use entropy_protocol::{
};
use entropy_shared::{
HashingAlgorithm, DAVE_VERIFYING_KEY, DEFAULT_VERIFYING_KEY_NOT_REGISTERED, DEVICE_KEY_HASH,
EVE_VERIFYING_KEY, NETWORK_PARENT_KEY,
NETWORK_PARENT_KEY,
};
use entropy_testing_utils::{
chain_api::{
Expand Down

0 comments on commit cfdd990

Please sign in to comment.