Skip to content

Commit 5bf07bb

Browse files
committed
improved crate structure
1 parent 1f89e37 commit 5bf07bb

File tree

3 files changed

+36
-29
lines changed

3 files changed

+36
-29
lines changed

contract-tests/tests/spectre.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,30 @@
66
* These are the highest level integration tests for the Spectre protocol
77
* They treat the Spectre contract as an ethereum light-client and test against the spec
88
*/
9-
use std::path::PathBuf;
10-
use std::sync::Arc;
119

12-
use contract_tests::make_client;
1310
#[cfg(feature = "contracts")]
14-
use contracts::{MockVerifier, Spectre};
15-
use eth_types::{Minimal, LIMB_BITS};
16-
use ethers::core::types::U256;
17-
use ethers::providers::Middleware;
18-
use halo2_base::halo2_proofs::halo2curves::bn256::Fr;
19-
use lightclient_circuits::sync_step_circuit::StepCircuit;
20-
use rstest::rstest;
21-
use test_utils::{get_initial_sync_committee_poseidon, read_test_files_and_gen_witness};
22-
23-
const SLOTS_PER_EPOCH: usize = 8;
24-
const EPOCHS_PER_SYNC_COMMITTEE_PERIOD: usize = 8;
25-
const SLOTS_PER_SYNC_COMMITTEE_PERIOD: usize = EPOCHS_PER_SYNC_COMMITTEE_PERIOD * SLOTS_PER_EPOCH;
26-
const FINALITY_THRESHOLD: usize = 20; // ~ 2/3 of 32
11+
mod contract_integration {
12+
use std::path::PathBuf;
13+
use std::sync::Arc;
14+
15+
use contract_tests::make_client;
16+
use contracts::{MockVerifier, Spectre};
17+
use eth_types::{Minimal, LIMB_BITS};
18+
use ethers::core::types::U256;
19+
use ethers::providers::Middleware;
20+
use halo2_base::halo2_proofs::halo2curves::bn256::Fr;
21+
use lightclient_circuits::sync_step_circuit::StepCircuit;
22+
use rstest::rstest;
23+
use test_utils::{get_initial_sync_committee_poseidon, read_test_files_and_gen_witness};
24+
const SLOTS_PER_EPOCH: usize = 8;
25+
const EPOCHS_PER_SYNC_COMMITTEE_PERIOD: usize = 8;
26+
const SLOTS_PER_SYNC_COMMITTEE_PERIOD: usize =
27+
EPOCHS_PER_SYNC_COMMITTEE_PERIOD * SLOTS_PER_EPOCH;
28+
const FINALITY_THRESHOLD: usize = 20; // ~ 2/3 of 32
29+
}
2730

2831
#[tokio::test]
2932
#[cfg(feature = "contracts")]
30-
3133
async fn test_deploy_spectre() -> anyhow::Result<()> {
3234
let (_anvil_instance, ethclient) = make_client();
3335
let _contract = deploy_spectre_mock_verifiers(ethclient, 0, U256::zero(), 0).await?;
@@ -37,7 +39,6 @@ async fn test_deploy_spectre() -> anyhow::Result<()> {
3739
#[rstest]
3840
#[tokio::test]
3941
#[cfg(feature = "contracts")]
40-
4142
async fn test_contract_initialization_and_first_step(
4243
#[files("../consensus-spec-tests/tests/minimal/capella/light_client/sync/pyspec_tests/**")]
4344
#[exclude("deneb*")]
@@ -82,7 +83,6 @@ async fn test_contract_initialization_and_first_step(
8283
contract.execution_payload_roots(head).call().await?,
8384
step_input.execution_payload_root
8485
);
85-
8686
Ok(())
8787
}
8888

contract-tests/tests/step_input_encoding.rs

+13-10
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
// Code: https://github.com/ChainSafe/Spectre
33
// SPDX-License-Identifier: LGPL-3.0-only
44

5-
use std::ops::Deref;
6-
use std::path::PathBuf;
5+
#[cfg(feature = "contracts")]
6+
mod contract_integration {
7+
use std::ops::Deref;
8+
use std::path::PathBuf;
79

8-
use contract_tests::make_client;
9-
use eth_types::{Minimal, LIMB_BITS};
10-
use ethers::contract::abigen;
11-
use lightclient_circuits::halo2_proofs::halo2curves::bn256;
12-
use lightclient_circuits::witness::SyncStepArgs;
13-
use rstest::rstest;
14-
use ssz_rs::Merkleized;
15-
use test_utils::read_test_files_and_gen_witness;
10+
use contract_tests::make_client;
11+
use eth_types::{Minimal, LIMB_BITS};
12+
use ethers::contract::abigen;
13+
use lightclient_circuits::halo2_proofs::halo2curves::bn256;
14+
use lightclient_circuits::witness::SyncStepArgs;
15+
use rstest::rstest;
16+
use ssz_rs::Merkleized;
17+
use test_utils::read_test_files_and_gen_witness;
18+
}
1619

1720
#[cfg(feature = "contracts")]
1821
abigen!(

contracts/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Running smart contract integration tests
2+
When running the Spectre smart contract integration tests, replace this crate with [this crate](https://github.com/ChainSafe/spectre-contracts/tree/a430caeb3678582b73e3ee73b6f001bd9d1e75ca)
3+
4+
Additionally make sure to enable the `contracts` feature when running tests against the real contracts crate.

0 commit comments

Comments
 (0)