add test
This commit is contained in:
parent
5faa4a85cb
commit
727ace0561
@ -391,9 +391,7 @@ mod tests {
|
|||||||
fn generates_seal_and_does_not_double_propose() {
|
fn generates_seal_and_does_not_double_propose() {
|
||||||
let tap = AccountProvider::transient_provider();
|
let tap = AccountProvider::transient_provider();
|
||||||
let addr1 = tap.insert_account("1".sha3(), "1").unwrap();
|
let addr1 = tap.insert_account("1".sha3(), "1").unwrap();
|
||||||
tap.unlock_account_permanently(addr1, "1".into()).unwrap();
|
|
||||||
let addr2 = tap.insert_account("2".sha3(), "2").unwrap();
|
let addr2 = tap.insert_account("2".sha3(), "2").unwrap();
|
||||||
tap.unlock_account_permanently(addr2, "2".into()).unwrap();
|
|
||||||
|
|
||||||
let spec = Spec::new_test_round();
|
let spec = Spec::new_test_round();
|
||||||
let engine = &*spec.engine;
|
let engine = &*spec.engine;
|
||||||
@ -409,12 +407,14 @@ mod tests {
|
|||||||
let b2 = OpenBlock::new(engine, Default::default(), false, db2, &genesis_header, last_hashes, addr2, (3141562.into(), 31415620.into()), vec![]).unwrap();
|
let b2 = OpenBlock::new(engine, Default::default(), false, db2, &genesis_header, last_hashes, addr2, (3141562.into(), 31415620.into()), vec![]).unwrap();
|
||||||
let b2 = b2.close_and_lock();
|
let b2 = b2.close_and_lock();
|
||||||
|
|
||||||
|
engine.set_signer(addr1, "1".into());
|
||||||
if let Some(seal) = engine.generate_seal(b1.block()) {
|
if let Some(seal) = engine.generate_seal(b1.block()) {
|
||||||
assert!(b1.clone().try_seal(engine, seal).is_ok());
|
assert!(b1.clone().try_seal(engine, seal).is_ok());
|
||||||
// Second proposal is forbidden.
|
// Second proposal is forbidden.
|
||||||
assert!(engine.generate_seal(b1.block()).is_none());
|
assert!(engine.generate_seal(b1.block()).is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
engine.set_signer(addr2, "2".into());
|
||||||
if let Some(seal) = engine.generate_seal(b2.block()) {
|
if let Some(seal) = engine.generate_seal(b2.block()) {
|
||||||
assert!(b2.clone().try_seal(engine, seal).is_ok());
|
assert!(b2.clone().try_seal(engine, seal).is_ok());
|
||||||
// Second proposal is forbidden.
|
// Second proposal is forbidden.
|
||||||
|
@ -257,10 +257,10 @@ mod tests {
|
|||||||
fn can_generate_seal() {
|
fn can_generate_seal() {
|
||||||
let tap = AccountProvider::transient_provider();
|
let tap = AccountProvider::transient_provider();
|
||||||
let addr = tap.insert_account("".sha3(), "").unwrap();
|
let addr = tap.insert_account("".sha3(), "").unwrap();
|
||||||
tap.unlock_account_permanently(addr, "".into()).unwrap();
|
|
||||||
|
|
||||||
let spec = new_test_authority();
|
let spec = new_test_authority();
|
||||||
let engine = &*spec.engine;
|
let engine = &*spec.engine;
|
||||||
|
engine.set_signer(addr, "".into());
|
||||||
engine.register_account_provider(Arc::new(tap));
|
engine.register_account_provider(Arc::new(tap));
|
||||||
let genesis_header = spec.genesis_header();
|
let genesis_header = spec.genesis_header();
|
||||||
let mut db_result = get_temp_state_db();
|
let mut db_result = get_temp_state_db();
|
||||||
|
Loading…
Reference in New Issue
Block a user