Block enactment with test.
This commit is contained in:
parent
abb4975400
commit
4512322d3e
22
src/block.rs
22
src/block.rs
@ -240,13 +240,16 @@ impl SealedBlock {
|
|||||||
block_rlp.append_raw(&self.uncle_bytes, 1);
|
block_rlp.append_raw(&self.uncle_bytes, 1);
|
||||||
block_rlp.out()
|
block_rlp.out()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Drop this object and return the underlieing database.
|
||||||
|
pub fn drain(self) -> OverlayDB { self.block.state.drop().1 }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IsBlock for SealedBlock {
|
impl IsBlock for SealedBlock {
|
||||||
fn block(&self) -> &Block { &self.block }
|
fn block(&self) -> &Block { &self.block }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn enacted(rlp_bytes: &[u8], db: OverlayDB, engine: &Engine, parent: &Header, last_hashes: &LastHashes) -> Result<SealedBlock, Error> {
|
pub fn enact(rlp_bytes: &[u8], engine: &Engine, db: OverlayDB, parent: &Header, last_hashes: &LastHashes) -> Result<SealedBlock, Error> {
|
||||||
let block = BlockView::new(rlp_bytes);
|
let block = BlockView::new(rlp_bytes);
|
||||||
let header = block.header_view();
|
let header = block.header_view();
|
||||||
let mut b = OpenBlock::new(engine, db, parent, last_hashes, header.author(), header.extra_data());
|
let mut b = OpenBlock::new(engine, db, parent, last_hashes, header.author(), header.extra_data());
|
||||||
@ -268,16 +271,25 @@ fn open_block() {
|
|||||||
let b = b.close();
|
let b = b.close();
|
||||||
let _ = b.seal(vec![]);
|
let _ = b.seal(vec![]);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
#[test]
|
#[test]
|
||||||
fn enact_block() {
|
fn enact_block() {
|
||||||
use spec::*;
|
use spec::*;
|
||||||
let engine = Spec::new_test().to_engine().unwrap();
|
let engine = Spec::new_test().to_engine().unwrap();
|
||||||
let genesis_header = engine.spec().genesis_header();
|
let genesis_header = engine.spec().genesis_header();
|
||||||
|
|
||||||
let mut db = OverlayDB::new_temp();
|
let mut db = OverlayDB::new_temp();
|
||||||
engine.spec().ensure_db_good(&mut db);
|
engine.spec().ensure_db_good(&mut db);
|
||||||
|
let b = OpenBlock::new(engine.deref(), db, &genesis_header, &vec![genesis_header.hash()], Address::zero(), vec![]).close().seal(vec![]).unwrap();
|
||||||
|
let orig_bytes = b.rlp_bytes();
|
||||||
|
let orig_db = b.drain();
|
||||||
|
|
||||||
let b = OpenBlock::new(engine.deref(), db, &genesis_header, &vec![genesis_header.hash()], Address::zero(), vec![]).close().seal(vec![]).rlp_bytes();
|
let mut db = OverlayDB::new_temp();
|
||||||
Block::
|
engine.spec().ensure_db_good(&mut db);
|
||||||
|
let e = enact(&orig_bytes, engine.deref(), db, &genesis_header, &vec![genesis_header.hash()]).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(e.rlp_bytes(), orig_bytes);
|
||||||
|
|
||||||
|
let db = e.drain();
|
||||||
|
assert_eq!(orig_db.keys(), db.keys());
|
||||||
}
|
}
|
||||||
*/
|
|
Loading…
Reference in New Issue
Block a user