Process exits and slashings off the network (#1253)

* Process exits and slashings off the network

* Fix rest_api tests

* Add op verification tests

* Add tests for pruning of slashings in the op pool

* Address Paul's review comments
This commit is contained in:
Michael Sproul
2020-06-18 21:06:34 +10:00
committed by GitHub
parent 3199b1a6f2
commit bcb6afa0aa
27 changed files with 956 additions and 273 deletions

View File

@@ -1019,7 +1019,7 @@ fn proposer_slashing() {
let spec = &chain.spec;
// Check that there are no proposer slashings before insertion
let (proposer_slashings, _attester_slashings) = chain.op_pool.get_slashings(&state, spec);
let (proposer_slashings, _attester_slashings) = chain.op_pool.get_slashings(&state);
assert_eq!(proposer_slashings.len(), 0);
let slot = state.slot;
@@ -1050,7 +1050,7 @@ fn proposer_slashing() {
assert!(result, true);
// Length should be just one as we've inserted only one proposer slashing
let (proposer_slashings, _attester_slashings) = chain.op_pool.get_slashings(&state, spec);
let (proposer_slashings, _attester_slashings) = chain.op_pool.get_slashings(&state);
assert_eq!(proposer_slashings.len(), 1);
assert_eq!(proposer_slashing.clone(), proposer_slashings[0]);
@@ -1073,7 +1073,7 @@ fn proposer_slashing() {
assert!(result.is_err());
// Length should still be one as we've inserted nothing since last time.
let (proposer_slashings, _attester_slashings) = chain.op_pool.get_slashings(&state, spec);
let (proposer_slashings, _attester_slashings) = chain.op_pool.get_slashings(&state);
assert_eq!(proposer_slashings.len(), 1);
assert_eq!(proposer_slashing, proposer_slashings[0]);
}
@@ -1106,7 +1106,7 @@ fn attester_slashing() {
let fork = &state.fork;
// Checking there are no attester slashings before insertion
let (_proposer_slashings, attester_slashings) = chain.op_pool.get_slashings(&state, spec);
let (_proposer_slashings, attester_slashings) = chain.op_pool.get_slashings(&state);
assert_eq!(attester_slashings.len(), 0);
let attester_slashing = build_double_vote_attester_slashing(
@@ -1130,7 +1130,7 @@ fn attester_slashing() {
assert!(result, true);
// Length should be just one as we've inserted only one attester slashing
let (_proposer_slashings, attester_slashings) = chain.op_pool.get_slashings(&state, spec);
let (_proposer_slashings, attester_slashings) = chain.op_pool.get_slashings(&state);
assert_eq!(attester_slashings.len(), 1);
assert_eq!(attester_slashing, attester_slashings[0]);
@@ -1151,10 +1151,10 @@ fn attester_slashing() {
.beacon()
.attester_slashing(invalid_attester_slashing),
);
assert!(result.is_err());
result.unwrap_err();
// Length should still be one as we've failed to insert the attester slashing.
let (_proposer_slashings, attester_slashings) = chain.op_pool.get_slashings(&state, spec);
let (_proposer_slashings, attester_slashings) = chain.op_pool.get_slashings(&state);
assert_eq!(attester_slashings.len(), 1);
assert_eq!(attester_slashing, attester_slashings[0]);
}