Make example for `Testkit::rollback()` compileable
@@ -558,10 +558,53 @@ impl TestKit {
/// Rollbacks are useful in testing alternative scenarios (e.g., transactions executed
/// in different order and/or in different blocks) that require an expensive setup:
///
- /// ```ignore
- /// let mut testkit = ...;
+ /// ```
+ /// # #[macro_use] extern crate exonum;
+ /// # #[macro_use] extern crate exonum_testkit;
+ /// # use exonum::blockchain::{Service, Transaction};
+ /// # use exonum::messages::RawTransaction;
+ /// # use exonum::encoding;
+ /// # use exonum_testkit::{TestKit, TestKitBuilder};
+ /// #
+ /// # type FromRawResult = Result<Box<Transaction>, encoding::Error>;
+ /// # pub struct MyService;
+ /// # impl Service for MyService {
+ /// # fn service_name(&self) -> &'static str {
+ /// # "documentation"
+ /// # }
+ /// # fn service_id(&self) -> u16 {
+ /// # 0
+ /// # }
+ /// # fn tx_from_raw(&self, _raw: RawTransaction) -> FromRawResult {
+ /// # unimplemented!();
+ /// # }
+ /// # }
+ /// #
+ /// # message! {
+ /// # struct MyTransaction {
+ /// # const TYPE = 0;
+ /// # const ID = 0;
+ /// # const SIZE = 40;
+ /// # field from: &exonum::crypto::PublicKey [0 => 32]
+ /// # field msg: &str [32 => 40]
+ /// # }
+ /// # }
+ /// # impl Transaction for MyTransaction {
+ /// # fn verify(&self) -> bool { true }
+ /// # fn execute(&self, _: &mut exonum::storage::Fork) {}
+ /// # }
+ /// #
+ /// # fn expensive_setup(_: &mut TestKit) {}
+ /// # fn assert_something_about(_: &TestKit) {}
+ /// #
+ /// # fn main() {
+ /// let mut testkit = TestKitBuilder::validator()
+ /// .with_service(MyService)
+ /// .create();
/// expensive_setup(&mut testkit);
- /// let (tx_a, tx_b) = ...;
+ /// let (pubkey, key) = exonum::crypto::gen_keypair();
+ /// let tx_a = MyTransaction::new(&pubkey, "foo", &key);
+ /// let tx_b = MyTransaction::new(&pubkey, "bar", &key);
/// testkit.create_block_with_transactions(txvec![tx_a.clone(), tx_b.clone()]);
/// assert_something_about(&testkit);
/// testkit.rollback(1);
@@ -569,7 +612,7 @@ impl TestKit {
/// testkit.create_block_with_transactions(txvec![tx_b.clone()]);
/// assert_something_about(&testkit);
/// testkit.rollback(2);
- /// ...
+ /// # }
/// ```
pub fn rollback(&mut self, blocks: usize) {
assert!(
