Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nulltea committed Feb 21, 2024
1 parent 5e058f8 commit 81c92d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ snark-verifier-sdk = { git = "https://github.com/axiom-crypto/snark-verifier.git
] }

# ethereum types
ethereum-consensus-types = { git = "https://github.com/ChainSafe/ethereum-consensus-types", branch = "deneb" }
ethereum-consensus-types = { git = "https://github.com/ChainSafe/ethereum-consensus-types", branch = "capella" }
beacon-api-client = { git = "https://github.com/ralexstokes/ethereum-consensus.git", rev = "f3bff52e9c43866f231ec40c8ab0e34125a8957f" }
ssz_rs = "0.9"

Expand Down
12 changes: 11 additions & 1 deletion contract-tests/tests/spectre.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ use std::sync::Arc;

use contract_tests::make_client;
use contracts::{MockVerifier, Spectre};
use eth_types::{Minimal, LIMB_BITS};
use ethers::core::types::U256;
use ethers::providers::Middleware;
use halo2_base::halo2_proofs::halo2curves::bn256::Fr;
use lightclient_circuits::sync_step_circuit::StepCircuit;
use rstest::rstest;
use test_utils::{get_initial_sync_committee_poseidon, read_test_files_and_gen_witness};

const SLOTS_PER_EPOCH: usize = 8;
const EPOCHS_PER_SYNC_COMMITTEE_PERIOD: usize = 8;
const SLOTS_PER_SYNC_COMMITTEE_PERIOD: usize = EPOCHS_PER_SYNC_COMMITTEE_PERIOD * SLOTS_PER_EPOCH;
const FINALITY_THRESHOLD: usize = 20; // ~ 2/3 of 32

#[tokio::test]
async fn test_deploy_spectre() -> anyhow::Result<()> {
Expand Down Expand Up @@ -52,9 +56,14 @@ async fn test_contract_initialization_and_first_step(
// pre conditions
assert_eq!(contract.head().call().await?, U256::from(0));

let instances = StepCircuit::<Minimal, Fr>::get_instances(&witness, LIMB_BITS);

// call step with the input and proof
let step_input: contracts::StepInput = witness.into();
let step_call = contract.step(step_input.clone(), Vec::new().into());
let mut proof = vec![0; 384];
proof.extend(instances[0][0].to_bytes().into_iter().rev());
proof.extend(instances[0][1].to_bytes().into_iter().rev());
let step_call = contract.step(step_input.clone(), proof.into());
let _receipt = step_call.send().await?.confirmations(1).await?;

// post conditions
Expand Down Expand Up @@ -93,6 +102,7 @@ async fn deploy_spectre_mock_verifiers<M: Middleware + 'static>(
U256::from(initial_sync_period),
initial_sync_committee_poseidon,
U256::from(slots_per_period),
U256::from(FINALITY_THRESHOLD)
),
)?
.send()
Expand Down

0 comments on commit 81c92d2

Please sign in to comment.