Skip to content

Commit

Permalink
Rework test/framework (hyperledger-iroha#1215)
Browse files Browse the repository at this point in the history
* Remove test block generator

Signed-off-by: kamilsa <[email protected]>
  • Loading branch information
kamilsa authored Apr 13, 2018
1 parent f1db8a1 commit 50255f1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 152 deletions.
12 changes: 0 additions & 12 deletions test/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,13 @@ target_link_libraries(test_subscriber_testing
rxcpp
)

add_library(test_block_generator test_block_generator.cpp)
target_link_libraries(test_block_generator
model
)

target_include_directories(test_block_generator PUBLIC ${PROJECT_SOURCE_DIR}/test)


add_library(integration_framework
integration_framework/integration_test_framework.cpp
integration_framework/iroha_instance.cpp
)
target_link_libraries(integration_framework
application
raw_block_insertion
keys_manager
model_generators
pb_model_converters
tbb
)

target_include_directories(integration_framework PUBLIC ${PROJECT_SOURCE_DIR}/test)
Expand Down
101 changes: 0 additions & 101 deletions test/framework/test_block_generator.cpp

This file was deleted.

34 changes: 0 additions & 34 deletions test/framework/test_block_generator.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion test/module/irohad/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ target_link_libraries(blob_converter_test
AddTest(block_insertion_test raw_block_loader_test.cpp)
target_link_libraries(block_insertion_test
json_model_converters
test_block_generator
raw_block_insertion
shared_model_cryptography_model
logger
)
17 changes: 13 additions & 4 deletions test/module/irohad/common/raw_block_loader_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,23 @@
#include "main/raw_block_loader.hpp"
#include <gtest/gtest.h>

#include "framework/test_block_generator.hpp"
#include "model/converters/json_block_factory.hpp"
#include "model/converters/json_common.hpp"
#include "model/converters/pb_command_factory.hpp"
#include "module/shared_model/builders/protobuf/test_block_builder.hpp"

using namespace iroha::main;
using namespace iroha::model::converters;
using namespace iroha;

auto generateBlock() {
return TestBlockBuilder()
.createdTime(100500)
.height(1)
.prevHash(shared_model::crypto::Hash(std::string(32, '0')))
.build();
}

/**
* @given generated block
*
Expand All @@ -37,10 +45,11 @@ using namespace iroha;
*/
TEST(BlockLoaderTest, BlockLoaderWhenParseBlock) {
BlockLoader loader;
auto block = framework::generator::generateBlock();
auto doc = JsonBlockFactory().serialize(block);
auto block = generateBlock();
auto old_block = *std::unique_ptr<iroha::model::Block>(block.makeOldModel());
auto doc = JsonBlockFactory().serialize(old_block);
auto str = jsonToString(doc);
auto new_block = loader.parseBlock(str);
ASSERT_TRUE(new_block);
ASSERT_EQ(block, *new_block);
ASSERT_EQ(old_block, *new_block);
}

0 comments on commit 50255f1

Please sign in to comment.