Skip to content

Commit 691e2c6

Browse files
committed
feat(testutil/validatormock): port attest.go (SlotAttester)
Ports `charon/testutil/validatormock/attest.go` to Rust. SlotAttester drives Prepare -> Attest -> Aggregate for a single slot, gated by Arc<CloseOnce> close-once flags (AtomicBool + Notify) that mirror Go's `chan struct{}` ready signals; mutable state lives behind Arc<Mutex<_>> so all entry points stay `&self`. Because the Rust eth2api client encodes attestations using the Electra SingleAttestation shape (incompatible with Go's VersionedAttestation JSON captured in the goldens), the two submit endpoints (`POST /eth/v2/beacon/pool/attestations` and `POST /eth/v2/validator/aggregate_and_proofs`) are POSTed as raw JSON whose structure matches `eth2spec.VersionedAttestation` / `*SubmitAggregateAttestationsOpts`. All other beacon-node interactions use the generated client. TestAttest matches Go's golden output for DutyFactor {0, 1} on validator set A via assert_json_eq, with submissions sorted by data.index to match the Go test's deterministic ordering. Also adds Eth2Exp and Submit variants to validatormock::Error, and a ValidatorSet-driven POST `/eth/v1/beacon/states/head/validators` plus a BeaconCommitteeSelections echo route in the tests because the beaconmock defaults don't cover those DV-only paths.
1 parent 03c48a9 commit 691e2c6

5 files changed

Lines changed: 1051 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/testutil/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ pluto-core.workspace = true
2222
pluto-crypto.workspace = true
2323
pluto-eth2api.workspace = true
2424
pluto-eth2util.workspace = true
25+
pluto-ssz.workspace = true
2526
rand.workspace = true
27+
reqwest.workspace = true
2628
serde.workspace = true
2729
serde_json.workspace = true
30+
serde_with.workspace = true
2831
thiserror.workspace = true
2932
tokio.workspace = true
3033
tokio-util.workspace = true
@@ -34,7 +37,6 @@ wiremock.workspace = true
3437

3538
[dev-dependencies]
3639
assert-json-diff.workspace = true
37-
reqwest.workspace = true
3840

3941
[lints]
4042
workspace = true

0 commit comments

Comments
 (0)