Merge pull request #242 from ethcore/blockchaintests
Note additional tests are fixed, fix doc test.
This commit is contained in:
		
						commit
						6c6708e2f2
					
				@ -158,7 +158,6 @@ impl BlockQueue {
 | 
			
		||||
				},
 | 
			
		||||
				Err(err) => {
 | 
			
		||||
					let mut v = verification.lock().unwrap();
 | 
			
		||||
					flushln!("Stage 2 block verification failed for {}\nError: {:?}", block_hash, err);
 | 
			
		||||
					warn!(target: "client", "Stage 2 block verification failed for {}\nError: {:?}", block_hash, err);
 | 
			
		||||
					v.bad.insert(block_hash.clone());
 | 
			
		||||
					v.verifying.retain(|e| e.hash != block_hash);
 | 
			
		||||
@ -224,7 +223,6 @@ impl BlockQueue {
 | 
			
		||||
				Ok(h)
 | 
			
		||||
			},
 | 
			
		||||
			Err(err) => {
 | 
			
		||||
				flushln!("Stage 1 block verification failed for {}\nError: {:?}", BlockView::new(&bytes).header_view().sha3(), err);
 | 
			
		||||
				warn!(target: "client", "Stage 1 block verification failed for {}\nError: {:?}", BlockView::new(&bytes).header_view().sha3(), err);
 | 
			
		||||
				self.verification.lock().unwrap().bad.insert(h.clone());
 | 
			
		||||
				Err(From::from(err))
 | 
			
		||||
 | 
			
		||||
@ -565,15 +565,6 @@ impl BlockChain {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/// Tries to squeeze the cache if its too big.
 | 
			
		||||
	pub fn squeeze_to_fit(&self, size: CacheSize) {
 | 
			
		||||
		self.blocks.write().unwrap().squeeze(size.blocks);
 | 
			
		||||
		self.block_details.write().unwrap().squeeze(size.block_details);
 | 
			
		||||
		self.transaction_addresses.write().unwrap().squeeze(size.transaction_addresses);
 | 
			
		||||
		self.block_logs.write().unwrap().squeeze(size.block_logs);
 | 
			
		||||
		self.blocks_blooms.write().unwrap().squeeze(size.blocks_blooms);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/// Let the cache system know that a cacheable item has been used.
 | 
			
		||||
	fn note_used(&self, id: CacheID) {
 | 
			
		||||
		let mut cache_man = self.cache_man.write().unwrap();
 | 
			
		||||
 | 
			
		||||
@ -205,7 +205,6 @@ impl Client {
 | 
			
		||||
		let _import_lock = self.import_lock.lock();
 | 
			
		||||
		let blocks = self.block_queue.write().unwrap().drain(128);
 | 
			
		||||
		for block in blocks {
 | 
			
		||||
//			flushln!("Importing {}...", block.header.hash());
 | 
			
		||||
			if bad.contains(&block.header.parent_hash) {
 | 
			
		||||
				self.block_queue.write().unwrap().mark_as_bad(&block.header.hash());
 | 
			
		||||
				bad.insert(block.header.hash());
 | 
			
		||||
@ -214,7 +213,6 @@ impl Client {
 | 
			
		||||
 | 
			
		||||
			let header = &block.header;
 | 
			
		||||
			if let Err(e) = verify_block_family(&header, &block.bytes, self.engine.deref().deref(), self.chain.read().unwrap().deref()) {
 | 
			
		||||
				flushln!("Stage 3 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e);
 | 
			
		||||
				warn!(target: "client", "Stage 3 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e);
 | 
			
		||||
				self.block_queue.write().unwrap().mark_as_bad(&header.hash());
 | 
			
		||||
				bad.insert(block.header.hash());
 | 
			
		||||
@ -223,7 +221,6 @@ impl Client {
 | 
			
		||||
			let parent = match self.chain.read().unwrap().block_header(&header.parent_hash) {
 | 
			
		||||
				Some(p) => p,
 | 
			
		||||
				None => {
 | 
			
		||||
					flushln!("Block import failed for #{} ({}): Parent not found ({}) ", header.number(), header.hash(), header.parent_hash);
 | 
			
		||||
					warn!(target: "client", "Block import failed for #{} ({}): Parent not found ({}) ", header.number(), header.hash(), header.parent_hash);
 | 
			
		||||
					self.block_queue.write().unwrap().mark_as_bad(&header.hash());
 | 
			
		||||
					bad.insert(block.header.hash());
 | 
			
		||||
@ -247,7 +244,6 @@ impl Client {
 | 
			
		||||
			let result = match enact_verified(&block, self.engine.deref().deref(), db, &parent, &last_hashes) {
 | 
			
		||||
				Ok(b) => b,
 | 
			
		||||
				Err(e) => {
 | 
			
		||||
					flushln!("Block import failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e);
 | 
			
		||||
					warn!(target: "client", "Block import failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e);
 | 
			
		||||
					bad.insert(block.header.hash());
 | 
			
		||||
					self.block_queue.write().unwrap().mark_as_bad(&header.hash());
 | 
			
		||||
@ -255,7 +251,6 @@ impl Client {
 | 
			
		||||
				}
 | 
			
		||||
			};
 | 
			
		||||
			if let Err(e) = verify_block_final(&header, result.block().header()) {
 | 
			
		||||
				flushln!("Stage 4 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e);
 | 
			
		||||
				warn!(target: "client", "Stage 4 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e);
 | 
			
		||||
				self.block_queue.write().unwrap().mark_as_bad(&header.hash());
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
@ -33,18 +33,12 @@ fn do_json_test(json_data: &[u8]) -> Vec<String> {
 | 
			
		||||
			{
 | 
			
		||||
				let client = Client::new(spec, &dir, IoChannel::disconnected()).unwrap();
 | 
			
		||||
				for (b, is_valid) in blocks.into_iter() {
 | 
			
		||||
					let mut hash = H256::new();
 | 
			
		||||
					if Block::is_good(&b) {
 | 
			
		||||
						if let Ok(h) = client.import_block(b.clone()) {
 | 
			
		||||
							hash = h;
 | 
			
		||||
						}
 | 
			
		||||
						let _ = client.import_block(b.clone());
 | 
			
		||||
					}
 | 
			
		||||
					client.flush_queue();
 | 
			
		||||
					let imported_ok = client.import_verified_blocks(&IoChannel::disconnected()) > 0;
 | 
			
		||||
					assert_eq!(imported_ok, is_valid);
 | 
			
		||||
					if imported_ok {
 | 
			
		||||
						flushln!("Imported {}; best block {}", hash, client.chain_info().best_block_hash);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				fail_unless(client.chain_info().best_block_hash == H256::from_json(&test["lastblockhash"]));
 | 
			
		||||
			}
 | 
			
		||||
@ -60,15 +54,15 @@ fn do_json_test(json_data: &[u8]) -> Vec<String> {
 | 
			
		||||
 | 
			
		||||
declare_test!{BlockchainTests_bcBlockGasLimitTest, "BlockchainTests/bcBlockGasLimitTest"}
 | 
			
		||||
declare_test!{BlockchainTests_bcForkBlockTest, "BlockchainTests/bcForkBlockTest"}
 | 
			
		||||
declare_test!{BlockchainTests_bcForkStressTest, "BlockchainTests/bcForkStressTest"}				// STILL FAILS
 | 
			
		||||
declare_test!{BlockchainTests_bcForkUncle, "BlockchainTests/bcForkUncle"}						// STILL FAILS
 | 
			
		||||
declare_test!{BlockchainTests_bcForkStressTest, "BlockchainTests/bcForkStressTest"}
 | 
			
		||||
declare_test!{BlockchainTests_bcForkUncle, "BlockchainTests/bcForkUncle"}
 | 
			
		||||
declare_test!{BlockchainTests_bcGasPricerTest, "BlockchainTests/bcGasPricerTest"}
 | 
			
		||||
declare_test!{BlockchainTests_bcInvalidHeaderTest, "BlockchainTests/bcInvalidHeaderTest"}
 | 
			
		||||
declare_test!{BlockchainTests_bcInvalidRLPTest, "BlockchainTests/bcInvalidRLPTest"}
 | 
			
		||||
declare_test!{BlockchainTests_bcMultiChainTest, "BlockchainTests/bcMultiChainTest"}
 | 
			
		||||
declare_test!{BlockchainTests_bcRPC_API_Test, "BlockchainTests/bcRPC_API_Test"}
 | 
			
		||||
declare_test!{BlockchainTests_bcStateTest, "BlockchainTests/bcStateTest"}
 | 
			
		||||
declare_test!{BlockchainTests_bcTotalDifficultyTest, "BlockchainTests/bcTotalDifficultyTest"}	// FAILS: ZeroPrefixed Int.
 | 
			
		||||
declare_test!{BlockchainTests_bcTotalDifficultyTest, "BlockchainTests/bcTotalDifficultyTest"}
 | 
			
		||||
declare_test!{BlockchainTests_bcUncleHeaderValiditiy, "BlockchainTests/bcUncleHeaderValiditiy"}
 | 
			
		||||
declare_test!{BlockchainTests_bcUncleTest, "BlockchainTests/bcUncleTest"}
 | 
			
		||||
declare_test!{BlockchainTests_bcValidBlockTest, "BlockchainTests/bcValidBlockTest"}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user