fn block_with_cut_through() {
	let keychain = ExtKeychain::from_random_seed().unwrap();
	let key_id1 = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
	let key_id2 = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
	let key_id3 = ExtKeychain::derive_key_id(1, 3, 0, 0, 0);

	let mut btx1 = tx2i1o();
	let mut btx2 = build::transaction(
		vec![input(7, key_id1), output(5, key_id2.clone()), with_fee(2)],
		&keychain,
	)
	.unwrap();

	// spending tx2 - reuse key_id2

	let mut btx3 = txspend1i1o(5, &keychain, key_id2.clone(), key_id3);
	let prev = BlockHeader::default();
	let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
	let b = new_block(
		vec![&mut btx1, &mut btx2, &mut btx3],
		&keychain,
		&prev,
		&key_id,
	);

	// block should have been automatically compacted (including reward
	// output) and should still be valid
	println!("3");
	b.validate(&BlindingFactor::zero(), verifier_cache())
		.unwrap();
	assert_eq!(b.inputs().len(), 3);
	assert_eq!(b.outputs().len(), 3);
	println!("4");
}
// builds a block with a tx spending another and check that cut_through occurred
builds a block with a tx spending another and check that cut_through occurred
builds a block with a tx spending another and check that cut_through occurred
fn block_with_cut_through() {
	let keychain = ExtKeychain::from_random_seed().unwrap();
	let key_id1 = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
	let key_id2 = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
	let key_id3 = ExtKeychain::derive_key_id(1, 3, 0, 0, 0);
	let mut btx1 = tx2i1o();
	let mut btx2 = build::transaction(
		vec![input(7, key_id1), output(5, key_id2.clone()), with_fee(2)],
		&keychain,
	)
	.unwrap();
	// spending tx2 - reuse key_id2
	let mut btx3 = txspend1i1o(5, &keychain, key_id2.clone(), key_id3);
	let prev = BlockHeader::default();
	let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
	let b = new_block(
		vec![&mut btx1, &mut btx2, &mut btx3],
		&keychain,
		&prev,
		&key_id,
	);
	// block should have been automatically compacted (including reward
	// output) and should still be valid
	println!("3");
	b.validate(&BlindingFactor::zero(), verifier_cache())
		.unwrap();
	assert_eq!(b.inputs().len(), 3);
	assert_eq!(b.outputs().len(), 3);
	println!("4");
}
fn block_with_cut_through ( ) { let keychain = ExtKeychain :: from_random_seed ( ) . unwrap ( ) ; let key_id1 = ExtKeychain :: derive_key_id ( 1 , 1 , 0 , 0 , 0 ) ; let key_id2 = ExtKeychain :: derive_key_id ( 1 , 2 , 0 , 0 , 0 ) ; let key_id3 = ExtKeychain :: derive_key_id ( 1 , 3 , 0 , 0 , 0 ) ; let mut btx1 = tx2i1o ( ) ; let mut btx2 = build :: transaction ( vec ! [ input ( 7 key_id1 ) output ( 5 key_id2 clone ( ) ) with_fee ( 2 ) ] , & keychain , ) . unwrap ( ) ; // spending tx2 - reuse key_id2 let mut btx3 = txspend1i1o ( 5 , & keychain , key_id2 . clone ( ) , key_id3 ) ; let prev = BlockHeader :: default ( ) ; let key_id = ExtKeychain :: derive_key_id ( 1 , 1 , 0 , 0 , 0 ) ; let b = new_block ( vec ! [ mut btx1 mut btx2 mut btx3 ] , & keychain , & prev , & key_id , ) ; // block should have been automatically compacted (including reward // output) and should still be valid println ! ( " " ) ; b . validate ( & BlindingFactor :: zero ( ) , verifier_cache ( ) ) . unwrap ( ) ; assert_eq ! ( b inputs ( ) len ( ) 3 ) ; assert_eq ! ( b outputs ( ) len ( ) 3 ) ; println ! ( " " ) ; }
builds a block with a tx spending another and check that cut_through occurred
builds a block with a tx spending another and check that cut_through occurred