Skip to content

Commit

Permalink
Convert participation_fn from lambda to def
Browse files Browse the repository at this point in the history
I felt that the the lambda was a little too complicated.
  • Loading branch information
jtraglia committed May 9, 2022
1 parent 9dcb2ee commit 90c1825
Showing 1 changed file with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,49 +200,63 @@ def participation_tracker(slot, comm_index, comm):
@spec_state_test
def test_almost_empty_attestations(spec, state):
rng = Random(1234)
yield from run_with_participation(spec, state, lambda slot, comm_index, comm: rng.sample(sorted(comm), 1))

def participation_fn(slot, comm_index, comm):
return rng.sample(sorted(comm), 1)
yield from run_with_participation(spec, state, participation_fn)


@with_all_phases
@spec_state_test
@leaking()
def test_almost_empty_attestations_with_leak(spec, state):
rng = Random(1234)
yield from run_with_participation(spec, state, lambda slot, comm_index, comm: rng.sample(sorted(comm), 1))

def participation_fn(slot, comm_index, comm):
return rng.sample(sorted(comm), 1)
yield from run_with_participation(spec, state, participation_fn)


@with_all_phases
@spec_state_test
def test_random_fill_attestations(spec, state):
rng = Random(4567)
yield from run_with_participation(spec, state,
lambda slot, comm_index, comm: rng.sample(sorted(comm), len(comm) // 3))

def participation_fn(slot, comm_index, comm):
return rng.sample(sorted(comm), len(comm) // 3)
yield from run_with_participation(spec, state, participation_fn)


@with_all_phases
@spec_state_test
@leaking()
def test_random_fill_attestations_with_leak(spec, state):
rng = Random(4567)
yield from run_with_participation(spec, state,
lambda slot, comm_index, comm: rng.sample(sorted(comm), len(comm) // 3))

def participation_fn(slot, comm_index, comm):
return rng.sample(sorted(comm), len(comm) // 3)
yield from run_with_participation(spec, state, participation_fn)


@with_all_phases
@spec_state_test
def test_almost_full_attestations(spec, state):
rng = Random(8901)
yield from run_with_participation(spec, state,
lambda slot, comm_index, comm: rng.sample(sorted(comm), len(comm) - 1))

def participation_fn(slot, comm_index, comm):
return rng.sample(sorted(comm), len(comm) - 1)
yield from run_with_participation(spec, state, participation_fn)


@with_all_phases
@spec_state_test
@leaking()
def test_almost_full_attestations_with_leak(spec, state):
rng = Random(8901)
yield from run_with_participation(spec, state,
lambda slot, comm_index, comm: rng.sample(sorted(comm), len(comm) - 1))

def participation_fn(slot, comm_index, comm):
return rng.sample(sorted(comm), len(comm) - 1)
yield from run_with_participation(spec, state, participation_fn)


@with_all_phases
Expand Down

0 comments on commit 90c1825

Please sign in to comment.