fn remove_coinbase_kernel_flag() {
	let keychain = ExtKeychain::from_random_seed().unwrap();
	let prev = BlockHeader::default();
	let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
	let mut b = new_block(vec![], &keychain, &prev, &key_id);

	assert!(b.kernels()[0]
		.features
		.contains(KernelFeatures::COINBASE_KERNEL));
	b.kernels_mut()[0]
		.features
		.remove(KernelFeatures::COINBASE_KERNEL);

	// Flipping the coinbase flag results in kernels not summing correctly.
	assert_eq!(
		b.verify_coinbase(),
		Err(Error::Secp(secp::Error::IncorrectCommitSum))
	);

	// Also results in the block no longer validating correctly
	// because the message being signed on each tx kernel includes the kernel features.
	assert_eq!(
		b.validate(&BlindingFactor::zero(), verifier_cache()),
		Err(Error::Transaction(transaction::Error::IncorrectSignature))
	);
}
// test that flipping the COINBASE_KERNEL flag on the kernel features
// invalidates the block and specifically it causes verify_coinbase to fail
test that flipping the COINBASE_KERNEL flag on the kernel features
invalidates the block and specifically it causes verify_coinbase to fail
test that flipping the COINBASE_KERNEL flag on the kernel features invalidates the block and specifically it causes verify_coinbase to fail
fn remove_coinbase_kernel_flag() {
	let keychain = ExtKeychain::from_random_seed().unwrap();
	let prev = BlockHeader::default();
	let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
	let mut b = new_block(vec![], &keychain, &prev, &key_id);
	assert!(b.kernels()[0]
		.features
		.contains(KernelFeatures::COINBASE_KERNEL));
	b.kernels_mut()[0]
		.features
		.remove(KernelFeatures::COINBASE_KERNEL);
	// Flipping the coinbase flag results in kernels not summing correctly.
	assert_eq!(
		b.verify_coinbase(),
		Err(Error::Secp(secp::Error::IncorrectCommitSum))
	);
	// Also results in the block no longer validating correctly
	// because the message being signed on each tx kernel includes the kernel features.
	assert_eq!(
		b.validate(&BlindingFactor::zero(), verifier_cache()),
		Err(Error::Transaction(transaction::Error::IncorrectSignature))
	);
}
fn remove_coinbase_kernel_flag ( ) { let keychain = ExtKeychain :: from_random_seed ( ) . unwrap ( ) ; let prev = BlockHeader :: default ( ) ; let key_id = ExtKeychain :: derive_key_id ( 1 , 1 , 0 , 0 , 0 ) ; let mut b = new_block ( vec ! [ ] , & keychain , & prev , & key_id ) ; assert ! ( b kernels ( ) [ 0 ] features contains ( KernelFeatures COINBASE_KERNEL ) ) ; b . kernels_mut ( ) [ 0 ] . features . remove ( KernelFeatures :: COINBASE_KERNEL ) ; // Flipping the coinbase flag results in kernels not summing correctly. assert_eq ! ( b verify_coinbase ( ) Err ( Error Secp ( secp Error IncorrectCommitSum ) ) ) ; // Also results in the block no longer validating correctly // because the message being signed on each tx kernel includes the kernel features. assert_eq ! ( b validate ( BlindingFactor zero ( ) verifier_cache ( ) ) Err ( Error Transaction ( transaction Error IncorrectSignature ) ) ) ; }
test that flipping the COINBASE_KERNEL flag on the kernel features
invalidates the block and specifically it causes verify_coinbase to fail
test that flipping the COINBASE_KERNEL flag on the kernel features invalidates the block and specifically it causes verify_coinbase to fail