Skip to content

Commit

Permalink
An assortment of fixes for bindings (hyperledger-iroha#1490)
Browse files Browse the repository at this point in the history
* Separate server and client objects in build for shared_model

* Enable android bindings build from current commit instead of develop

* Remove parallelism on Windows for python and java

* Add missing ciso646 include

* Enable js tests for getTxs, remove proto perms from swig iface

* Fix crypto patch for shared model subdirectory

Signed-off-by: Andrei Lebedev <[email protected]>
  • Loading branch information
lebdron authored Jun 22, 2018
1 parent 6a96a87 commit 2947016
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 39 deletions.
8 changes: 5 additions & 3 deletions .jenkinsci/bindings.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def doJavaBindings(os, buildType=Release) {
-DSWIG_JAVA=ON \
${cmakeOptions}
"""
sh "cmake --build build --target irohajava -- -j${params.PARALLELISM}"
def parallelismParam = (os == 'windows') ? '' : "-j${params.PARALLELISM}"
sh "cmake --build build --target irohajava -- ${parallelismParam}"
// TODO 29.05.18 @bakhtin Java tests never finishes on Windows Server 2016. IR-1380
sh "zip -j $artifactsPath build/bindings/*.java build/bindings/*.dll build/bindings/libirohajava.so"
if (os == 'windows') {
Expand Down Expand Up @@ -59,7 +60,8 @@ def doPythonBindings(os, buildType=Release) {
-DSUPPORT_PYTHON2=$supportPython2 \
${cmakeOptions}
"""
sh "cmake --build build --target irohapy -- -j${params.PARALLELISM}"
def parallelismParam = (os == 'windows') ? '' : "-j${params.PARALLELISM}"
sh "cmake --build build --target irohapy -- ${parallelismParam}"
sh "cmake --build build --target python_tests"
sh "cd build; ctest -R python --output-on-failure"
if (os == 'linux') {
Expand Down Expand Up @@ -108,7 +110,7 @@ def doAndroidBindings(abiVersion) {
[currentPath, "\$PLATFORM", abiVersion, "\$BUILD_TYPE_A", sh(script: 'date "+%Y%m%d"', returnStdout: true).trim(), commit.substring(0,6)])
sh """
(cd /iroha; git init; git remote add origin https://github.com/hyperledger/iroha.git; \
git fetch --depth 1 origin develop; git checkout -t origin/develop)
git fetch origin ${GIT_COMMIT}; git checkout FETCH_HEAD)
"""
sh """
. /entrypoint.sh; \
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ include_directories(
${IROHA_SCHEMA_DIR}
)

SET(IROHA_ROOT_PROJECT ON)

include(FeatureSummary)
include(cmake/functions.cmake)
include(cmake/dependencies.cmake)
Expand All @@ -117,8 +119,6 @@ if(PACKAGE_TGZ OR PACKAGE_ZIP OR PACKAGE_RPM OR PACKAGE_DEB)
include(cmake/release.cmake)
endif()

SET(IROHA_ROOT_PROJECT ON)

add_subdirectory(schema)
add_subdirectory(libs)
add_subdirectory(irohad)
Expand Down
6 changes: 5 additions & 1 deletion cmake/Modules/Finded25519.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ set_target_description(ed25519 "Digital signature algorithm" ${URL} ${VERSION})
if (NOT ed25519_FOUND)
if (NOT WIN32)
find_package(Git REQUIRED)
set(PATCH_RANDOM ${GIT_EXECUTABLE} apply ${PROJECT_SOURCE_DIR}/patch/close.patch || true)
set(PATCH_RANDOM ${GIT_EXECUTABLE} apply ${PROJECT_SOURCE_DIR})
if (NOT IROHA_ROOT_PROJECT)
set(PATCH_RANDOM ${PATCH_RANDOM}/..)
endif ()
set(PATCH_RANDOM ${PATCH_RANDOM}/patch/close.patch || true)
endif ()

externalproject_add(hyperledger_ed25519
Expand Down
31 changes: 18 additions & 13 deletions shared_model/backend/protobuf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@ add_library(shared_model_proto_backend
commands/impl/proto_set_quorum.cpp
commands/impl/proto_subtract_asset_quantity.cpp
commands/impl/proto_transfer_asset.cpp
query_responses/impl/proto_account_asset_response.cpp
query_responses/impl/proto_account_detail_response.cpp
query_responses/impl/proto_account_response.cpp
query_responses/impl/proto_asset_response.cpp
query_responses/impl/proto_error_query_response.cpp
query_responses/impl/proto_query_response.cpp
query_responses/impl/proto_role_permissions_response.cpp
query_responses/impl/proto_roles_response.cpp
query_responses/impl/proto_signatories_response.cpp
query_responses/impl/proto_transaction_response.cpp
query_responses/impl/proto_block_query_response.cpp
query_responses/impl/proto_block_response.cpp
query_responses/impl/proto_block_error_response.cpp
queries/impl/proto_query.cpp
queries/impl/proto_get_account.cpp
queries/impl/proto_get_account_asset_transactions.cpp
Expand All @@ -45,6 +32,24 @@ add_library(shared_model_proto_backend
queries/impl/proto_query_payload_meta.cpp
)

if (IROHA_ROOT_PROJECT)
target_sources(shared_model_proto_backend PRIVATE
query_responses/impl/proto_account_asset_response.cpp
query_responses/impl/proto_account_detail_response.cpp
query_responses/impl/proto_account_response.cpp
query_responses/impl/proto_asset_response.cpp
query_responses/impl/proto_error_query_response.cpp
query_responses/impl/proto_query_response.cpp
query_responses/impl/proto_role_permissions_response.cpp
query_responses/impl/proto_roles_response.cpp
query_responses/impl/proto_signatories_response.cpp
query_responses/impl/proto_transaction_response.cpp
query_responses/impl/proto_block_query_response.cpp
query_responses/impl/proto_block_response.cpp
query_responses/impl/proto_block_error_response.cpp
)
endif ()

target_link_libraries(shared_model_proto_backend
schema
shared_model_interfaces
Expand Down
1 change: 0 additions & 1 deletion shared_model/bindings/bindings.i
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ namespace std {
%include "cryptography/hash.hpp"
%include "cryptography/keypair.hpp"
%include "cryptography/signed.hpp"
%include "backend/protobuf/permissions.hpp"
%include "backend/protobuf/transaction.hpp"
%include "backend/protobuf/queries/proto_query.hpp"
%include "backend/protobuf/queries/proto_blocks_query.hpp"
Expand Down
35 changes: 20 additions & 15 deletions shared_model/interfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ add_library(shared_model_interfaces
commands/impl/set_quorum.cpp
commands/impl/subtract_asset_quantity.cpp
commands/impl/transfer_asset.cpp
query_responses/impl/account_asset_response.cpp
query_responses/impl/account_detail_response.cpp
query_responses/impl/account_response.cpp
query_responses/impl/asset_response.cpp
query_responses/impl/error_query_response.cpp
query_responses/impl/query_response.cpp
query_responses/impl/role_permissions.cpp
query_responses/impl/roles_response.cpp
query_responses/impl/signatories_response.cpp
query_responses/impl/transactions_response.cpp
query_responses/impl/block_error_response.cpp
query_responses/impl/block_query_response.cpp
query_responses/impl/block_response.cpp
queries/impl/query.cpp
queries/impl/get_account.cpp
queries/impl/get_account_asset_transactions.cpp
Expand All @@ -57,10 +44,28 @@ add_library(shared_model_interfaces
queries/impl/get_transactions.cpp
queries/impl/blocks_query.cpp
queries/impl/query_payload_meta.cpp
iroha_internal/block_variant.cpp
iroha_internal/transaction_sequence.cpp
)

if (IROHA_ROOT_PROJECT)
target_sources(shared_model_interfaces PRIVATE
query_responses/impl/account_asset_response.cpp
query_responses/impl/account_detail_response.cpp
query_responses/impl/account_response.cpp
query_responses/impl/asset_response.cpp
query_responses/impl/error_query_response.cpp
query_responses/impl/query_response.cpp
query_responses/impl/role_permissions.cpp
query_responses/impl/roles_response.cpp
query_responses/impl/signatories_response.cpp
query_responses/impl/transactions_response.cpp
query_responses/impl/block_error_response.cpp
query_responses/impl/block_query_response.cpp
query_responses/impl/block_response.cpp
iroha_internal/block_variant.cpp
iroha_internal/transaction_sequence.cpp
)
endif ()

target_link_libraries(shared_model_interfaces
shared_model_cryptography
${Boost_LIBRARIES}
Expand Down
9 changes: 6 additions & 3 deletions shared_model/packages/javascript/tests/queryBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const accountId = 'admin@test'
const assetId = 'coin#test'

test('ModelQueryBuilder tests', function (t) {
t.plan(47)
t.plan(48)

let queryBuilder = new iroha.ModelQueryBuilder()
const time = (new Date()).getTime()
Expand Down Expand Up @@ -87,10 +87,13 @@ test('ModelQueryBuilder tests', function (t) {
let hv = new iroha.HashVector()
hv.add(new iroha.Hash('11111111111111111111111111111111'))
hv.add(new iroha.Hash('22222222222222222222222222222222'))
let invalidHv = new iroha.HashVector()
invalidHv.add(new iroha.Hash(''))
let emptyHv = new iroha.HashVector()

t.throws(() => correctQuery.getTransactions(emptyHv), /Hash set should contain at least one hash/, 'Should throw Hash set should contain at least one hash')
t.doesNotThrow(() => correctQuery.getTransactions(hv), null, 'Should not throw any exceptions')
t.throws(() => correctQuery.getTransactions(emptyHv).build(), /tx_hashes cannot be empty/, 'Should throw tx_hashes cannot be empty')
t.throws(() => correctQuery.getTransactions(invalidHv).build(), /Hash has invalid size: 0/, 'Should throw Hash has invalid size')
t.doesNotThrow(() => correctQuery.getTransactions(hv).build(), null, 'Should not throw any exceptions')

// getAccountDetail() tests
t.comment('Testing getAccountDetail()')
Expand Down
4 changes: 3 additions & 1 deletion shared_model/validators/answer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
#ifndef IROHA_ANSWER_HPP
#define IROHA_ANSWER_HPP

#include <boost/range/numeric.hpp>
#include <ciso646>
#include <map>
#include <vector>

#include <boost/range/numeric.hpp>
#include "utils/string_builder.hpp"

namespace shared_model {
Expand Down

0 comments on commit 2947016

Please sign in to comment.