Skip to content

Commit

Permalink
Merge branch 'feature/pb-factories' of https://github.com/hyperledger…
Browse files Browse the repository at this point in the history
…/iroha into feature/pb-factories
  • Loading branch information
muratovv authored and lebdron committed Jul 19, 2017
2 parents ef72443 + 4f9b473 commit d58623a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions irohad/model/converters/impl/pb_command_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ namespace iroha {
return transfer_asset;
}

protocol::Command &&
protocol::Command
PbCommandFactory::serializeAbstractCommand(const model::Command &command) {
PbCommandFactory commandFactory;
auto cmd = protocol::Command();
Expand Down Expand Up @@ -365,7 +365,7 @@ namespace iroha {
serialized));
}

return std::forward<protocol::Command>(cmd);
return cmd;
}

std::shared_ptr<model::Command>
Expand Down
2 changes: 1 addition & 1 deletion irohad/model/converters/pb_command_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace iroha {
model::TransferAsset deserializeTransferAsset(const protocol::TransferAsset &subtractAssetQuantity);

// abstract
protocol::Command &&serializeAbstractCommand(const model::Command &command);
protocol::Command serializeAbstractCommand(const model::Command &command);
std::shared_ptr<model::Command> deserializeAbstractCommand(const protocol::Command &command);
};
} // namespace converters
Expand Down
6 changes: 5 additions & 1 deletion irohad/model/impl/model_operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,12 @@ namespace iroha {

/* Transaction */
bool Transaction::operator==(const Transaction &rhs) const {
if (rhs.commands.size() != commands.size()) return false;
for (uint i = 0; i < rhs.commands.size(); i++){
if (*rhs.commands.at(i) != *commands.at(i)) return false;
}
return rhs.tx_counter == tx_counter && rhs.signatures == signatures &&
rhs.created_ts == created_ts && rhs.commands == commands;
rhs.created_ts == created_ts;
}

bool Transaction::operator!=(const Transaction &rhs) const {
Expand Down
15 changes: 15 additions & 0 deletions test/module/irohad/model/converters/pb_transaction_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ TEST(TransactionTest, tx_test) {

auto factory = iroha::model::converters::PbTransactionFactory();
auto proto_tx = factory.serialize(orig_tx);
switch (proto_tx.body().commands().Get(0).command_case()){

case iroha::protocol::Command::kAddAssetQuantity:break;
case iroha::protocol::Command::kAddPeer:break;
case iroha::protocol::Command::kAddSignatory:break;
case iroha::protocol::Command::kAccountAssignMk:break;
case iroha::protocol::Command::kCreateAsset:break;
case iroha::protocol::Command::kCreateAccount:break;
case iroha::protocol::Command::kCreateDomain:break;
case iroha::protocol::Command::kRemoveSign:break;
case iroha::protocol::Command::kSetPermission:break;
case iroha::protocol::Command::kSetQuorum:break;
case iroha::protocol::Command::kTransferAsset:break;
case iroha::protocol::Command::COMMAND_NOT_SET:break;
}
auto serial_tx = factory.deserialize(proto_tx);
ASSERT_EQ(orig_tx, serial_tx);
}

0 comments on commit d58623a

Please sign in to comment.