Skip to content

Commit

Permalink
is valid test
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorvsadana committed Aug 26, 2024
1 parent 82604fd commit dcd0bf5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ AWS_DEFAULT_REGION="localhost"
MADARA_RPC_URL="http://localhost:3000"
ETHEREUM_RPC_URL="http://localhost:3001"
ETHEREUM_MAINNET_RPC_URL="https://mainnet.infura.io/v3/bf9e41563a6a45e28eb60382d85ef3c9" # for forking during tests
MEMORY_PAGES_CONTRACT_ADDRESS="0x000000000000000000000000000000000001dead"
MEMORY_PAGES_CONTRACT_ADDRESS="0x47312450B3Ac8b5b8e247a6bB6d523e7605bDb60"
PRIVATE_KEY="0xdead"
# Private key of Test wallet provided by Anvil
ETHEREUM_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
Expand Down
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions crates/prover-services/gps-fact-checker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ edition.workspace = true

[dependencies]
alloy = { workspace = true, features = [
"sol-types",
"json",
"contract",
"providers",
"rpc-client",
"transport-http",
"reqwest",
"sol-types",
"json",
"contract",
"providers",
"rpc-client",
"transport-http",
"reqwest",
] }
async-trait.workspace = true
cairo-vm.workspace = true
Expand All @@ -20,4 +20,6 @@ starknet.workspace = true
thiserror.workspace = true
url.workspace = true
utils.workspace = true
log = "0.4.21"
tokio.workspace = true
rstest.workspace = true
dotenvy.workspace = true
29 changes: 29 additions & 0 deletions crates/prover-services/gps-fact-checker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,32 @@ impl FactChecker {
Ok(_0)
}
}

#[cfg(test)]
mod tests {
use crate::FactChecker;
use alloy::primitives::{Address, B256};
use rstest::rstest;
use std::str::FromStr;
use url::Url;
use utils::env_utils::get_env_var_or_panic;

#[rstest]
// Picked a valid fact registered on Eth.
// You can check on etherscan by calling `isValid` function on GpsStatementVerifier.sol
// Contract Link : https://etherscan.io/address/0x9fb7F48dCB26b7bFA4e580b2dEFf637B13751942#readContract#F9
#[case::valid_fact("0xec8fa9cdfe069ed59b8f17aeecfd95c6abd616379269d2fa16a80955b6e0f068", true)]
// same fact with last letter changed
#[case::invalid_fact("0xec8fa9cdfe069ed59b8f17aeecfd95c6abd616379269d2fa16a80955b6e0f067", false)]
#[tokio::test]
pub async fn fact_registry_is_valid(#[case] fact: &str, #[case] is_valid: bool) {
dotenvy::from_filename("../.env.test").expect("Failed to load the .env file");

let fact_checker = FactChecker::new(
Url::from_str(get_env_var_or_panic("ETHEREUM_MAINNET_RPC_URL").as_str()).unwrap(),
Address::from_str(get_env_var_or_panic("MEMORY_PAGES_CONTRACT_ADDRESS").as_str()).unwrap(),
);
let fact = B256::from_str(fact).unwrap();
assert_eq!(fact_checker.is_valid(&fact).await.unwrap(), is_valid);
}
}
1 change: 0 additions & 1 deletion crates/prover-services/sharp-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::str::FromStr;

use alloy::primitives::{B256, I256};
use async_trait::async_trait;
use gps_fact_checker::fact_info::get_fact_info;
use gps_fact_checker::FactChecker;
use prover_client_interface::{ProverClient, ProverClientError, Task, TaskId, TaskStatus};
use snos::sharp::CairoJobStatus;
Expand Down

0 comments on commit dcd0bf5

Please sign in to comment.