Skip to content

Commit

Permalink
improved crate structure
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas089 committed Oct 7, 2024
1 parent 1f89e37 commit 5bf07bb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 29 deletions.
38 changes: 19 additions & 19 deletions contract-tests/tests/spectre.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,30 @@
* These are the highest level integration tests for the Spectre protocol
* They treat the Spectre contract as an ethereum light-client and test against the spec
*/
use std::path::PathBuf;
use std::sync::Arc;

use contract_tests::make_client;
#[cfg(feature = "contracts")]
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
mod contract_integration {
use std::path::PathBuf;
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]
#[cfg(feature = "contracts")]

async fn test_deploy_spectre() -> anyhow::Result<()> {
let (_anvil_instance, ethclient) = make_client();
let _contract = deploy_spectre_mock_verifiers(ethclient, 0, U256::zero(), 0).await?;
Expand All @@ -37,7 +39,6 @@ async fn test_deploy_spectre() -> anyhow::Result<()> {
#[rstest]
#[tokio::test]
#[cfg(feature = "contracts")]

async fn test_contract_initialization_and_first_step(
#[files("../consensus-spec-tests/tests/minimal/capella/light_client/sync/pyspec_tests/**")]
#[exclude("deneb*")]
Expand Down Expand Up @@ -82,7 +83,6 @@ async fn test_contract_initialization_and_first_step(
contract.execution_payload_roots(head).call().await?,
step_input.execution_payload_root
);

Ok(())
}

Expand Down
23 changes: 13 additions & 10 deletions contract-tests/tests/step_input_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
// Code: https://github.com/ChainSafe/Spectre
// SPDX-License-Identifier: LGPL-3.0-only

use std::ops::Deref;
use std::path::PathBuf;
#[cfg(feature = "contracts")]
mod contract_integration {
use std::ops::Deref;
use std::path::PathBuf;

use contract_tests::make_client;
use eth_types::{Minimal, LIMB_BITS};
use ethers::contract::abigen;
use lightclient_circuits::halo2_proofs::halo2curves::bn256;
use lightclient_circuits::witness::SyncStepArgs;
use rstest::rstest;
use ssz_rs::Merkleized;
use test_utils::read_test_files_and_gen_witness;
use contract_tests::make_client;
use eth_types::{Minimal, LIMB_BITS};
use ethers::contract::abigen;
use lightclient_circuits::halo2_proofs::halo2curves::bn256;
use lightclient_circuits::witness::SyncStepArgs;
use rstest::rstest;
use ssz_rs::Merkleized;
use test_utils::read_test_files_and_gen_witness;
}

#[cfg(feature = "contracts")]
abigen!(
Expand Down
4 changes: 4 additions & 0 deletions contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Running smart contract integration tests
When running the Spectre smart contract integration tests, replace this crate with [this crate](https://github.com/ChainSafe/spectre-contracts/tree/a430caeb3678582b73e3ee73b6f001bd9d1e75ca)

Additionally make sure to enable the `contracts` feature when running tests against the real contracts crate.

0 comments on commit 5bf07bb

Please sign in to comment.