Newer
Older
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
session_index: 1,
validator_index: 1.into(),
});
assert_eq!(unsigned, Err(InvalidTransaction::Custom(INVALID_TX_DOUBLE_VOTE).into()));
assert_err!(dispatch, Error::<Test>::PvfCheckDoubleVote);
// Equivocation
let (unsigned, dispatch) = check(PvfCheckStatement {
accept: true,
subject: code_a.hash(),
session_index: 1,
validator_index: 1.into(),
});
assert_eq!(unsigned, Err(InvalidTransaction::Custom(INVALID_TX_DOUBLE_VOTE).into()));
assert_err!(dispatch, Error::<Test>::PvfCheckDoubleVote);
// Vote for an earlier session.
let (unsigned, dispatch) = check(PvfCheckStatement {
accept: false,
subject: code_a.hash(),
session_index: 0,
validator_index: 1.into(),
});
assert_eq!(unsigned, Err(InvalidTransaction::Stale.into()));
assert_err!(dispatch, Error::<Test>::PvfCheckStatementStale);
// Vote for an later session.
let (unsigned, dispatch) = check(PvfCheckStatement {
accept: false,
subject: code_a.hash(),
session_index: 2,
validator_index: 1.into(),
});
assert_eq!(unsigned, Err(InvalidTransaction::Future.into()));
assert_err!(dispatch, Error::<Test>::PvfCheckStatementFuture);
// Validator not in the set.
let (unsigned, dispatch) = check(PvfCheckStatement {
accept: false,
subject: code_a.hash(),
session_index: 1,
validator_index: 5.into(),
});
assert_eq!(
unsigned,
Err(InvalidTransaction::Custom(INVALID_TX_BAD_VALIDATOR_IDX).into())
);
assert_err!(dispatch, Error::<Test>::PvfCheckValidatorIndexOutOfBounds);
// Bad subject (code_b)
let (unsigned, dispatch) = check(PvfCheckStatement {
accept: false,
subject: code_b.hash(),
session_index: 1,
validator_index: 1.into(),
});
assert_eq!(unsigned, Err(InvalidTransaction::Custom(INVALID_TX_BAD_SUBJECT).into()));
assert_err!(dispatch, Error::<Test>::PvfCheckSubjectInvalid);
});
}
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
#[test]
fn verify_upgrade_go_ahead_signal_is_externally_accessible() {
use primitives::v1::well_known_keys;
let a = ParaId::from(2020);
new_test_ext(Default::default()).execute_with(|| {
assert!(sp_io::storage::get(&well_known_keys::upgrade_go_ahead_signal(a)).is_none());
<Paras as Store>::UpgradeGoAheadSignal::insert(&a, UpgradeGoAhead::GoAhead);
assert_eq!(
sp_io::storage::get(&well_known_keys::upgrade_go_ahead_signal(a)).unwrap(),
vec![1u8],
);
});
}
#[test]
fn verify_upgrade_restriction_signal_is_externally_accessible() {
use primitives::v1::well_known_keys;
let a = ParaId::from(2020);
new_test_ext(Default::default()).execute_with(|| {
assert!(sp_io::storage::get(&well_known_keys::upgrade_restriction_signal(a)).is_none());
<Paras as Store>::UpgradeRestrictionSignal::insert(&a, UpgradeRestriction::Present);
assert_eq!(
sp_io::storage::get(&well_known_keys::upgrade_restriction_signal(a)).unwrap(),
vec![0],
);
});
}