message: added test for diff update
diff: @@ -118,3 +118,60 @@ TEST_F(StorageTest, StorageDoesNotFindNonExistingBatch) {
  auto distinct_batch = makeTestBatch(txBuilder(4, creation_time));
  EXPECT_FALSE(storage->batchInStorage(distinct_batch));
  }
  +
  +/**
  + * @given storage with a batch from peer A (quorum = 3, 1 signature)
  + * @when the batch gets updated with a new signature from Torii
  + * @then the diff for peer A has the new signature
  + */
  +TEST_F(StorageTest, ClearStalledPeerStatesTest) {
  + using namespace testing;
  + using namespace shared_model::interface;
  +
  + std::vector<shared_model::crypto::Keypair> keypairs;
  + std::generate_n(std::back_inserter(keypairs), 2, [] {
  + return shared_model::crypto::DefaultCryptoAlgorithmType::generateKeypair();
  + });
  +
  + const auto batch =
  + framework::batch::makeTestBatch(txBuilder(1, creation_time));
  +
  + const auto peerAKey = shared_model::crypto::PublicKey("A");
  +
  + // storage gets a batch from peer A with 1st signature
  + {
  + auto new_state = MstState::empty(getTestLogger("MstState"), completer_);
  + new_state += addSignaturesFromKeyPairs(
  + std::make_unique<TransactionBatchImpl>(batch->transactions()),
  + 0,
  + keypairs[0]);
  +
  + storage->apply(peerAKey, std::move(new_state));
  + }
  +
  + // diff with peer A does not have this batch
  + ASSERT_THAT(storage->getDiffState(peerAKey, creation_time).getBatches(),
  + Not(Contains(Pointee(Property(
  + &TransactionBatch::transactions,
  + Contains(Pointee(Property(
  + &Transaction::reducedHash,
  + Eq(batch->transactions().front()->reducedHash())))))))));
  +
  + // storage gets another signature for the batch from Torii
  + storage->updateOwnState(addSignaturesFromKeyPairs(
  + std::make_unique<TransactionBatchImpl>(batch->transactions()),
  + 0,
  + keypairs[1]));
  +
  + // diff with peer A now has the batch with the signature that just came Torii
  + EXPECT_THAT(
  + storage->getDiffState(peerAKey, creation_time).getBatches(),
  + Contains(Pointee(Property(
  + &TransactionBatch::transactions,
  + ElementsAre(Pointee(AllOf(
  + Property(&Transaction::reducedHash,
  + Eq(batch->transactions().front()->reducedHash())),
  + Property(&Transaction::signatures,
  + Contains(Property(&Signature::publicKey,
  + Eq(keypairs[1].publicKey())))))))))));
  +}
  