This commit is contained in:
Ajinkya Kulkarni 2024-12-05 15:28:01 +01:00
parent d78c2559aa
commit 95286858b0

View file

@ -50,6 +50,7 @@ async fn upsert_tcbinfo() -> Result<(), &'static str> {
for fmspc in fmspc_list {
let tcbinfo_from_api = get_tcbinfo(fmspc.clone(), "standard".to_string()).await;
// assert!(verify_signature(tcbinfo.clone(), key));
let contract_address =
"neutron1r4m59786vmxrx866585ze5ugjx9egcyja0nuxhn2y6d7ht6680sspa89zk"
@ -57,7 +58,7 @@ async fn upsert_tcbinfo() -> Result<(), &'static str> {
.expect("failed to parse contract address");
let query_msg = QueryMsg::GetTcbInfo { fmspc: fmspc.clone() };
let tcbinfo_on_chain_json: Value = client.query_smart(&contract_address, json!(query_msg)).await.expect("contract query failed");
let tcbinfo_on_chain = format_json_string(tcbinfo_on_chain_json);
let tcbinfo_on_chain = to_content::<TestSpec>(&tcbinfo_on_chain_json["data"]["tcb_info"].to_string()).unwrap().to_string();
println!("{tcbinfo_on_chain} \n {tcbinfo_from_api}");
if tcbinfo_on_chain != tcbinfo_from_api {
println!("updating on-chain TCBInfo for FMSPC: {fmspc}");
@ -88,11 +89,7 @@ async fn upsert_tcbinfo() -> Result<(), &'static str> {
Ok(())
}
fn format_json_string(input: Value) -> String {
let without_end_quotes = strip_dquotes(format!("{}", input["data"]["tcb_info"]).as_ref()).unwrap().to_string();
let content = to_content::<TestSpec>(&without_end_quotes).unwrap().to_string();
content
}
#[tokio::main]
pub async fn main() {