Test: simplify Makefile
This commit is contained in:
parent
166801fc77
commit
a6c7f355cc
@ -36,17 +36,21 @@ src/client/embedded/alpha/webclient/static/main.js
|
|||||||
src/client/embedded/alpha/webclient/webclient_proto_static.ml
|
src/client/embedded/alpha/webclient/webclient_proto_static.ml
|
||||||
|
|
||||||
test/.depend
|
test/.depend
|
||||||
|
test/lib/.depend
|
||||||
|
test/utils/.depend
|
||||||
|
test/p2p/.depend
|
||||||
|
test/shell/.depend
|
||||||
test/reports
|
test/reports
|
||||||
|
|
||||||
test/test-store
|
test/utils/test-data-encoding
|
||||||
test/test-state
|
test/utils/test-merkle
|
||||||
test/test-context
|
test/utils/test-lwt-pipe
|
||||||
test/test-basic
|
test/p2p/test-p2p-io-scheduler
|
||||||
test/test-data-encoding
|
test/p2p/test-p2p-connection
|
||||||
test/test-p2p-io-scheduler
|
test/p2p/test-p2p-connection-pool
|
||||||
test/test-p2p-connection
|
test/shell/test-store
|
||||||
test/test-p2p-connection-pool
|
test/shell/test-state
|
||||||
test/LOG
|
test/shell/test-context
|
||||||
|
|
||||||
**/*~
|
**/*~
|
||||||
**/\#*\#
|
**/\#*\#
|
||||||
|
24
.gitignore
vendored
24
.gitignore
vendored
@ -35,19 +35,21 @@
|
|||||||
/src/client/embedded/alpha/webclient/webclient_proto_static.ml
|
/src/client/embedded/alpha/webclient/webclient_proto_static.ml
|
||||||
|
|
||||||
/test/.depend
|
/test/.depend
|
||||||
|
/test/lib/.depend
|
||||||
|
/test/utils/.depend
|
||||||
|
/test/p2p/.depend
|
||||||
|
/test/shell/.depend
|
||||||
/test/reports
|
/test/reports
|
||||||
|
|
||||||
/test/test-store
|
/test/utils/test-data-encoding
|
||||||
/test/test-state
|
/test/utils/test-merkle
|
||||||
/test/test-context
|
/test/utils/test-lwt-pipe
|
||||||
/test/test-basic
|
/test/p2p/test-p2p-io-scheduler
|
||||||
/test/test-data-encoding
|
/test/p2p/test-p2p-connection
|
||||||
/test/test-merkle
|
/test/p2p/test-p2p-connection-pool
|
||||||
/test/test-p2p-io-scheduler
|
/test/shell/test-store
|
||||||
/test/test-p2p-connection
|
/test/shell/test-state
|
||||||
/test/test-p2p-connection-pool
|
/test/shell/test-context
|
||||||
/test/generate_hash
|
|
||||||
/test/LOG
|
|
||||||
|
|
||||||
*~
|
*~
|
||||||
\#*\#
|
\#*\#
|
||||||
|
102
.gitlab-ci.yml
102
.gitlab-ci.yml
@ -27,44 +27,81 @@ build:
|
|||||||
script:
|
script:
|
||||||
- echo "PRODUCTION=yes" > src/Makefile.local
|
- echo "PRODUCTION=yes" > src/Makefile.local
|
||||||
- make -C src -j4
|
- make -C src -j4
|
||||||
- make -C test -j4 build-test
|
- make -C test build
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
untracked: true
|
untracked: true
|
||||||
|
|
||||||
test:store:
|
|
||||||
|
test:utils:data-encoding:
|
||||||
stage: test
|
stage: test
|
||||||
tags:
|
tags:
|
||||||
- tezos_builder
|
- tezos_builder
|
||||||
script:
|
script:
|
||||||
- make -C test run-test-store
|
- make -C test/utils run-test-data-encoding
|
||||||
dependencies:
|
dependencies:
|
||||||
- build
|
- build
|
||||||
|
|
||||||
test:context:
|
test:utils:merkle:
|
||||||
stage: test
|
stage: test
|
||||||
tags:
|
tags:
|
||||||
- tezos_builder
|
- tezos_builder
|
||||||
script:
|
script:
|
||||||
- make -C test run-test-context
|
- make -C test/utils run-test-merkle
|
||||||
dependencies:
|
dependencies:
|
||||||
- build
|
- build
|
||||||
|
|
||||||
test:state:
|
test:shell:store:
|
||||||
stage: test
|
stage: test
|
||||||
tags:
|
tags:
|
||||||
- tezos_builder
|
- tezos_builder
|
||||||
script:
|
script:
|
||||||
- make -C test run-test-state
|
- make -C test/shell run-test-store
|
||||||
dependencies:
|
dependencies:
|
||||||
- build
|
- build
|
||||||
|
|
||||||
test:basic:
|
test:shell:context:
|
||||||
stage: test
|
stage: test
|
||||||
tags:
|
tags:
|
||||||
- tezos_builder
|
- tezos_builder
|
||||||
script:
|
script:
|
||||||
- make -C test run-test-basic
|
- make -C test/shell run-test-context
|
||||||
|
dependencies:
|
||||||
|
- build
|
||||||
|
|
||||||
|
test:shell:state:
|
||||||
|
stage: test
|
||||||
|
tags:
|
||||||
|
- tezos_builder
|
||||||
|
script:
|
||||||
|
- make -C test/shell run-test-state
|
||||||
|
dependencies:
|
||||||
|
- build
|
||||||
|
|
||||||
|
test:p2p:io-scheduler:
|
||||||
|
stage: test
|
||||||
|
tags:
|
||||||
|
- tezos_builder
|
||||||
|
script:
|
||||||
|
- make -C test/p2p run-test-p2p-io-scheduler
|
||||||
|
dependencies:
|
||||||
|
- build
|
||||||
|
|
||||||
|
test:p2p:connection:
|
||||||
|
stage: test
|
||||||
|
tags:
|
||||||
|
- tezos_builder
|
||||||
|
script:
|
||||||
|
- make -C test/p2p run-test-p2p-connection
|
||||||
|
dependencies:
|
||||||
|
- build
|
||||||
|
|
||||||
|
test:p2p:connection-pool:
|
||||||
|
stage: test
|
||||||
|
tags:
|
||||||
|
- tezos_builder
|
||||||
|
script:
|
||||||
|
- make -C test/p2p run-test-p2p-connection-pool
|
||||||
dependencies:
|
dependencies:
|
||||||
- build
|
- build
|
||||||
|
|
||||||
@ -73,52 +110,7 @@ test:basic.sh:
|
|||||||
tags:
|
tags:
|
||||||
- tezos_builder
|
- tezos_builder
|
||||||
script:
|
script:
|
||||||
- make -C test run-test-basic.sh
|
- make -C test run-basic.sh
|
||||||
dependencies:
|
|
||||||
- build
|
|
||||||
|
|
||||||
test:data-encoding:
|
|
||||||
stage: test
|
|
||||||
tags:
|
|
||||||
- tezos_builder
|
|
||||||
script:
|
|
||||||
- make -C test run-test-data-encoding
|
|
||||||
dependencies:
|
|
||||||
- build
|
|
||||||
|
|
||||||
test:merkle:
|
|
||||||
stage: test
|
|
||||||
tags:
|
|
||||||
- tezos_builder
|
|
||||||
script:
|
|
||||||
- make -C test run-test-merkle
|
|
||||||
dependencies:
|
|
||||||
- build
|
|
||||||
|
|
||||||
test:p2p-io-scheduler:
|
|
||||||
stage: test
|
|
||||||
tags:
|
|
||||||
- tezos_builder
|
|
||||||
script:
|
|
||||||
- make -C test run-test-p2p-io-scheduler
|
|
||||||
dependencies:
|
|
||||||
- build
|
|
||||||
|
|
||||||
test:p2p-connection:
|
|
||||||
stage: test
|
|
||||||
tags:
|
|
||||||
- tezos_builder
|
|
||||||
script:
|
|
||||||
- make -C test run-test-p2p-connection
|
|
||||||
dependencies:
|
|
||||||
- build
|
|
||||||
|
|
||||||
test:p2p-connection-pool:
|
|
||||||
stage: test
|
|
||||||
tags:
|
|
||||||
- tezos_builder
|
|
||||||
script:
|
|
||||||
- make -C test run-test-p2p-connection-pool
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- build
|
- build
|
||||||
|
|
||||||
|
499
src/Makefile
499
src/Makefile
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
-include Makefile.local
|
-include Makefile.local
|
||||||
include Makefile.config
|
include Makefile.config
|
||||||
|
include Makefile.files
|
||||||
|
|
||||||
TZCOMPILER=../tezos-protocol-compiler
|
TZCOMPILER=../tezos-protocol-compiler
|
||||||
TZNODE=../tezos-node
|
TZNODE=../tezos-node
|
||||||
@ -10,45 +11,12 @@ TZATTACKER=../tezos-attacker
|
|||||||
|
|
||||||
all: ${TZCOMPILER} ${TZNODE} ${TZCLIENT} # ${TZWEBCLIENT} ${TZATTACKER}
|
all: ${TZCOMPILER} ${TZNODE} ${TZCLIENT} # ${TZWEBCLIENT} ${TZATTACKER}
|
||||||
|
|
||||||
|
|
||||||
NODEPS :=
|
NODEPS :=
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
## Protocol environment
|
## Protocol environment
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
PROTOCOL_ENV_INTFS := \
|
|
||||||
$(addprefix proto/environment/, \
|
|
||||||
pervasives.mli \
|
|
||||||
compare.mli \
|
|
||||||
\
|
|
||||||
array.mli list.mli bytes.mli string.mli \
|
|
||||||
set.mli map.mli \
|
|
||||||
int32.mli int64.mli \
|
|
||||||
buffer.mli \
|
|
||||||
format.mli \
|
|
||||||
\
|
|
||||||
lwt_sequence.mli lwt.mli lwt_list.mli \
|
|
||||||
\
|
|
||||||
mBytes.mli \
|
|
||||||
hex_encode.mli \
|
|
||||||
\
|
|
||||||
uri.mli \
|
|
||||||
data_encoding.mli \
|
|
||||||
error_monad.mli \
|
|
||||||
logging.mli \
|
|
||||||
time.mli \
|
|
||||||
base58.mli \
|
|
||||||
hash.mli \
|
|
||||||
ed25519.mli \
|
|
||||||
persist.mli \
|
|
||||||
fitness.mli \
|
|
||||||
context.mli \
|
|
||||||
RPC.mli \
|
|
||||||
\
|
|
||||||
updater.mli \
|
|
||||||
)
|
|
||||||
|
|
||||||
.INTERMEDIATE: compiler/environment_gen
|
.INTERMEDIATE: compiler/environment_gen
|
||||||
.SECONDARY: node/updater/proto_environment.mli
|
.SECONDARY: node/updater/proto_environment.mli
|
||||||
|
|
||||||
@ -79,32 +47,16 @@ partial-clean::
|
|||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
|
|
||||||
COMPILER_EMBEDDED_CMIS := \
|
|
||||||
compiler/sigs/camlinternalFormatBasics.cmi \
|
|
||||||
compiler/sigs/proto_environment.cmi \
|
|
||||||
compiler/sigs/register.cmi
|
|
||||||
|
|
||||||
compiler/sigs/register.cmi: EXTRA_OCAMLFLAGS = -opaque
|
compiler/sigs/register.cmi: EXTRA_OCAMLFLAGS = -opaque
|
||||||
|
|
||||||
COMPILER_PRECOMPILED_INTFS := \
|
|
||||||
compiler/sigs/tezos_compiler.mli \
|
|
||||||
compiler/sigs/fitness.mli \
|
|
||||||
compiler/sigs/persist.mli \
|
|
||||||
compiler/sigs/store_sigs.mli \
|
|
||||||
compiler/sigs/store.mli \
|
|
||||||
compiler/sigs/context.mli \
|
|
||||||
compiler/sigs/protocol.mli \
|
|
||||||
compiler/sigs/proto_environment.mli \
|
|
||||||
compiler/sigs/register.mli
|
|
||||||
|
|
||||||
COMPILER_PRECOMPILED_OBJS := \
|
COMPILER_PRECOMPILED_OBJS := \
|
||||||
${COMPILER_PRECOMPILED_INTFS:.mli=.cmi} \
|
${COMPILER_PRECOMPILED_INTFS:.mli=.cmi} \
|
||||||
${COMPILER_PRECOMPILED_INTFS:.mli=.mli.deps}
|
${COMPILER_PRECOMPILED_INTFS:.mli=.mli.deps}
|
||||||
|
|
||||||
${COMPILER_PRECOMPILED_OBJS}: PACKAGES=${MINUTILS_PACKAGES} ${UTILS_PACKAGES}
|
${COMPILER_PRECOMPILED_OBJS}: PACKAGES=${COMPILER_PRECOMPILED_PACKAGES}
|
||||||
${COMPILER_PRECOMPILED_OBJS}: SOURCE_DIRECTORIES=minutils utils compiler/sigs/
|
${COMPILER_PRECOMPILED_OBJS}: SOURCE_DIRECTORIES=${COMPILER_PRECOMPILED_SOURCE_DIRECTORIES}
|
||||||
${COMPILER_PRECOMPILED_OBJS}: TARGET="(embedded_cmis.cmx)"
|
${COMPILER_PRECOMPILED_OBJS}: TARGET="(embedded_cmis.cmx)"
|
||||||
${COMPILER_PRECOMPILED_OBJS}: OPENED_MODULES=Error_monad Hash Utils
|
${COMPILER_PRECOMPILED_OBJS}: OPENED_MODULES=${COMPILER_PRECOMPILED_OPENED_MODULES}
|
||||||
|
|
||||||
compiler/sigs/camlinternalFormatBasics.cmi:
|
compiler/sigs/camlinternalFormatBasics.cmi:
|
||||||
ln -sf $(shell ocamlc -where)/camlinternalFormatBasics.cmi $@
|
ln -sf $(shell ocamlc -where)/camlinternalFormatBasics.cmi $@
|
||||||
@ -156,36 +108,13 @@ node/db/context.cmi: compiler/sigs/context.cmi
|
|||||||
## Minimal utils library compatible with js_of_ocaml
|
## Minimal utils library compatible with js_of_ocaml
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
MINUTILS_LIB_INTFS := \
|
|
||||||
minutils/mBytes.mli \
|
|
||||||
minutils/hex_encode.mli \
|
|
||||||
minutils/utils.mli \
|
|
||||||
minutils/compare.mli \
|
|
||||||
minutils/data_encoding.mli \
|
|
||||||
minutils/RPC.mli \
|
|
||||||
|
|
||||||
MINUTILS_LIB_IMPLS := \
|
|
||||||
minutils/mBytes.ml \
|
|
||||||
minutils/hex_encode.ml \
|
|
||||||
minutils/utils.ml \
|
|
||||||
minutils/compare.ml \
|
|
||||||
minutils/data_encoding.ml \
|
|
||||||
minutils/RPC.ml \
|
|
||||||
|
|
||||||
MINUTILS_PACKAGES := \
|
|
||||||
cstruct \
|
|
||||||
lwt \
|
|
||||||
ocplib-json-typed.bson \
|
|
||||||
ocplib-resto.directory \
|
|
||||||
$(COVERAGEPKG) \
|
|
||||||
|
|
||||||
MINUTILS_OBJS := \
|
MINUTILS_OBJS := \
|
||||||
${MINUTILS_LIB_IMPLS:.ml=.cmx} ${MINUTILS_LIB_IMPLS:.ml=.ml.deps} \
|
${MINUTILS_LIB_IMPLS:.ml=.cmx} ${MINUTILS_LIB_IMPLS:.ml=.ml.deps} \
|
||||||
${MINUTILS_LIB_INTFS:.mli=.cmi} ${MINUTILS_LIB_INTFS:.mli=.mli.deps}
|
${MINUTILS_LIB_INTFS:.mli=.cmi} ${MINUTILS_LIB_INTFS:.mli=.mli.deps}
|
||||||
${MINUTILS_OBJS}: PACKAGES=${MINUTILS_PACKAGES}
|
${MINUTILS_OBJS}: PACKAGES=${MINUTILS_PACKAGES}
|
||||||
${MINUTILS_OBJS}: SOURCE_DIRECTORIES=minutils
|
${MINUTILS_OBJS}: SOURCE_DIRECTORIES=${MINUTILS_SOURCE_DIRECTORIES}
|
||||||
${MINUTILS_OBJS}: TARGET="(minutils.cmxa)"
|
${MINUTILS_OBJS}: TARGET="(minutils.cmxa)"
|
||||||
${MINUTILS_OBJS}: OPENED_MODULES=
|
${MINUTILS_OBJS}: OPENED_MODULES=${MINUTILS_OPENED_MODULES}
|
||||||
|
|
||||||
minutils.cmxa: ${MINUTILS_LIB_IMPLS:.ml=.cmx}
|
minutils.cmxa: ${MINUTILS_LIB_IMPLS:.ml=.cmx}
|
||||||
@echo LINK $(notdir $@)
|
@echo LINK $(notdir $@)
|
||||||
@ -194,9 +123,9 @@ minutils.cmxa: ${MINUTILS_LIB_IMPLS:.ml=.cmx}
|
|||||||
MINUTILS_OBJS_BYTECODE := \
|
MINUTILS_OBJS_BYTECODE := \
|
||||||
${MINUTILS_LIB_IMPLS:.ml=.cmo} ${MINUTILS_LIB_IMPLS:.ml=.ml.deps.byte}
|
${MINUTILS_LIB_IMPLS:.ml=.cmo} ${MINUTILS_LIB_IMPLS:.ml=.ml.deps.byte}
|
||||||
${MINUTILS_OBJS_BYTECODE}: PACKAGES=${MINUTILS_PACKAGES}
|
${MINUTILS_OBJS_BYTECODE}: PACKAGES=${MINUTILS_PACKAGES}
|
||||||
${MINUTILS_OBJS_BYTECODE}: SOURCE_DIRECTORIES=minutils
|
${MINUTILS_OBJS_BYTECODE}: SOURCE_DIRECTORIES=${MINUTILS_SOURCE_DIRECTORIES}
|
||||||
${MINUTILS_OBJS_BYTECODE}: TARGET="(minutils.cma)"
|
${MINUTILS_OBJS_BYTECODE}: TARGET="(minutils.cma)"
|
||||||
${MINUTILS_OBJS_BYTECODE}: OPENED_MODULES=
|
${MINUTILS_OBJS_BYTECODE}: OPENED_MODULES=${MINUTILS_OPENED_MODULES}
|
||||||
|
|
||||||
minutils.cma: ${MINUTILS_LIB_IMPLS:.ml=.cmo}
|
minutils.cma: ${MINUTILS_LIB_IMPLS:.ml=.cmo}
|
||||||
@echo LINK $(notdir $@)
|
@echo LINK $(notdir $@)
|
||||||
@ -206,61 +135,13 @@ minutils.cma: ${MINUTILS_LIB_IMPLS:.ml=.cmo}
|
|||||||
## Utils library
|
## Utils library
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
UTILS_LIB_INTFS := \
|
|
||||||
utils/base58.mli \
|
|
||||||
utils/cli_entries.mli \
|
|
||||||
utils/data_encoding_ezjsonm.mli \
|
|
||||||
utils/crypto_box.mli \
|
|
||||||
utils/time.mli \
|
|
||||||
utils/hash.mli \
|
|
||||||
utils/error_monad.mli \
|
|
||||||
utils/lwt_exit.mli \
|
|
||||||
utils/logging.mli \
|
|
||||||
utils/lwt_utils.mli \
|
|
||||||
utils/lwt_pipe.mli \
|
|
||||||
utils/IO.mli \
|
|
||||||
utils/moving_average.mli \
|
|
||||||
utils/ring.mli \
|
|
||||||
utils/watcher.mli \
|
|
||||||
|
|
||||||
UTILS_LIB_IMPLS := \
|
|
||||||
utils/base58.ml \
|
|
||||||
utils/error_monad_sig.ml \
|
|
||||||
utils/error_monad.ml \
|
|
||||||
utils/cli_entries.ml \
|
|
||||||
utils/data_encoding_ezjsonm.ml \
|
|
||||||
utils/time.ml \
|
|
||||||
utils/hash.ml \
|
|
||||||
utils/crypto_box.ml \
|
|
||||||
utils/lwt_exit.ml \
|
|
||||||
utils/logging.ml \
|
|
||||||
utils/lwt_utils.ml \
|
|
||||||
utils/lwt_pipe.ml \
|
|
||||||
utils/IO.ml \
|
|
||||||
utils/moving_average.ml \
|
|
||||||
utils/ring.ml \
|
|
||||||
utils/watcher.ml \
|
|
||||||
|
|
||||||
UTILS_PACKAGES := \
|
|
||||||
${MINUTILS_PACKAGES} \
|
|
||||||
base64 \
|
|
||||||
calendar \
|
|
||||||
ezjsonm \
|
|
||||||
ipaddr.unix \
|
|
||||||
lwt.unix \
|
|
||||||
mtime.os \
|
|
||||||
nocrypto \
|
|
||||||
sodium \
|
|
||||||
zarith \
|
|
||||||
$(COVERAGEPKG) \
|
|
||||||
|
|
||||||
UTILS_OBJS := \
|
UTILS_OBJS := \
|
||||||
${UTILS_LIB_IMPLS:.ml=.cmx} ${UTILS_LIB_IMPLS:.ml=.ml.deps} \
|
${UTILS_LIB_IMPLS:.ml=.cmx} ${UTILS_LIB_IMPLS:.ml=.ml.deps} \
|
||||||
${UTILS_LIB_INTFS:.mli=.cmi} ${UTILS_LIB_INTFS:.mli=.mli.deps}
|
${UTILS_LIB_INTFS:.mli=.cmi} ${UTILS_LIB_INTFS:.mli=.mli.deps}
|
||||||
${UTILS_OBJS}: PACKAGES=${UTILS_PACKAGES}
|
${UTILS_OBJS}: PACKAGES=${UTILS_PACKAGES}
|
||||||
${UTILS_OBJS}: SOURCE_DIRECTORIES=minutils utils
|
${UTILS_OBJS}: SOURCE_DIRECTORIES=${UTILS_SOURCE_DIRECTORIES}
|
||||||
${UTILS_OBJS}: TARGET="(utils.cmxa)"
|
${UTILS_OBJS}: TARGET="(utils.cmxa)"
|
||||||
${UTILS_OBJS}: OPENED_MODULES=
|
${UTILS_OBJS}: OPENED_MODULES=${UTILS_OPENED_MODULES}
|
||||||
|
|
||||||
utils.cmxa: ${UTILS_LIB_IMPLS:.ml=.cmx}
|
utils.cmxa: ${UTILS_LIB_IMPLS:.ml=.cmx}
|
||||||
@echo LINK $(notdir $@)
|
@echo LINK $(notdir $@)
|
||||||
@ -276,35 +157,15 @@ utils.top:
|
|||||||
## Node protocol compiler (also embedded in the main program)
|
## Node protocol compiler (also embedded in the main program)
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
COMPILER_LIB_INTFS := \
|
|
||||||
compiler/tezos_compiler.mli \
|
|
||||||
compiler/embedded_cmis.mli \
|
|
||||||
|
|
||||||
COMPILER_LIB_IMPLS := \
|
|
||||||
compiler/embedded_cmis.ml \
|
|
||||||
compiler/tezos_compiler.ml \
|
|
||||||
|
|
||||||
COMPILER_IMPLS := \
|
|
||||||
compiler_main.ml \
|
|
||||||
|
|
||||||
COMPILER_PACKAGES := \
|
|
||||||
${UTILS_PACKAGES} \
|
|
||||||
compiler-libs.optcomp \
|
|
||||||
lwt.unix \
|
|
||||||
ocplib-endian \
|
|
||||||
ocplib-ocamlres \
|
|
||||||
unix \
|
|
||||||
|
|
||||||
COMPILER_OBJS := \
|
COMPILER_OBJS := \
|
||||||
${COMPILER_IMPLS:.ml=.cmx} ${COMPILER_IMPLS:.ml=.ml.deps} \
|
${COMPILER_IMPLS:.ml=.cmx} ${COMPILER_IMPLS:.ml=.ml.deps} \
|
||||||
${COMPILER_LIB_IMPLS:.ml=.cmx} ${COMPILER_LIB_IMPLS:.ml=.ml.deps} \
|
${COMPILER_LIB_IMPLS:.ml=.cmx} ${COMPILER_LIB_IMPLS:.ml=.ml.deps} \
|
||||||
${COMPILER_LIB_INTFS:.mli=.cmi} ${COMPILER_LIB_INTFS:.mli=.mli.deps} \
|
${COMPILER_LIB_INTFS:.mli=.cmi} ${COMPILER_LIB_INTFS:.mli=.mli.deps} \
|
||||||
${TZCOMPILER}
|
${TZCOMPILER}
|
||||||
${COMPILER_OBJS}: PACKAGES=${COMPILER_PACKAGES}
|
${COMPILER_OBJS}: PACKAGES=${COMPILER_PACKAGES}
|
||||||
${COMPILER_OBJS}: SOURCE_DIRECTORIES=utils minutils compiler
|
${COMPILER_OBJS}: SOURCE_DIRECTORIES=${COMPILER_SOURCE_DIRECTORIES}
|
||||||
${COMPILER_OBJS}: TARGET="(compiler.cmxa)"
|
${COMPILER_OBJS}: TARGET="(compiler.cmxa)"
|
||||||
${COMPILER_OBJS}: \
|
${COMPILER_OBJS}: OPENED_MODULES=${COMPILER_OPENED_MODULES}
|
||||||
OPENED_MODULES=Error_monad Hash Utils
|
|
||||||
|
|
||||||
compiler.cmxa: ${COMPILER_LIB_IMPLS:.ml=.cmx}
|
compiler.cmxa: ${COMPILER_LIB_IMPLS:.ml=.cmx}
|
||||||
@echo LINK $(notdir $@)
|
@echo LINK $(notdir $@)
|
||||||
@ -317,134 +178,10 @@ ${TZCOMPILER}: minutils.cmxa utils.cmxa compiler.cmxa ${COMPILER_IMPLS:.ml=.cmx}
|
|||||||
clean::
|
clean::
|
||||||
rm -f ${TZCOMPILER}
|
rm -f ${TZCOMPILER}
|
||||||
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
## Node program
|
## Node program
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
NODE_LIB_INTFS := \
|
|
||||||
\
|
|
||||||
node/net/p2p_types.mli \
|
|
||||||
node/net/p2p_io_scheduler.mli \
|
|
||||||
node/net/p2p_connection.mli \
|
|
||||||
node/net/p2p_connection_pool_types.mli \
|
|
||||||
node/net/p2p_connection_pool.mli \
|
|
||||||
node/net/p2p_welcome.mli \
|
|
||||||
node/net/p2p_discovery.mli \
|
|
||||||
node/net/p2p_maintenance.mli \
|
|
||||||
node/net/p2p.mli \
|
|
||||||
node/net/RPC_server.mli \
|
|
||||||
\
|
|
||||||
node/updater/fitness.mli \
|
|
||||||
\
|
|
||||||
node/db/store_sigs.mli \
|
|
||||||
node/db/raw_store.mli \
|
|
||||||
node/db/store_sigs.mli \
|
|
||||||
node/db/store_helpers.mli \
|
|
||||||
node/db/store.mli \
|
|
||||||
\
|
|
||||||
node/db/ir_funview.mli \
|
|
||||||
node/db/persist.mli \
|
|
||||||
node/db/context.mli \
|
|
||||||
\
|
|
||||||
node/updater/protocol.mli \
|
|
||||||
node/updater/updater.mli \
|
|
||||||
node/updater/proto_environment.mli \
|
|
||||||
node/updater/register.mli \
|
|
||||||
\
|
|
||||||
node/shell/state.mli \
|
|
||||||
node/shell/distributed_db_functors.mli \
|
|
||||||
node/shell/distributed_db_message.mli \
|
|
||||||
node/shell/distributed_db_metadata.mli \
|
|
||||||
node/shell/distributed_db.mli \
|
|
||||||
node/shell/prevalidator.mli \
|
|
||||||
node/shell/validator.mli \
|
|
||||||
\
|
|
||||||
node/shell/node_rpc_services.mli \
|
|
||||||
node/shell/node.mli \
|
|
||||||
node/shell/node_rpc.mli \
|
|
||||||
|
|
||||||
FULL_NODE_LIB_IMPLS := \
|
|
||||||
\
|
|
||||||
compiler/node_compiler_main.ml \
|
|
||||||
\
|
|
||||||
node/net/p2p_types.ml \
|
|
||||||
node/net/p2p_io_scheduler.ml \
|
|
||||||
node/net/p2p_connection.ml \
|
|
||||||
node/net/p2p_connection_pool_types.ml \
|
|
||||||
node/net/p2p_connection_pool.ml \
|
|
||||||
node/net/p2p_welcome.ml \
|
|
||||||
node/net/p2p_discovery.ml \
|
|
||||||
node/net/p2p_maintenance.ml \
|
|
||||||
node/net/p2p.ml \
|
|
||||||
\
|
|
||||||
node/net/RPC_server.ml \
|
|
||||||
\
|
|
||||||
node/updater/fitness.ml \
|
|
||||||
\
|
|
||||||
node/db/raw_store.ml \
|
|
||||||
node/db/store_sigs.mli \
|
|
||||||
node/db/store_helpers.ml \
|
|
||||||
node/db/store.ml \
|
|
||||||
\
|
|
||||||
node/db/ir_funview.ml \
|
|
||||||
node/db/persist.ml \
|
|
||||||
node/db/context.ml \
|
|
||||||
\
|
|
||||||
node/updater/protocol.mli \
|
|
||||||
node/updater/updater.ml \
|
|
||||||
node/updater/environment.ml \
|
|
||||||
node/updater/proto_environment.ml \
|
|
||||||
node/updater/register.ml \
|
|
||||||
\
|
|
||||||
node/shell/state.ml \
|
|
||||||
node/shell/distributed_db_functors.ml \
|
|
||||||
node/shell/distributed_db_message.ml \
|
|
||||||
node/shell/distributed_db_metadata.ml \
|
|
||||||
node/shell/distributed_db.ml \
|
|
||||||
node/shell/prevalidator.ml \
|
|
||||||
node/shell/validator.ml \
|
|
||||||
\
|
|
||||||
node/shell/node_rpc_services.ml \
|
|
||||||
node/shell/node.ml \
|
|
||||||
node/shell/node_rpc.ml \
|
|
||||||
|
|
||||||
NODE_LIB_IMPLS := $(filter-out ${NODE_LIB_INTFS}, ${FULL_NODE_LIB_IMPLS})
|
|
||||||
|
|
||||||
NODE_INTFS := \
|
|
||||||
node/main/node_identity_file.mli \
|
|
||||||
node/main/node_config_file.mli \
|
|
||||||
node/main/node_shared_arg.mli \
|
|
||||||
node/main/node_run_command.mli \
|
|
||||||
node/main/node_config_command.mli \
|
|
||||||
node/main/node_identity_command.mli \
|
|
||||||
|
|
||||||
NODE_IMPLS := \
|
|
||||||
node/main/node_identity_file.ml \
|
|
||||||
node/main/node_config_file.ml \
|
|
||||||
node/main/node_shared_arg.ml \
|
|
||||||
node/main/node_run_command.ml \
|
|
||||||
node/main/node_config_command.ml \
|
|
||||||
node/main/node_identity_command.ml \
|
|
||||||
node_main.ml \
|
|
||||||
|
|
||||||
NODE_PACKAGES := \
|
|
||||||
$(COMPILER_PACKAGES) \
|
|
||||||
calendar \
|
|
||||||
cmdliner \
|
|
||||||
cohttp.lwt \
|
|
||||||
dynlink \
|
|
||||||
git \
|
|
||||||
ipv6-multicast \
|
|
||||||
irmin.unix \
|
|
||||||
ocplib-resto.directory \
|
|
||||||
|
|
||||||
|
|
||||||
EMBEDDED_NODE_PROTOCOLS := \
|
|
||||||
$(patsubst proto/%/,proto/embedded_proto_%.cmxa, \
|
|
||||||
$(filter-out proto/environment/, \
|
|
||||||
$(subst TEZOS_PROTOCOL,,$(shell ls proto/*/TEZOS_PROTOCOL))))
|
|
||||||
|
|
||||||
NODE_OBJS := \
|
NODE_OBJS := \
|
||||||
${NODE_IMPLS:.ml=.cmx} ${NODE_IMPLS:.ml=.ml.deps} \
|
${NODE_IMPLS:.ml=.cmx} ${NODE_IMPLS:.ml=.ml.deps} \
|
||||||
${NODE_INTFS:.mli=.cmi} ${NODE_INTFS:.mli=.mli.deps} \
|
${NODE_INTFS:.mli=.cmi} ${NODE_INTFS:.mli=.mli.deps} \
|
||||||
@ -452,9 +189,9 @@ NODE_OBJS := \
|
|||||||
${NODE_LIB_INTFS:.mli=.cmi} ${NODE_LIB_INTFS:.mli=.mli.deps} \
|
${NODE_LIB_INTFS:.mli=.cmi} ${NODE_LIB_INTFS:.mli=.mli.deps} \
|
||||||
${TZNODE}
|
${TZNODE}
|
||||||
${NODE_OBJS}: PACKAGES=${NODE_PACKAGES}
|
${NODE_OBJS}: PACKAGES=${NODE_PACKAGES}
|
||||||
${NODE_OBJS}: SOURCE_DIRECTORIES=minutils utils compiler node/db node/net node/updater node/shell node/main
|
${NODE_OBJS}: SOURCE_DIRECTORIES=${NODE_SOURCE_DIRECTORIES}
|
||||||
${NODE_OBJS}: TARGET="(node.cmxa)"
|
${NODE_OBJS}: TARGET="(node.cmxa)"
|
||||||
${NODE_OBJS}: OPENED_MODULES=Error_monad Hash Utils
|
${NODE_OBJS}: OPENED_MODULES=${NODE_OPENED_MODULES}
|
||||||
|
|
||||||
node/updater/environment.cmi: node/updater/environment.cmx
|
node/updater/environment.cmi: node/updater/environment.cmx
|
||||||
|
|
||||||
@ -462,7 +199,7 @@ node.cmxa: ${NODE_LIB_IMPLS:.ml=.cmx}
|
|||||||
@echo LINK $(notdir $@)
|
@echo LINK $(notdir $@)
|
||||||
@${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ $^
|
@${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ $^
|
||||||
|
|
||||||
${NODE_IMPLS:.ml=.cmx}: ${EMBEDDED_CLIENT_PROTOCOLS}
|
${NODE_IMPLS:.ml=.cmx}: ${EMBEDDED_NODE_PROTOCOLS}
|
||||||
${TZNODE}: minutils.cmxa utils.cmxa compiler.cmxa node.cmxa ${EMBEDDED_NODE_PROTOCOLS} ${NODE_IMPLS:.ml=.cmx}
|
${TZNODE}: minutils.cmxa utils.cmxa compiler.cmxa node.cmxa ${EMBEDDED_NODE_PROTOCOLS} ${NODE_IMPLS:.ml=.cmx}
|
||||||
@echo LINK $(notdir $@)
|
@echo LINK $(notdir $@)
|
||||||
@${OCAMLOPT} -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
@${OCAMLOPT} -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
||||||
@ -485,96 +222,25 @@ clean::
|
|||||||
## Client program
|
## Client program
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
CLIENT_LIB_INTFS := \
|
|
||||||
client/client_rpcs.mli \
|
|
||||||
client/client_node_rpcs.mli \
|
|
||||||
client/client_commands.mli \
|
|
||||||
client/client_generic_rpcs.mli \
|
|
||||||
client/client_helpers.mli \
|
|
||||||
client/client_aliases.mli \
|
|
||||||
client/client_tags.mli \
|
|
||||||
client/client_keys.mli \
|
|
||||||
client/client_protocols.mli \
|
|
||||||
client/client_blocks.mli \
|
|
||||||
client/client_network.mli \
|
|
||||||
|
|
||||||
CLIENT_LIB_IMPLS := \
|
|
||||||
client/client_rpcs.ml \
|
|
||||||
client/client_node_rpcs.ml \
|
|
||||||
client/client_commands.ml \
|
|
||||||
client/client_config.ml \
|
|
||||||
client/client_generic_rpcs.ml \
|
|
||||||
client/client_helpers.ml \
|
|
||||||
client/client_aliases.ml \
|
|
||||||
client/client_tags.ml \
|
|
||||||
client/client_keys.ml \
|
|
||||||
client/client_protocols.ml \
|
|
||||||
client/client_blocks.ml \
|
|
||||||
client/client_network.ml \
|
|
||||||
|
|
||||||
WEBCLIENT_LIB_INTFS := \
|
|
||||||
|
|
||||||
WEBCLIENT_LIB_IMPLS := \
|
|
||||||
client/webclient_version.ml \
|
|
||||||
|
|
||||||
CLIENT_IMPLS := \
|
|
||||||
client_main.ml
|
|
||||||
|
|
||||||
WEBCLIENT_IMPLS := \
|
|
||||||
webclient_static.ml \
|
|
||||||
webclient_main.ml
|
|
||||||
|
|
||||||
CLIENT_PACKAGES := \
|
|
||||||
${NODE_PACKAGES} \
|
|
||||||
magic-mime \
|
|
||||||
|
|
||||||
EMBEDDED_CLIENT_PROTOCOLS := \
|
|
||||||
$(patsubst client/embedded/%/, \
|
|
||||||
proto/client_embedded_proto_%.cmxa, \
|
|
||||||
$(shell ls -d client/embedded/*/))
|
|
||||||
|
|
||||||
EMBEDDED_CLIENT_VERSIONS := \
|
|
||||||
$(patsubst client/embedded/%/, \
|
|
||||||
client/embedded/client_%.cmx, \
|
|
||||||
$(shell ls -d client/embedded/*/))
|
|
||||||
|
|
||||||
EMBEDDED_WEBCLIENT_VERSIONS := \
|
|
||||||
$(patsubst client/embedded/%/, \
|
|
||||||
client/embedded/webclient_%.cmx, \
|
|
||||||
$(shell ls -d client/embedded/*/))
|
|
||||||
|
|
||||||
CLIENT_OBJS := \
|
CLIENT_OBJS := \
|
||||||
${CLIENT_IMPLS:.ml=.cmx} ${CLIENT_IMPLS:.ml=.ml.deps} \
|
${CLIENT_IMPLS:.ml=.cmx} ${CLIENT_IMPLS:.ml=.ml.deps} \
|
||||||
${WEBCLIENT_IMPLS:.ml=.cmx} ${WEBCLIENT_IMPLS:.ml=.ml.deps} \
|
|
||||||
${CLIENT_LIB_IMPLS:.ml=.cmx} ${CLIENT_LIB_IMPLS:.ml=.ml.deps} \
|
${CLIENT_LIB_IMPLS:.ml=.cmx} ${CLIENT_LIB_IMPLS:.ml=.ml.deps} \
|
||||||
${CLIENT_LIB_INTFS:.mli=.cmi} ${CLIENT_LIB_INTFS:.mli=.mli.deps} \
|
${CLIENT_LIB_INTFS:.mli=.cmi} ${CLIENT_LIB_INTFS:.mli=.mli.deps} \
|
||||||
${WEBCLIENT_LIB_IMPLS:.ml=.cmx} ${WEBCLIENT_LIB_IMPLS:.ml=.ml.deps} \
|
${TZCLIENT}
|
||||||
${WEBCLIENT_LIB_INTFS:.mli=.cmi} ${WEBCLIENT_LIB_INTFS:.mli=.mli.deps} \
|
|
||||||
${TZCLIENT} \
|
|
||||||
${TZWEBCLIENT}
|
|
||||||
${CLIENT_OBJS}: PACKAGES=${CLIENT_PACKAGES}
|
${CLIENT_OBJS}: PACKAGES=${CLIENT_PACKAGES}
|
||||||
${CLIENT_OBJS}: SOURCE_DIRECTORIES=client client/embedded minutils utils node/net node/shell node/updater node/db compiler
|
${CLIENT_OBJS}: SOURCE_DIRECTORIES=${CLIENT_SOURCE_DIRECTORIES}
|
||||||
${CLIENT_OBJS}: OPENED_MODULES=Error_monad Hash Utils
|
${CLIENT_OBJS}: OPENED_MODULES=${CLIENT_OPENED_MODULES}
|
||||||
|
|
||||||
${CLIENT_LIB_IMPLS:.ml=.cmx} ${CLIENT_LIB_IMPLS:.ml=.ml.deps}: TARGET="(client.cmxa)"
|
${CLIENT_LIB_IMPLS:.ml=.cmx} ${CLIENT_LIB_IMPLS:.ml=.ml.deps}: TARGET="(client.cmxa)"
|
||||||
${CLIENT_LIB_INTFS:.mli=.cmi} ${CLIENT_LIB_INTFS:.mli=.mli.deps}: TARGET="(client.cmxa)"
|
${CLIENT_LIB_INTFS:.mli=.cmi} ${CLIENT_LIB_INTFS:.mli=.mli.deps}: TARGET="(client.cmxa)"
|
||||||
${WEBCLIENT_LIB_IMPLS:.ml=.cmx} ${WEBCLIENT_LIB_IMPLS:.ml=.ml.deps}: TARGET="(webclient.cmxa)"
|
|
||||||
${WEBCLIENT_LIB_INTFS:.mli=.cmi} ${WEBCLIENT_LIB_INTFS:.mli=.mli.deps}: TARGET="(webclient.cmxa)"
|
|
||||||
|
|
||||||
client.cmxa: ${CLIENT_LIB_IMPLS:.ml=.cmx}
|
client.cmxa: ${CLIENT_LIB_IMPLS:.ml=.cmx}
|
||||||
@echo LINK $(notdir $@)
|
@echo LINK $(notdir $@)
|
||||||
@${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ $^
|
@${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ $^
|
||||||
|
|
||||||
webclient.cmxa: ${WEBCLIENT_LIB_IMPLS:.ml=.cmx} client.cmxa
|
${EMBEDDED_CLIENT_VERSIONS}: client.cmxa ${EMBEDDED_CLIENT_PROTOCOLS}
|
||||||
@echo LINK $(notdir $@)
|
|
||||||
${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ ${WEBCLIENT_LIB_IMPLS:.ml=.cmx}
|
|
||||||
|
|
||||||
${EMBEDDED_CLIENT_VERSIONS}: client.cmxa
|
|
||||||
${CLIENT_IMPLS:.ml=.cmx}: ${EMBEDDED_CLIENT_VERSIONS}
|
${CLIENT_IMPLS:.ml=.cmx}: ${EMBEDDED_CLIENT_VERSIONS}
|
||||||
|
|
||||||
${EMBEDDED_WEBCLIENT_VERSIONS}: webclient.cmxa
|
|
||||||
${WEBCLIENT_IMPLS:.ml=.cmx}: ${EMBEDDED_CLIENT_VERSIONS} ${EMBEDDED_WEBCLIENT_VERSIONS}
|
|
||||||
|
|
||||||
${TZCLIENT}: minutils.cmxa utils.cmxa compiler.cmxa node.cmxa \
|
${TZCLIENT}: minutils.cmxa utils.cmxa compiler.cmxa node.cmxa \
|
||||||
client.cmxa \
|
client.cmxa \
|
||||||
${EMBEDDED_CLIENT_PROTOCOLS} \
|
${EMBEDDED_CLIENT_PROTOCOLS} \
|
||||||
@ -583,6 +249,32 @@ ${TZCLIENT}: minutils.cmxa utils.cmxa compiler.cmxa node.cmxa \
|
|||||||
@echo LINK $(notdir $@)
|
@echo LINK $(notdir $@)
|
||||||
@${OCAMLOPT} -linkpkg ${OCAMLFLAGS} -o $@ $^
|
@${OCAMLOPT} -linkpkg ${OCAMLFLAGS} -o $@ $^
|
||||||
|
|
||||||
|
clean::
|
||||||
|
-rm -f ${TZCLIENT}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## Webclient program
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
WEBCLIENT_OBJS := \
|
||||||
|
${WEBCLIENT_IMPLS:.ml=.cmx} ${WEBCLIENT_IMPLS:.ml=.ml.deps} \
|
||||||
|
${WEBCLIENT_LIB_IMPLS:.ml=.cmx} ${WEBCLIENT_LIB_IMPLS:.ml=.ml.deps} \
|
||||||
|
${WEBCLIENT_LIB_INTFS:.mli=.cmi} ${WEBCLIENT_LIB_INTFS:.mli=.mli.deps} \
|
||||||
|
${TZWEBCLIENT}
|
||||||
|
${WEBCLIENT_OBJS}: PACKAGES=${WEBCLIENT_PACKAGES}
|
||||||
|
${WEBCLIENT_OBJS}: SOURCE_DIRECTORIES=${WEBCLIENT_SOURCE_DIRECTORIES}
|
||||||
|
${WEBCLIENT_OBJS}: OPENED_MODULES=${WEBCLIENT_OPENED_MODULES}
|
||||||
|
|
||||||
|
${WEBCLIENT_LIB_IMPLS:.ml=.cmx} ${WEBCLIENT_LIB_IMPLS:.ml=.ml.deps}: TARGET="(webclient.cmxa)"
|
||||||
|
${WEBCLIENT_LIB_INTFS:.mli=.cmi} ${WEBCLIENT_LIB_INTFS:.mli=.mli.deps}: TARGET="(webclient.cmxa)"
|
||||||
|
|
||||||
|
${EMBEDDED_WEBCLIENT_VERSIONS}: webclient.cmxa
|
||||||
|
${WEBCLIENT_IMPLS:.ml=.cmx}: ${EMBEDDED_CLIENT_VERSIONS} ${EMBEDDED_WEBCLIENT_VERSIONS}
|
||||||
|
|
||||||
|
webclient.cmxa: ${WEBCLIENT_LIB_IMPLS:.ml=.cmx} client.cmxa
|
||||||
|
@echo LINK $(notdir $@)
|
||||||
|
${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ ${WEBCLIENT_LIB_IMPLS:.ml=.cmx}
|
||||||
|
|
||||||
${TZWEBCLIENT}: minutils.cmxa utils.cmxa compiler.cmxa node.cmxa \
|
${TZWEBCLIENT}: minutils.cmxa utils.cmxa compiler.cmxa node.cmxa \
|
||||||
client.cmxa webclient.cmxa \
|
client.cmxa webclient.cmxa \
|
||||||
${EMBEDDED_CLIENT_PROTOCOLS} \
|
${EMBEDDED_CLIENT_PROTOCOLS} \
|
||||||
@ -592,81 +284,14 @@ ${TZWEBCLIENT}: minutils.cmxa utils.cmxa compiler.cmxa node.cmxa \
|
|||||||
@echo LINK $(notdir $@)
|
@echo LINK $(notdir $@)
|
||||||
@${OCAMLOPT} -linkpkg ${OCAMLFLAGS} -o $@ $^
|
@${OCAMLOPT} -linkpkg ${OCAMLFLAGS} -o $@ $^
|
||||||
|
|
||||||
|
clean::
|
||||||
|
-rm -f ${TZCLIENT}
|
||||||
|
|
||||||
webclient_static.ml: $(shell find webclient_static/)
|
webclient_static.ml: $(shell find webclient_static/)
|
||||||
ocp-ocamlres webclient_static -o $@
|
ocp-ocamlres webclient_static -o $@
|
||||||
|
|
||||||
clean::
|
|
||||||
-rm -f ${TZCLIENT} $(TZWEBCLIENT)
|
|
||||||
-rm -f webclient_static.ml
|
|
||||||
|
|
||||||
## Embedded client protocol modules
|
|
||||||
|
|
||||||
.SECONDEXPANSION:
|
|
||||||
|
|
||||||
client/embedded/client_%.cmx: \
|
|
||||||
$(patsubst %.ml, %.cmx, $(NODE_LIB_IMPLS) $(CLIENT_LIB_IMPLS)) \
|
|
||||||
proto/client_embedded_proto_%.cmxa \
|
|
||||||
$$(shell find client/embedded/% -name webclient -prune -name \*.ml -or -name \*.mli)
|
|
||||||
@$(MAKE) -C client/embedded/$* ../client_$*.cmx
|
|
||||||
|
|
||||||
client/embedded/webclient_%.cmx: \
|
|
||||||
client/embedded/client_%.cmx \
|
|
||||||
minutils.cma \
|
|
||||||
$$(shell find client/embedded/%/webclient -name \*.ml -or -name \*.mli 2>/dev/null) \
|
|
||||||
$$(shell find client/embedded/%/webclient/static/ 2>/dev/null)
|
|
||||||
@$(MAKE) -C client/embedded/$* ../webclient_$*.cmx
|
|
||||||
|
|
||||||
partial-clean::
|
partial-clean::
|
||||||
-for d in $$(ls -d client/embedded/*/) ; do make clean -C $$d ; done
|
-rm -f webclient_static.ml
|
||||||
-rm -f client/embedded/*.cm* client/embedded/*.o
|
|
||||||
|
|
||||||
|
|
||||||
############################################################################
|
|
||||||
## Attacker program
|
|
||||||
############################################################################
|
|
||||||
|
|
||||||
ATTACKER_LIB_INTFS := \
|
|
||||||
attacker/attacker_minimal.mli \
|
|
||||||
|
|
||||||
ATTACKER_LIB_IMPLS := \
|
|
||||||
attacker/attacker_minimal.ml \
|
|
||||||
|
|
||||||
ATTACKER_IMPLS := \
|
|
||||||
attacker_main.ml
|
|
||||||
|
|
||||||
ATTACKER_PACKAGES := \
|
|
||||||
${NODE_PACKAGES}
|
|
||||||
|
|
||||||
EMBEDDED_ATTACKER_PROTOCOLS := \
|
|
||||||
$(patsubst client/embedded/%/, \
|
|
||||||
proto/client_embedded_proto_%.cmxa, \
|
|
||||||
$(shell ls -d client/embedded/*/))
|
|
||||||
|
|
||||||
ATTACKER_OBJS := \
|
|
||||||
${ATTACKER_IMPLS:.ml=.cmx} ${ATTACKER_IMPLS:.ml=.ml.deps} \
|
|
||||||
${ATTACKER_LIB_IMPLS:.ml=.cmx} ${ATTACKER_LIB_IMPLS:.ml=.ml.deps} \
|
|
||||||
${ATTACKER_LIB_INTFS:.mli=.cmi} ${ATTACKER_LIB_INTFS:.mli=.mli.deps} \
|
|
||||||
${TZATTACKER}
|
|
||||||
${ATTACKER_OBJS}: PACKAGES=${ATTACKER_PACKAGES}
|
|
||||||
${ATTACKER_OBJS}: SOURCE_DIRECTORIES=attacker proto client/embedded minutils utils node/net node/shell node/updater node/db compiler
|
|
||||||
${ATTACKER_OBJS}: TARGET="(attacker.cmxa)"
|
|
||||||
${ATTACKER_OBJS}: OPENED_MODULES=Error_monad Hash Utils
|
|
||||||
|
|
||||||
attacker.cmxa: ${ATTACKER_LIB_IMPLS:.ml=.cmx}
|
|
||||||
@echo LINK $(notdir $@)
|
|
||||||
@${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ $^
|
|
||||||
|
|
||||||
${ATTACKER_LIB_IMPLS:.ml=.cmx} ${ATTACKER_IMPLS:.ml=.cmx}: \
|
|
||||||
${EMBEDDED_ATTACKER_PROTOCOLS}
|
|
||||||
|
|
||||||
${TZATTACKER}: minutils.cmxa utils.cmxa compiler.cmxa node.cmxa \
|
|
||||||
${EMBEDDED_ATTACKER_PROTOCOLS} attacker.cmxa \
|
|
||||||
${ATTACKER_IMPLS:.ml=.cmx}
|
|
||||||
@echo LINK $(notdir $@)
|
|
||||||
@${OCAMLOPT} -linkpkg ${OCAMLFLAGS} -o $@ $^
|
|
||||||
|
|
||||||
clean::
|
|
||||||
-rm -f ${TZATTACKER}
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
## Generic rules
|
## Generic rules
|
||||||
@ -765,6 +390,8 @@ proto/client_embedded_proto_%.cmxa: \
|
|||||||
${TZCOMPILER} \
|
${TZCOMPILER} \
|
||||||
node/updater/environment.cmi \
|
node/updater/environment.cmi \
|
||||||
node/updater/environment.cmx \
|
node/updater/environment.cmx \
|
||||||
|
node/updater/proto_environment.cmi \
|
||||||
|
node/updater/proto_environment.cmx \
|
||||||
proto/%/TEZOS_PROTOCOL \
|
proto/%/TEZOS_PROTOCOL \
|
||||||
$$(wildcard proto/%/*.ml) \
|
$$(wildcard proto/%/*.ml) \
|
||||||
$$(wildcard proto/%/*.mli)
|
$$(wildcard proto/%/*.mli)
|
||||||
@ -773,11 +400,29 @@ proto/client_embedded_proto_%.cmxa: \
|
|||||||
$(addprefix -I , ${CLIENT_PROTO_INCLUDES}) \
|
$(addprefix -I , ${CLIENT_PROTO_INCLUDES}) \
|
||||||
$@ proto/$*
|
$@ proto/$*
|
||||||
|
|
||||||
proto/client_embedded_proto_genesis.cmxa: proto/client_embedded_proto_alpha.cmxa
|
partial-clean::
|
||||||
|
|
||||||
clean::
|
|
||||||
-rm -rf $(patsubst proto/embedded_proto_%.cmxa,proto/%/_tzbuild, \
|
-rm -rf $(patsubst proto/embedded_proto_%.cmxa,proto/%/_tzbuild, \
|
||||||
${EMBEDDED_NODE_PROTOCOLS})
|
${EMBEDDED_NODE_PROTOCOLS})
|
||||||
-rm -f $(patsubst proto/client_embedded_proto_%.cmxa, \
|
-rm -f $(patsubst proto/client_embedded_proto_%.cmxa, \
|
||||||
proto/register_client_embedded_proto_%.ml, \
|
proto/register_client_embedded_proto_%.ml, \
|
||||||
${EMBEDDED_CLIENT_PROTOCOLS})
|
${EMBEDDED_CLIENT_PROTOCOLS})
|
||||||
|
|
||||||
|
## Embedded client protocol modules
|
||||||
|
|
||||||
|
client/embedded/client_%.cmx: \
|
||||||
|
$(patsubst %.ml, %.cmx, $(NODE_LIB_IMPLS) $(CLIENT_LIB_IMPLS)) \
|
||||||
|
proto/client_embedded_proto_%.cmxa \
|
||||||
|
$$(shell find client/embedded/% \( -name webclient -or -name _tzbuild \) -prune -or \( -name \*.ml -print -or -name \*.mli -print \))
|
||||||
|
@echo $^
|
||||||
|
@$(MAKE) -C client/embedded/$* ../client_$*.cmx
|
||||||
|
|
||||||
|
client/embedded/webclient_%.cmx: \
|
||||||
|
client/embedded/client_%.cmx \
|
||||||
|
minutils.cma \
|
||||||
|
$$(shell find client/embedded/%/webclient -name \*.ml -or -name \*.mli 2>/dev/null) \
|
||||||
|
$$(shell find client/embedded/%/webclient/static/ 2>/dev/null)
|
||||||
|
@$(MAKE) -C client/embedded/$* ../webclient_$*.cmx
|
||||||
|
|
||||||
|
partial-clean::
|
||||||
|
-for d in $$(ls -d client/embedded/*/) ; do make clean -C $$d ; done
|
||||||
|
-rm -f client/embedded/*.cm* client/embedded/*.o
|
||||||
|
398
src/Makefile.files
Normal file
398
src/Makefile.files
Normal file
@ -0,0 +1,398 @@
|
|||||||
|
|
||||||
|
SRCDIR ?= .
|
||||||
|
|
||||||
|
PROTOCOL_ENV_INTFS := \
|
||||||
|
$(addprefix proto/environment/, \
|
||||||
|
pervasives.mli \
|
||||||
|
compare.mli \
|
||||||
|
\
|
||||||
|
array.mli list.mli bytes.mli string.mli \
|
||||||
|
set.mli map.mli \
|
||||||
|
int32.mli int64.mli \
|
||||||
|
buffer.mli \
|
||||||
|
format.mli \
|
||||||
|
\
|
||||||
|
lwt_sequence.mli lwt.mli lwt_list.mli \
|
||||||
|
\
|
||||||
|
mBytes.mli \
|
||||||
|
hex_encode.mli \
|
||||||
|
\
|
||||||
|
uri.mli \
|
||||||
|
data_encoding.mli \
|
||||||
|
error_monad.mli \
|
||||||
|
logging.mli \
|
||||||
|
time.mli \
|
||||||
|
base58.mli \
|
||||||
|
hash.mli \
|
||||||
|
ed25519.mli \
|
||||||
|
persist.mli \
|
||||||
|
fitness.mli \
|
||||||
|
context.mli \
|
||||||
|
RPC.mli \
|
||||||
|
\
|
||||||
|
updater.mli \
|
||||||
|
)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## Minimal utils library compatible with js_of_ocaml
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
MINUTILS_SOURCE_DIRECTORIES := \
|
||||||
|
${SRCDIR}/minutils
|
||||||
|
|
||||||
|
MINUTILS_OPENED_MODULES :=
|
||||||
|
|
||||||
|
MINUTILS_LIB_INTFS := \
|
||||||
|
minutils/mBytes.mli \
|
||||||
|
minutils/hex_encode.mli \
|
||||||
|
minutils/utils.mli \
|
||||||
|
minutils/compare.mli \
|
||||||
|
minutils/data_encoding.mli \
|
||||||
|
minutils/RPC.mli \
|
||||||
|
|
||||||
|
MINUTILS_LIB_IMPLS := \
|
||||||
|
minutils/mBytes.ml \
|
||||||
|
minutils/hex_encode.ml \
|
||||||
|
minutils/utils.ml \
|
||||||
|
minutils/compare.ml \
|
||||||
|
minutils/data_encoding.ml \
|
||||||
|
minutils/RPC.ml \
|
||||||
|
|
||||||
|
MINUTILS_PACKAGES := \
|
||||||
|
cstruct \
|
||||||
|
lwt \
|
||||||
|
ocplib-json-typed.bson \
|
||||||
|
ocplib-resto.directory \
|
||||||
|
$(COVERAGEPKG) \
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## Utils library
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
UTILS_SOURCE_DIRECTORIES := \
|
||||||
|
${MINUTILS_SOURCE_DIRECTORIES} \
|
||||||
|
${SRCDIR}/utils
|
||||||
|
|
||||||
|
UTILS_OPENED_MODULES :=
|
||||||
|
|
||||||
|
UTILS_LIB_INTFS := \
|
||||||
|
utils/base58.mli \
|
||||||
|
utils/cli_entries.mli \
|
||||||
|
utils/data_encoding_ezjsonm.mli \
|
||||||
|
utils/crypto_box.mli \
|
||||||
|
utils/time.mli \
|
||||||
|
utils/hash.mli \
|
||||||
|
utils/error_monad.mli \
|
||||||
|
utils/lwt_exit.mli \
|
||||||
|
utils/logging.mli \
|
||||||
|
utils/lwt_utils.mli \
|
||||||
|
utils/lwt_pipe.mli \
|
||||||
|
utils/IO.mli \
|
||||||
|
utils/moving_average.mli \
|
||||||
|
utils/ring.mli \
|
||||||
|
utils/watcher.mli \
|
||||||
|
|
||||||
|
UTILS_LIB_IMPLS := \
|
||||||
|
utils/base58.ml \
|
||||||
|
utils/error_monad_sig.ml \
|
||||||
|
utils/error_monad.ml \
|
||||||
|
utils/cli_entries.ml \
|
||||||
|
utils/data_encoding_ezjsonm.ml \
|
||||||
|
utils/time.ml \
|
||||||
|
utils/hash.ml \
|
||||||
|
utils/crypto_box.ml \
|
||||||
|
utils/lwt_exit.ml \
|
||||||
|
utils/logging.ml \
|
||||||
|
utils/lwt_utils.ml \
|
||||||
|
utils/lwt_pipe.ml \
|
||||||
|
utils/IO.ml \
|
||||||
|
utils/moving_average.ml \
|
||||||
|
utils/ring.ml \
|
||||||
|
utils/watcher.ml \
|
||||||
|
|
||||||
|
UTILS_PACKAGES := \
|
||||||
|
${MINUTILS_PACKAGES} \
|
||||||
|
base64 \
|
||||||
|
calendar \
|
||||||
|
ezjsonm \
|
||||||
|
ipaddr.unix \
|
||||||
|
lwt.unix \
|
||||||
|
mtime.os \
|
||||||
|
nocrypto \
|
||||||
|
sodium \
|
||||||
|
zarith \
|
||||||
|
$(COVERAGEPKG) \
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## Node protocol compiler (also embedded in the main program)
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
COMPILER_SOURCE_DIRECTORIES := \
|
||||||
|
${UTILS_SOURCE_DIRECTORIES} \
|
||||||
|
${SRCDIR}/compiler
|
||||||
|
|
||||||
|
COMPILER_OPENED_MODULES := Error_monad Hash Utils
|
||||||
|
|
||||||
|
COMPILER_EMBEDDED_CMIS := \
|
||||||
|
compiler/sigs/camlinternalFormatBasics.cmi \
|
||||||
|
compiler/sigs/proto_environment.cmi \
|
||||||
|
compiler/sigs/register.cmi
|
||||||
|
|
||||||
|
COMPILER_PRECOMPILED_INTFS := \
|
||||||
|
compiler/sigs/tezos_compiler.mli \
|
||||||
|
compiler/sigs/fitness.mli \
|
||||||
|
compiler/sigs/persist.mli \
|
||||||
|
compiler/sigs/store_sigs.mli \
|
||||||
|
compiler/sigs/store.mli \
|
||||||
|
compiler/sigs/context.mli \
|
||||||
|
compiler/sigs/protocol.mli \
|
||||||
|
compiler/sigs/proto_environment.mli \
|
||||||
|
compiler/sigs/register.mli
|
||||||
|
|
||||||
|
COMPILER_PRECOMPILED_PACKAGES := \
|
||||||
|
${MINUTILS_PACKAGES} ${UTILS_PACKAGES}
|
||||||
|
|
||||||
|
COMPILER_PRECOMPILED_SOURCE_DIRECTORIES := \
|
||||||
|
${UTILS_SOURCE_DIRECTORIES} compiler/sigs/
|
||||||
|
|
||||||
|
COMPILER_PRECOMPILED_OPENED_MODULES := Error_monad Hash Utils
|
||||||
|
|
||||||
|
COMPILER_LIB_INTFS := \
|
||||||
|
compiler/tezos_compiler.mli \
|
||||||
|
compiler/embedded_cmis.mli \
|
||||||
|
|
||||||
|
COMPILER_LIB_IMPLS := \
|
||||||
|
compiler/embedded_cmis.ml \
|
||||||
|
compiler/tezos_compiler.ml \
|
||||||
|
|
||||||
|
COMPILER_IMPLS := \
|
||||||
|
compiler_main.ml \
|
||||||
|
|
||||||
|
COMPILER_PACKAGES := \
|
||||||
|
${UTILS_PACKAGES} \
|
||||||
|
compiler-libs.optcomp \
|
||||||
|
lwt.unix \
|
||||||
|
ocplib-endian \
|
||||||
|
ocplib-ocamlres \
|
||||||
|
unix \
|
||||||
|
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## Node program
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
NODE_LIB_SOURCE_DIRECTORIES := \
|
||||||
|
${COMPILER_SOURCE_DIRECTORIES} \
|
||||||
|
${SRCDIR}/node/db ${SRCDIR}/node/net \
|
||||||
|
${SRCDIR}/node/updater ${SRCDIR}/node/shell \
|
||||||
|
|
||||||
|
NODE_SOURCE_DIRECTORIES := \
|
||||||
|
${NODE_LIB_SOURCE_DIRECTORIES} \
|
||||||
|
${SRCDIR}/node/main
|
||||||
|
|
||||||
|
NODE_OPENED_MODULES := Error_monad Hash Utils
|
||||||
|
|
||||||
|
NODE_LIB_INTFS := \
|
||||||
|
\
|
||||||
|
node/net/p2p_types.mli \
|
||||||
|
node/net/p2p_io_scheduler.mli \
|
||||||
|
node/net/p2p_connection.mli \
|
||||||
|
node/net/p2p_connection_pool_types.mli \
|
||||||
|
node/net/p2p_connection_pool.mli \
|
||||||
|
node/net/p2p_welcome.mli \
|
||||||
|
node/net/p2p_discovery.mli \
|
||||||
|
node/net/p2p_maintenance.mli \
|
||||||
|
node/net/p2p.mli \
|
||||||
|
node/net/RPC_server.mli \
|
||||||
|
\
|
||||||
|
node/updater/fitness.mli \
|
||||||
|
\
|
||||||
|
node/db/store_sigs.mli \
|
||||||
|
node/db/raw_store.mli \
|
||||||
|
node/db/store_sigs.mli \
|
||||||
|
node/db/store_helpers.mli \
|
||||||
|
node/db/store.mli \
|
||||||
|
\
|
||||||
|
node/db/ir_funview.mli \
|
||||||
|
node/db/persist.mli \
|
||||||
|
node/db/context.mli \
|
||||||
|
\
|
||||||
|
node/updater/protocol.mli \
|
||||||
|
node/updater/updater.mli \
|
||||||
|
node/updater/proto_environment.mli \
|
||||||
|
node/updater/register.mli \
|
||||||
|
\
|
||||||
|
node/shell/state.mli \
|
||||||
|
node/shell/distributed_db_functors.mli \
|
||||||
|
node/shell/distributed_db_message.mli \
|
||||||
|
node/shell/distributed_db_metadata.mli \
|
||||||
|
node/shell/distributed_db.mli \
|
||||||
|
node/shell/prevalidator.mli \
|
||||||
|
node/shell/validator.mli \
|
||||||
|
\
|
||||||
|
node/shell/node_rpc_services.mli \
|
||||||
|
node/shell/node.mli \
|
||||||
|
node/shell/node_rpc.mli \
|
||||||
|
|
||||||
|
# this includes single .mli for `node.top`
|
||||||
|
FULL_NODE_LIB_IMPLS := \
|
||||||
|
\
|
||||||
|
compiler/node_compiler_main.ml \
|
||||||
|
\
|
||||||
|
node/net/p2p_types.ml \
|
||||||
|
node/net/p2p_io_scheduler.ml \
|
||||||
|
node/net/p2p_connection.ml \
|
||||||
|
node/net/p2p_connection_pool_types.ml \
|
||||||
|
node/net/p2p_connection_pool.ml \
|
||||||
|
node/net/p2p_welcome.ml \
|
||||||
|
node/net/p2p_discovery.ml \
|
||||||
|
node/net/p2p_maintenance.ml \
|
||||||
|
node/net/p2p.ml \
|
||||||
|
\
|
||||||
|
node/net/RPC_server.ml \
|
||||||
|
\
|
||||||
|
node/updater/fitness.ml \
|
||||||
|
\
|
||||||
|
node/db/raw_store.ml \
|
||||||
|
node/db/store_sigs.mli \
|
||||||
|
node/db/store_helpers.ml \
|
||||||
|
node/db/store.ml \
|
||||||
|
\
|
||||||
|
node/db/ir_funview.ml \
|
||||||
|
node/db/persist.ml \
|
||||||
|
node/db/context.ml \
|
||||||
|
\
|
||||||
|
node/updater/protocol.mli \
|
||||||
|
node/updater/updater.ml \
|
||||||
|
node/updater/environment.ml \
|
||||||
|
node/updater/proto_environment.ml \
|
||||||
|
node/updater/register.ml \
|
||||||
|
\
|
||||||
|
node/shell/state.ml \
|
||||||
|
node/shell/distributed_db_functors.ml \
|
||||||
|
node/shell/distributed_db_message.ml \
|
||||||
|
node/shell/distributed_db_metadata.ml \
|
||||||
|
node/shell/distributed_db.ml \
|
||||||
|
node/shell/prevalidator.ml \
|
||||||
|
node/shell/validator.ml \
|
||||||
|
\
|
||||||
|
node/shell/node_rpc_services.ml \
|
||||||
|
node/shell/node.ml \
|
||||||
|
node/shell/node_rpc.ml \
|
||||||
|
|
||||||
|
# this only includes .ml
|
||||||
|
NODE_LIB_IMPLS := $(filter-out ${NODE_LIB_INTFS}, ${FULL_NODE_LIB_IMPLS})
|
||||||
|
|
||||||
|
NODE_INTFS := \
|
||||||
|
node/main/node_identity_file.mli \
|
||||||
|
node/main/node_config_file.mli \
|
||||||
|
node/main/node_shared_arg.mli \
|
||||||
|
node/main/node_run_command.mli \
|
||||||
|
node/main/node_config_command.mli \
|
||||||
|
node/main/node_identity_command.mli \
|
||||||
|
|
||||||
|
NODE_IMPLS := \
|
||||||
|
node/main/node_identity_file.ml \
|
||||||
|
node/main/node_config_file.ml \
|
||||||
|
node/main/node_shared_arg.ml \
|
||||||
|
node/main/node_run_command.ml \
|
||||||
|
node/main/node_config_command.ml \
|
||||||
|
node/main/node_identity_command.ml \
|
||||||
|
node_main.ml \
|
||||||
|
|
||||||
|
NODE_PACKAGES := \
|
||||||
|
$(COMPILER_PACKAGES) \
|
||||||
|
calendar \
|
||||||
|
cmdliner \
|
||||||
|
cohttp.lwt \
|
||||||
|
dynlink \
|
||||||
|
git \
|
||||||
|
ipv6-multicast \
|
||||||
|
irmin.unix \
|
||||||
|
ocplib-resto.directory \
|
||||||
|
|
||||||
|
EMBEDDED_NODE_PROTOCOLS := \
|
||||||
|
$(patsubst ${SRCDIR}/proto/%/,${SRCDIR}/proto/embedded_proto_%.cmxa, \
|
||||||
|
$(filter-out ${SRCDIR}/proto/environment/, \
|
||||||
|
$(subst TEZOS_PROTOCOL,,$(shell ls ${SRCDIR}/proto/*/TEZOS_PROTOCOL))))
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## Client program
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
# we do not include 'node/main'
|
||||||
|
CLIENT_SOURCE_DIRECTORIES := \
|
||||||
|
${NODE_LIB_SOURCE_DIRECTORIES} \
|
||||||
|
${SRCDIR}/client ${SRCDIR}/client/embedded
|
||||||
|
|
||||||
|
CLIENT_OPENED_MODULES := Error_monad Hash Utils
|
||||||
|
|
||||||
|
CLIENT_LIB_INTFS := \
|
||||||
|
client/client_rpcs.mli \
|
||||||
|
client/client_node_rpcs.mli \
|
||||||
|
client/client_commands.mli \
|
||||||
|
client/client_generic_rpcs.mli \
|
||||||
|
client/client_helpers.mli \
|
||||||
|
client/client_aliases.mli \
|
||||||
|
client/client_tags.mli \
|
||||||
|
client/client_keys.mli \
|
||||||
|
client/client_protocols.mli \
|
||||||
|
client/client_blocks.mli \
|
||||||
|
client/client_network.mli \
|
||||||
|
|
||||||
|
CLIENT_LIB_IMPLS := \
|
||||||
|
client/client_rpcs.ml \
|
||||||
|
client/client_node_rpcs.ml \
|
||||||
|
client/client_commands.ml \
|
||||||
|
client/client_config.ml \
|
||||||
|
client/client_generic_rpcs.ml \
|
||||||
|
client/client_helpers.ml \
|
||||||
|
client/client_aliases.ml \
|
||||||
|
client/client_tags.ml \
|
||||||
|
client/client_keys.ml \
|
||||||
|
client/client_protocols.ml \
|
||||||
|
client/client_blocks.ml \
|
||||||
|
client/client_network.ml \
|
||||||
|
|
||||||
|
CLIENT_IMPLS := \
|
||||||
|
client_main.ml
|
||||||
|
|
||||||
|
CLIENT_PACKAGES := \
|
||||||
|
${NODE_PACKAGES} \
|
||||||
|
magic-mime \
|
||||||
|
|
||||||
|
EMBEDDED_CLIENT_PROTOCOLS := \
|
||||||
|
$(patsubst ${SRCDIR}/client/embedded/%/, \
|
||||||
|
${SRCDIR}/proto/client_embedded_proto_%.cmxa, \
|
||||||
|
$(shell ls -d ${SRCDIR}/client/embedded/*/))
|
||||||
|
|
||||||
|
EMBEDDED_CLIENT_VERSIONS := \
|
||||||
|
$(patsubst ${SRCDIR}/client/embedded/%/, \
|
||||||
|
${SRCDIR}/client/embedded/client_%.cmx, \
|
||||||
|
$(shell ls -d ${SRCDIR}/client/embedded/*/))
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## Web-Client program
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
# we do not include 'node/main'
|
||||||
|
WEBCLIENT_SOURCE_DIRECTORIES := \
|
||||||
|
${NODE_LIB_SOURCE_DIRECTORIES} \
|
||||||
|
${SRCDIR}/client ${SRCDIR}/client/embedded
|
||||||
|
|
||||||
|
WEBCLIENT_OPENED_MODULES := Error_monad Hash Utils
|
||||||
|
|
||||||
|
WEBCLIENT_LIB_INTFS := \
|
||||||
|
|
||||||
|
WEBCLIENT_LIB_IMPLS := \
|
||||||
|
client/webclient_version.ml \
|
||||||
|
|
||||||
|
WEBCLIENT_IMPLS := \
|
||||||
|
webclient_static.ml \
|
||||||
|
webclient_main.ml
|
||||||
|
|
||||||
|
EMBEDDED_WEBCLIENT_VERSIONS := \
|
||||||
|
$(patsubst ${SRCDIR}/client/embedded/%/, \
|
||||||
|
${SRCDIR}/client/embedded/webclient_%.cmx, \
|
||||||
|
$(shell ls -d ${SRCDIR}/client/embedded/*/))
|
||||||
|
|
28
test/.merlin
28
test/.merlin
@ -1,28 +0,0 @@
|
|||||||
REC
|
|
||||||
S .
|
|
||||||
B .
|
|
||||||
S ../src/minutils
|
|
||||||
B ../src/minutils
|
|
||||||
S ../src/utils
|
|
||||||
B ../src/utils
|
|
||||||
S ../src/node/db
|
|
||||||
B ../src/node/db
|
|
||||||
S ../src/node/net
|
|
||||||
B ../src/node/net
|
|
||||||
S ../src/node/updater
|
|
||||||
B ../src/node/updater
|
|
||||||
S ../src/node/shell
|
|
||||||
B ../src/node/shell
|
|
||||||
S ../src/proto
|
|
||||||
B ../src/proto
|
|
||||||
S ../src/client
|
|
||||||
B ../src/client
|
|
||||||
S ../src/client/embedded
|
|
||||||
B ../src/client/embedded
|
|
||||||
S ./lib
|
|
||||||
B ./lib
|
|
||||||
FLG -w -40
|
|
||||||
PKG lwt
|
|
||||||
PKG sodium
|
|
||||||
PKG kaputt
|
|
||||||
PKG ipaddr
|
|
367
test/Makefile
367
test/Makefile
@ -1,353 +1,28 @@
|
|||||||
|
|
||||||
TESTS := \
|
DIR := \
|
||||||
merkle \
|
|
||||||
data-encoding \
|
|
||||||
store context state \
|
|
||||||
basic basic.sh \
|
|
||||||
p2p-io-scheduler \
|
|
||||||
p2p-connection \
|
|
||||||
p2p-connection-pool
|
|
||||||
|
|
||||||
all: test
|
|
||||||
|
|
||||||
INCLUDES = $(patsubst %, -I %, $(SOURCE_DIRECTORIES) lib)
|
|
||||||
OCAMLFLAGS = \
|
|
||||||
-g -safe-string -w -40 \
|
|
||||||
${INCLUDES} \
|
|
||||||
$(patsubst %, -package %, $(PACKAGES)) \
|
|
||||||
${EXTRA_OCAMLFLAGS}
|
|
||||||
|
|
||||||
SOURCE_DIRECTORIES := \
|
|
||||||
lib \
|
|
||||||
$(addprefix ../src/, \
|
|
||||||
minutils \
|
|
||||||
utils \
|
utils \
|
||||||
compiler \
|
shell \
|
||||||
node/db \
|
p2p
|
||||||
node/net \
|
|
||||||
node/updater \
|
|
||||||
node/shell \
|
|
||||||
proto \
|
|
||||||
)
|
|
||||||
|
|
||||||
PACKAGES := \
|
all: build run
|
||||||
base64 \
|
|
||||||
calendar \
|
|
||||||
cohttp.lwt \
|
|
||||||
compiler-libs.optcomp \
|
|
||||||
cstruct \
|
|
||||||
dynlink \
|
|
||||||
ezjsonm \
|
|
||||||
git \
|
|
||||||
ipv6-multicast \
|
|
||||||
irmin.unix \
|
|
||||||
lwt \
|
|
||||||
lwt.unix \
|
|
||||||
mtime.os \
|
|
||||||
ocplib-endian \
|
|
||||||
ocplib-ocamlres \
|
|
||||||
ocplib-json-typed.bson \
|
|
||||||
ocplib-resto.directory \
|
|
||||||
sodium \
|
|
||||||
unix \
|
|
||||||
kaputt \
|
|
||||||
|
|
||||||
ifeq ($(strip ${COVERAGE}),yes)
|
.PHONY: build run test
|
||||||
PACKAGES += bisect_ppx.runtime
|
build:
|
||||||
endif
|
${MAKE} -C lib build
|
||||||
|
${MAKE} ${addprefix build-,${DIR}}
|
||||||
|
run:
|
||||||
|
${MAKE} ${addprefix run-,${DIR}}
|
||||||
|
${MAKE} run-basic.sh
|
||||||
|
clean:
|
||||||
|
${MAKE} -C lib clean
|
||||||
|
${MAKE} ${addprefix clean-,${DIR}}
|
||||||
|
|
||||||
############################################################################
|
${addprefix build-,${DIR}}: build-%:
|
||||||
## External packages
|
${MAKE} -C $* build
|
||||||
|
${addprefix run-,${DIR}}: run-%:
|
||||||
|
${MAKE} -C $* run
|
||||||
|
${addprefix clean-,${DIR}}: clean-%:
|
||||||
|
${MAKE} -C $* clean
|
||||||
|
|
||||||
NODELIB := \
|
run-basic.sh:
|
||||||
../src/minutils.cmxa ../src/utils.cmxa \
|
|
||||||
../src/compiler.cmxa ../src/node.cmxa
|
|
||||||
CLIENTLIB := ../src/client.cmxa \
|
|
||||||
$(patsubst ../src/client/embedded/%/, \
|
|
||||||
../src/proto/client_embedded_proto_%.cmxa, \
|
|
||||||
$(shell ls -d ../src/client/embedded/*/)) \
|
|
||||||
$(patsubst ../src/client/embedded/%/, \
|
|
||||||
../src/client/embedded/client_%.cmx, \
|
|
||||||
$(shell ls -d ../src/client/embedded/*/))
|
|
||||||
|
|
||||||
${NODELIB} ${CLIENTLIB}:
|
|
||||||
${MAKE} -C ../src $@
|
|
||||||
|
|
||||||
.PHONY: build-test run-test test
|
|
||||||
build-test: ${addprefix build-test-,${TESTS}}
|
|
||||||
run-test:
|
|
||||||
@$(patsubst %,${MAKE} run-test-% && , ${TESTS}) \
|
|
||||||
echo && echo "Success" && echo
|
|
||||||
test:
|
|
||||||
@${MAKE} --no-print-directory build-test
|
|
||||||
@${MAKE} --no-print-directory run-test
|
|
||||||
|
|
||||||
############################################################################
|
|
||||||
## Store test program
|
|
||||||
|
|
||||||
.PHONY:build-test-store run-test-store
|
|
||||||
build-test-store: test-store
|
|
||||||
run-test-store:
|
|
||||||
./test-store
|
|
||||||
|
|
||||||
TEST_STORE_INTFS =
|
|
||||||
|
|
||||||
TEST_STORE_IMPLS = \
|
|
||||||
lib/assert.ml \
|
|
||||||
lib/test.ml \
|
|
||||||
test_store.ml
|
|
||||||
|
|
||||||
${TEST_STORE_IMPLS:.ml=.cmx}: ${NODELIB}
|
|
||||||
test-store: ${NODELIB} ${TEST_STORE_IMPLS:.ml=.cmx}
|
|
||||||
ocamlfind ocamlopt -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
|
||||||
|
|
||||||
clean::
|
|
||||||
rm -f test-store
|
|
||||||
|
|
||||||
|
|
||||||
############################################################################
|
|
||||||
## Context test program
|
|
||||||
|
|
||||||
.PHONY:build-test-context run-test-context
|
|
||||||
build-test-context: test-context
|
|
||||||
run-test-context:
|
|
||||||
./test-context
|
|
||||||
|
|
||||||
TEST_CONTEXT_INTFS =
|
|
||||||
|
|
||||||
TEST_CONTEXT_IMPLS = \
|
|
||||||
lib/assert.ml \
|
|
||||||
lib/test.ml \
|
|
||||||
test_context.ml
|
|
||||||
|
|
||||||
${TEST_CONTEXT_IMPLS:.ml=.cmx}: ${NODELIB}
|
|
||||||
test-context: ${NODELIB} ${TEST_CONTEXT_IMPLS:.ml=.cmx}
|
|
||||||
ocamlfind ocamlopt -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
|
||||||
|
|
||||||
clean::
|
|
||||||
rm -f test-context
|
|
||||||
|
|
||||||
|
|
||||||
############################################################################
|
|
||||||
## State test program
|
|
||||||
|
|
||||||
.PHONY:build-test-state run-test-state
|
|
||||||
build-test-state: test-state
|
|
||||||
run-test-state:
|
|
||||||
./test-state
|
|
||||||
|
|
||||||
TEST_STATE_INTFS =
|
|
||||||
|
|
||||||
TEST_STATE_IMPLS = \
|
|
||||||
lib/assert.ml \
|
|
||||||
lib/test.ml \
|
|
||||||
test_state.ml
|
|
||||||
|
|
||||||
${TEST_STATE_IMPLS:.ml=.cmx}: ${NODELIB}
|
|
||||||
test-state: ${NODELIB} ../src/proto/embedded_proto_demo.cmxa ${TEST_STATE_IMPLS:.ml=.cmx}
|
|
||||||
ocamlfind ocamlopt -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
|
||||||
|
|
||||||
clean::
|
|
||||||
rm -f test-state
|
|
||||||
|
|
||||||
|
|
||||||
############################################################################
|
|
||||||
## Basic-client-functionality test program
|
|
||||||
|
|
||||||
.PHONY:build-test-basic.sh run-test-basic.sh
|
|
||||||
build-test-basic.sh:
|
|
||||||
run-test-basic.sh:
|
|
||||||
./test-basic.sh
|
./test-basic.sh
|
||||||
|
|
||||||
.PHONY:build-test-basic run-test-basic
|
|
||||||
build-test-basic: test-basic
|
|
||||||
run-test-basic:
|
|
||||||
./test-basic
|
|
||||||
|
|
||||||
TEST_BASIC_INTFS =
|
|
||||||
|
|
||||||
TEST_BASIC_IMPLS = \
|
|
||||||
lib/assert.ml \
|
|
||||||
lib/test.ml \
|
|
||||||
test_basic.ml
|
|
||||||
|
|
||||||
test-basic \
|
|
||||||
${TEST_BASIC_IMPLS:.ml=.cmx}: \
|
|
||||||
SOURCE_DIRECTORIES+=../src/client ../src/client/embedded/
|
|
||||||
|
|
||||||
${TEST_BASIC_IMPLS:.ml=.cmx}: ${NODELIB} ${CLIENTLIB}
|
|
||||||
test-basic: ${NODELIB} ${CLIENTLIB} ${TEST_BASIC_IMPLS:.ml=.cmx}
|
|
||||||
ocamlfind ocamlopt -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
|
||||||
|
|
||||||
clean::
|
|
||||||
rm -f test-basic
|
|
||||||
|
|
||||||
############################################################################
|
|
||||||
## p2p test program
|
|
||||||
|
|
||||||
.PHONY:build-test-p2p-io-scheduler run-test-p2p-io-scheduler
|
|
||||||
build-test-p2p-io-scheduler: test-p2p-io-scheduler
|
|
||||||
run-test-p2p-io-scheduler:
|
|
||||||
./test-p2p-io-scheduler \
|
|
||||||
--delay 20 --clients 8 \
|
|
||||||
--max-upload-speed $$((1 << 18)) \
|
|
||||||
--max-download-speed $$((1 << 20))
|
|
||||||
|
|
||||||
.PHONY:build-test-p2p-connection run-test-p2p-connection
|
|
||||||
build-test-p2p-connection: test-p2p-connection
|
|
||||||
run-test-p2p-connection:
|
|
||||||
./test-p2p-connection
|
|
||||||
|
|
||||||
.PHONY:build-test-p2p-connection-pool run-test-p2p-connection-pool
|
|
||||||
build-test-p2p-connection-pool: test-p2p-connection-pool
|
|
||||||
run-test-p2p-connection-pool:
|
|
||||||
./test-p2p-connection-pool --clients 10 --repeat 5
|
|
||||||
|
|
||||||
TEST_P2P_IO_SCHEDULER_IMPLS = \
|
|
||||||
lib/process.ml \
|
|
||||||
test_p2p_io_scheduler.ml
|
|
||||||
|
|
||||||
TEST_P2P_CONNECTION_IMPLS = \
|
|
||||||
lib/process.ml \
|
|
||||||
test_p2p_connection.ml
|
|
||||||
|
|
||||||
TEST_P2P_CONNECTION_POOL_IMPLS = \
|
|
||||||
lib/process.ml \
|
|
||||||
test_p2p_connection_pool.ml
|
|
||||||
|
|
||||||
${TEST_P2P_IO_SCHEDULER_IMPLS:.ml=.cmx}: ${NODELIB}
|
|
||||||
test-p2p-io-scheduler: ${NODELIB} ${TEST_P2P_IO_SCHEDULER_IMPLS:.ml=.cmx}
|
|
||||||
ocamlfind ocamlopt -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
|
||||||
|
|
||||||
${TEST_P2P_CONNECTION_IMPLS:.ml=.cmx}: ${NODELIB}
|
|
||||||
test-p2p-connection: ${NODELIB} ${TEST_P2P_CONNECTION_IMPLS:.ml=.cmx}
|
|
||||||
ocamlfind ocamlopt -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
|
||||||
|
|
||||||
${TEST_P2P_CONNECTION_POOL_IMPLS:.ml=.cmx}: ${NODELIB}
|
|
||||||
test-p2p-connection-pool: ${NODELIB} ${TEST_P2P_CONNECTION_POOL_IMPLS:.ml=.cmx}
|
|
||||||
ocamlfind ocamlopt -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
|
||||||
|
|
||||||
clean::
|
|
||||||
-rm -f test-p2p-io_scheduler
|
|
||||||
-rm -f test-p2p-connection
|
|
||||||
-rm -f test-p2p-connection-pool
|
|
||||||
|
|
||||||
############################################################################
|
|
||||||
## lwt pipe test program
|
|
||||||
|
|
||||||
build-test-lwt-pipe: test-lwt-pipe
|
|
||||||
|
|
||||||
TEST_PIPE_IMPLS = \
|
|
||||||
test_lwt_pipe.ml
|
|
||||||
|
|
||||||
${TEST_BASIC_IMPLS:.ml=.cmx}: ${NODELIB}
|
|
||||||
test-lwt-pipe: ${NODELIB} ${TEST_PIPE_IMPLS:.ml=.cmx}
|
|
||||||
ocamlfind ocamlopt -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
|
||||||
|
|
||||||
clean::
|
|
||||||
rm -f test-p2p
|
|
||||||
|
|
||||||
############################################################################
|
|
||||||
## Merkle test program
|
|
||||||
|
|
||||||
.PHONY:build-test-merkle run-test-merkle
|
|
||||||
build-test-merkle: test-merkle
|
|
||||||
run-test-merkle:
|
|
||||||
./test-merkle
|
|
||||||
|
|
||||||
TEST_MERKLE_INTFS =
|
|
||||||
|
|
||||||
TEST_MERKLE_IMPLS = \
|
|
||||||
lib/assert.ml \
|
|
||||||
lib/test.ml \
|
|
||||||
test_merkle.ml
|
|
||||||
|
|
||||||
${TEST_MERKLE_IMPLS:.ml=.cmx}: ${NODELIB}
|
|
||||||
test-merkle: ${NODELIB} ${TEST_MERKLE_IMPLS:.ml=.cmx}
|
|
||||||
ocamlfind ocamlopt -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
|
||||||
|
|
||||||
clean::
|
|
||||||
rm -f test-merkle
|
|
||||||
|
|
||||||
|
|
||||||
############################################################################
|
|
||||||
## data encoding test program
|
|
||||||
|
|
||||||
.PHONY:build-test-data-encoding run-test-data-encoding
|
|
||||||
build-test-data-encoding: test-data-encoding
|
|
||||||
run-test-data-encoding:
|
|
||||||
./test-data-encoding
|
|
||||||
|
|
||||||
TEST_DATA_ENCODING_INTFS =
|
|
||||||
|
|
||||||
TEST_DATA_ENCODING_IMPLS = \
|
|
||||||
lib/assert.ml \
|
|
||||||
lib/test.ml \
|
|
||||||
test_data_encoding.ml
|
|
||||||
|
|
||||||
${TEST_DATA_ENCODING_IMPLS:.ml=.cmx}: ${NODELIB}
|
|
||||||
test-data-encoding: ${NODELIB} ${TEST_DATA_ENCODING_IMPLS:.ml=.cmx}
|
|
||||||
ocamlfind ocamlopt -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
|
||||||
|
|
||||||
clean::
|
|
||||||
rm -f test-data-encoding
|
|
||||||
|
|
||||||
COVERAGESRCDIR= \
|
|
||||||
-I ../src \
|
|
||||||
-I ../src/client \
|
|
||||||
-I ../src/client/embedded \
|
|
||||||
-I ../src/client/embedded/alpha \
|
|
||||||
-I ../src/client/embedded/alpha/mining \
|
|
||||||
-I ../src/compiler \
|
|
||||||
-I ../src/node \
|
|
||||||
-I ../src/node/db \
|
|
||||||
-I ../src/node/updater \
|
|
||||||
-I ../src/node/net \
|
|
||||||
-I ../src/node/shell \
|
|
||||||
-I ../src/proto \
|
|
||||||
-I ../src/proto/alpha \
|
|
||||||
-I ../src/proto/demo \
|
|
||||||
-I ../src/minutils \
|
|
||||||
-I ../src/utils
|
|
||||||
|
|
||||||
bisect:
|
|
||||||
bisect-ppx-report $(COVERAGESRCDIR) \
|
|
||||||
-ignore-missing-files -html reports bisect*.out
|
|
||||||
|
|
||||||
#####
|
|
||||||
|
|
||||||
generate_hash: ../src/minutils/utils.cmx ../src/minutils/compare.cmx ../src/minutils/mBytes.cmx ../src/utils/base58.cmx ../src/minutils/hex_encode.cmx ../src/minutils/data_encoding.cmx ../src/utils/cli_entries.cmx ../src/utils/hash.cmx generate_hash.ml
|
|
||||||
ocamlfind ocamlopt -o $@ -linkpkg -package cstruct -package zarith -package ezjsonm -package sodium -package ocplib-json-typed.bson -package lwt.unix -package nocrypto -I ../src/utils/ -I ../src/minutils $^
|
|
||||||
|
|
||||||
|
|
||||||
#####
|
|
||||||
|
|
||||||
lib/assert.cmx: lib/assert.cmi
|
|
||||||
lib/assert.cmi: ../src/node/db/persist.cmi
|
|
||||||
|
|
||||||
lib/process.cmx: lib/process.cmi
|
|
||||||
lib/test.cmx: lib/test.cmi
|
|
||||||
|
|
||||||
############################################################################
|
|
||||||
## Generic rules
|
|
||||||
|
|
||||||
test.cmx: test.cmi
|
|
||||||
|
|
||||||
%.cmx: %.ml
|
|
||||||
ocamlfind ocamlopt ${OCAMLFLAGS} -c $<
|
|
||||||
|
|
||||||
%.cmo: %.ml
|
|
||||||
ocamlfind ocamlc ${OCAMLFLAGS} -c $<
|
|
||||||
|
|
||||||
%.cmi: %.mli
|
|
||||||
ocamlfind ocamlc ${OCAMLFLAGS} -c $<
|
|
||||||
|
|
||||||
clean::
|
|
||||||
-rm -f *.cm* lib/*.cm* *.out *.o
|
|
||||||
|
|
||||||
-include .depend
|
|
||||||
.depend: $(wildcard *.ml *.mli lib/*.ml lib/*.mli)
|
|
||||||
ocamldep -I lib $^ > .depend
|
|
||||||
|
|
||||||
clean::
|
|
||||||
-rm .depend
|
|
||||||
|
90
test/Makefile.shared
Normal file
90
test/Makefile.shared
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
|
||||||
|
ifeq ($(strip ${SRCDIR}),)
|
||||||
|
$(error "Undefined value for $${SRCDIR}")
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: build run
|
||||||
|
|
||||||
|
all:
|
||||||
|
@${MAKE} --no-print-directory build
|
||||||
|
@${MAKE} --no-print-directory run
|
||||||
|
|
||||||
|
build: ${addprefix test-,${TESTS}}
|
||||||
|
|
||||||
|
run:
|
||||||
|
@$(patsubst %,${MAKE} --no-print-directory run-test-% && , ${TESTS}) \
|
||||||
|
echo && echo "Success" && echo
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
-include ${SRCDIR}/Makefile.local
|
||||||
|
include ${SRCDIR}/Makefile.config
|
||||||
|
include ${SRCDIR}/Makefile.files
|
||||||
|
|
||||||
|
COVERAGESRCDIR=$(patsubst %, -I %, $(SOURCE_DIRECTORIES))
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## External packages
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
TESTLIB := ${SRCDIR}/../test/lib/testlib.cmxa
|
||||||
|
|
||||||
|
${TESTLIB}: $(shell find ${SRCDIR}/../test/lib -name \*.ml -or -name \*.mli)
|
||||||
|
${MAKE} -C ${SRCDIR}/../test/lib testlib.cmxa
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## External packages
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
MINUTILSLIB := ${SRCDIR}/minutils.cmxa
|
||||||
|
UTILSLIB := ${SRCDIR}/utils.cmxa
|
||||||
|
COMPILERLIB := ${SRCDIR}/compiler.cmxa
|
||||||
|
NODELIB := ${SRCDIR}/node.cmxa
|
||||||
|
|
||||||
|
CLIENTLIB := ${SRCDIR}/client.cmxa \
|
||||||
|
$(patsubst ${SRCDIR}/client/embedded/%/, \
|
||||||
|
${SRCDIR}/proto/client_embedded_proto_%.cmxa, \
|
||||||
|
$(shell ls -d ${SRCDIR}/client/embedded/*/)) \
|
||||||
|
$(patsubst ${SRCDIR}/client/embedded/%/, \
|
||||||
|
${SRCDIR}/client/embedded/client_%.cmx, \
|
||||||
|
$(shell ls -d ${SRCDIR}/client/embedded/*/))
|
||||||
|
|
||||||
|
${MINUTILSLIB} ${UTILSLIB} ${COMPILERLIB} ${NODELIB} ${CLIENTLIB}:
|
||||||
|
${MAKE} -C ${SRCDIR} $@
|
||||||
|
|
||||||
|
${SRCDIR}/minutils/%: ${MINUTILSLIB}
|
||||||
|
${SRCDIR}/utils/%: ${UTILSLIB}
|
||||||
|
${SRCDIR}/compiler/%: ${COMPILERLIB}
|
||||||
|
${SRCDIR}/node/%: ${NODELIB}
|
||||||
|
${SRCDIR}/client/%: ${CLIENTLIB}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## Generic rules
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
%.cmx: %.ml
|
||||||
|
@echo OCAMLOPT ${TARGET} $(notdir $@)
|
||||||
|
@$(OCAMLOPT) ${OCAMLFLAGS} -c $<
|
||||||
|
|
||||||
|
%.cmo: %.ml
|
||||||
|
@echo OCAMLC ${TARGET} $(notdir $@)
|
||||||
|
@$(OCAMLC) ${OCAMLFLAGS} -c $<
|
||||||
|
|
||||||
|
%.cmi: %.mli
|
||||||
|
@echo OCAMLOPT ${TARGET} $(notdir $@)
|
||||||
|
@$(OCAMLOPT) ${OCAMLFLAGS} -c $<
|
||||||
|
|
||||||
|
## Cleaning
|
||||||
|
|
||||||
|
.PHONY: clean partial-clean
|
||||||
|
clean:: partial-clean
|
||||||
|
partial-clean::
|
||||||
|
-find \( -name \*.cm\* -or -name \*.cmp -or -name \*.out -or -name \*~ -or -name \*.o -or -name \*.a \) -delete
|
||||||
|
|
||||||
|
-include .depend
|
||||||
|
.depend: $(shell find -name \*.ml -or -name \*.ml)
|
||||||
|
@echo OCAMLDEP "(test/$(notdir $(shell echo $$PWD)))"
|
||||||
|
@$(OCAMLDEP) -native $(INCLUDES) $^ > .depend
|
||||||
|
|
||||||
|
clean::
|
||||||
|
-rm .depend
|
@ -1,151 +0,0 @@
|
|||||||
(*
|
|
||||||
ocamlfind ocamlopt \
|
|
||||||
-package 'lwt,lwt.unix,lwt.log,ezjsonm,ocplib-endian,config-file,cstruct' \
|
|
||||||
../core/utils.cmx ../core/logs.cmx ../core/mMBytes.cmx ../core/json.cmx \
|
|
||||||
netbits.cmx p2p.cmx test_p2p.ml -linkpkg \
|
|
||||||
-o test_p2p && ./test_p2p
|
|
||||||
*)
|
|
||||||
|
|
||||||
open Lwt
|
|
||||||
open P2p
|
|
||||||
open Netbits
|
|
||||||
open Printf
|
|
||||||
|
|
||||||
let interval min max cb =
|
|
||||||
let rec loop acc n =
|
|
||||||
if n > max then List.rev acc
|
|
||||||
else loop ((n, cb n) :: acc) (n + 1) in
|
|
||||||
loop [] min
|
|
||||||
|
|
||||||
let rec join_map acc = function
|
|
||||||
| [] -> return (List.rev acc)
|
|
||||||
| (i, t) :: ts -> t >>= fun v -> join_map ((i, v) :: acc) ts
|
|
||||||
|
|
||||||
let show_peers creds net =
|
|
||||||
Printf.printf " - Network of %s\n%!" creds ;
|
|
||||||
let peers = peers net in
|
|
||||||
peers |> List.iter @@ fun peer ->
|
|
||||||
let addr, port, _ = peer_info peer net in
|
|
||||||
Printf.printf " * %s @ %s:%i\n%!" creds addr port
|
|
||||||
|
|
||||||
|
|
||||||
(* launch 15 peers who originally know all the others, make everyone
|
|
||||||
send toto, and wait for everyone to receive one toto *)
|
|
||||||
let toto () =
|
|
||||||
let known_peers =
|
|
||||||
interval 0 15 (fun i -> ("127.0.0.1", 4440 + i)) |> List.split |> snd
|
|
||||||
in
|
|
||||||
let net i =
|
|
||||||
bootstrap
|
|
||||||
{ incoming_port = Some (4440 + i) ;
|
|
||||||
discovery_port = None ;
|
|
||||||
supported_versions = [ "TEST", 0, 0 ] ;
|
|
||||||
known_peers;
|
|
||||||
peers_file = sprintf "test_peers_toto_%d.json" i }
|
|
||||||
{ max_packet_size = 10_000 ;
|
|
||||||
peer_answer_timeout = 2. ;
|
|
||||||
expected_connections = 5 ;
|
|
||||||
min_connections = 2 ;
|
|
||||||
max_connections = 20 ;
|
|
||||||
blacklist_time = 30. }
|
|
||||||
in
|
|
||||||
let nets = interval 0 15 (fun i -> net i) in
|
|
||||||
printf "---- Networks created\n%!" ;
|
|
||||||
join_map [] nets >>= fun nets ->
|
|
||||||
printf "---- Networks bootstrapped\n%!" ;
|
|
||||||
List.iter (fun (_, net) -> broadcast [ B (MBytes.of_string "TOTO") ] net) nets ;
|
|
||||||
printf "---- Messages sent\n%!" ;
|
|
||||||
let recv (i, net) = i, recv net >>= fun (_, m) ->
|
|
||||||
Printf.printf "user_%d received %s\n%!" i (Netbits.to_string m) ;
|
|
||||||
return m
|
|
||||||
in
|
|
||||||
let receptions = List.map recv nets in
|
|
||||||
join_map [] receptions >>= fun msgs ->
|
|
||||||
printf "---- Messages received\n%!" ;
|
|
||||||
let shutdowns = List.map (fun (i, net) -> i, shutdown net) nets in
|
|
||||||
join_map [] shutdowns >>= fun _ ->
|
|
||||||
printf "---- Networks shutdown\n%!" ;
|
|
||||||
return ()
|
|
||||||
|
|
||||||
(* launch 15 peers who originally know only one another, make everyone
|
|
||||||
connect to at least 10 others *)
|
|
||||||
let boot () =
|
|
||||||
let net i =
|
|
||||||
bootstrap
|
|
||||||
{ incoming_port = Some (4440 + i) ;
|
|
||||||
discovery_port = None ;
|
|
||||||
supported_versions = [ "TEST", 0, 0 ] ;
|
|
||||||
known_peers = [ "127.0.0.1", 4440 + ((i + 1) mod 16) ] ;
|
|
||||||
peers_file = sprintf "test_peers_boot_%d.json" i }
|
|
||||||
{ max_packet_size = 10_000 ;
|
|
||||||
peer_answer_timeout = 2. ;
|
|
||||||
expected_connections = 10 ;
|
|
||||||
min_connections = 2 ;
|
|
||||||
max_connections = 20 ;
|
|
||||||
blacklist_time = 30. }
|
|
||||||
in
|
|
||||||
let nets = interval 0 15 (fun i -> net i) in
|
|
||||||
printf "---- Networks created\n%!" ;
|
|
||||||
join_map [] nets >>= fun nets ->
|
|
||||||
printf "---- Networks bootstrapped\n%!" ;
|
|
||||||
List.iter (fun (i, net) -> show_peers (sprintf "user_%d" i) net) nets ;
|
|
||||||
let shutdowns = List.map (fun (i, net) -> i, shutdown net) nets in
|
|
||||||
join_map [] shutdowns >>= fun _ ->
|
|
||||||
printf "---- Networks shutdown\n%!" ;
|
|
||||||
return ()
|
|
||||||
|
|
||||||
(* the same as above, but five nodes have no input port, and some
|
|
||||||
known addresses are bad ones *)
|
|
||||||
let boot_with_unreachable () =
|
|
||||||
let net i =
|
|
||||||
bootstrap
|
|
||||||
{ incoming_port = if i > 10 then None else Some (4440 + i) ;
|
|
||||||
discovery_port = None ;
|
|
||||||
supported_versions = [ "TEST", 0, 0 ] ;
|
|
||||||
known_peers = [ "127.0.0.1", 4440 + ((i + 1) mod 10) ;
|
|
||||||
"127.0.0.1", 9999 ] ;
|
|
||||||
peers_file = sprintf "test_peers_boot_%d.json" i }
|
|
||||||
{ max_packet_size = 10_000 ;
|
|
||||||
peer_answer_timeout = 2. ;
|
|
||||||
expected_connections = 10 ;
|
|
||||||
min_connections = 5 ;
|
|
||||||
max_connections = 15 ;
|
|
||||||
blacklist_time = 30. }
|
|
||||||
in
|
|
||||||
let nets = interval 0 15 (fun i -> net i) in
|
|
||||||
printf "---- Networks created\n%!" ;
|
|
||||||
join_map [] nets >>= fun nets ->
|
|
||||||
printf "---- Networks bootstrapped\n%!" ;
|
|
||||||
List.iter (fun (i, net) -> show_peers (sprintf "user_%d" i) net) nets ;
|
|
||||||
let shutdowns = List.map (fun (i, net) -> i, shutdown net) nets in
|
|
||||||
join_map [] shutdowns >>= fun _ ->
|
|
||||||
printf "---- Networks shutdown\n%!" ;
|
|
||||||
return ()
|
|
||||||
|
|
||||||
(* connect to ten peers, only by using local discovery *)
|
|
||||||
let boot_by_discovery () =
|
|
||||||
let net i =
|
|
||||||
bootstrap
|
|
||||||
{ incoming_port = Some (4440 + i) ;
|
|
||||||
discovery_port = Some 121212 ;
|
|
||||||
supported_versions = [ "TEST", 0, 0 ] ;
|
|
||||||
known_peers = [] ;
|
|
||||||
peers_file = sprintf "test_peers_boot_%d.json" i }
|
|
||||||
{ max_packet_size = 10_000 ;
|
|
||||||
peer_answer_timeout = 2. ;
|
|
||||||
expected_connections = 10 ;
|
|
||||||
min_connections = 5 ;
|
|
||||||
max_connections = 15 ;
|
|
||||||
blacklist_time = 30. }
|
|
||||||
in
|
|
||||||
let nets = interval 0 15 (fun i -> net i) in
|
|
||||||
printf "---- Networks created\n%!" ;
|
|
||||||
join_map [] nets >>= fun nets ->
|
|
||||||
printf "---- Networks bootstrapped\n%!" ;
|
|
||||||
List.iter (fun (i, net) -> show_peers (sprintf "user_%d" i) net) nets ;
|
|
||||||
let shutdowns = List.map (fun (i, net) -> i, shutdown net) nets in
|
|
||||||
join_map [] shutdowns >>= fun _ ->
|
|
||||||
printf "---- Networks shutdown\n%!" ;
|
|
||||||
return ()
|
|
||||||
|
|
||||||
let _ = Lwt_main.run (boot_by_discovery ())
|
|
@ -1,63 +0,0 @@
|
|||||||
|
|
||||||
open Base58
|
|
||||||
open Hash
|
|
||||||
open Lwt.Infix
|
|
||||||
|
|
||||||
type generator =
|
|
||||||
Generator : {
|
|
||||||
encoding: 'h encoding ;
|
|
||||||
generator: string -> 'h list ;
|
|
||||||
} -> generator
|
|
||||||
|
|
||||||
let generators = ref []
|
|
||||||
|
|
||||||
let register_generator
|
|
||||||
(type a)
|
|
||||||
(encoding : a encoding)
|
|
||||||
(generator : string -> a list) =
|
|
||||||
generators := Generator { encoding ; generator } :: !generators
|
|
||||||
|
|
||||||
let register (type t) (enc: t Base58.encoding) =
|
|
||||||
register_generator enc
|
|
||||||
(fun s ->
|
|
||||||
match
|
|
||||||
enc.of_raw
|
|
||||||
(s ^
|
|
||||||
Sodium.Random.Bytes.generate (enc.length - String.length s)) with
|
|
||||||
| Some x -> [x]
|
|
||||||
| None -> [])
|
|
||||||
|
|
||||||
let generate ?alphabet request =
|
|
||||||
let rec find s = function
|
|
||||||
| [] -> []
|
|
||||||
| Generator { encoding ; generator } :: generators ->
|
|
||||||
if not (Utils.has_prefix ~prefix:encoding.encoded_prefix s) then
|
|
||||||
find s generators
|
|
||||||
else
|
|
||||||
let prefix =
|
|
||||||
partial_decode ?alphabet request encoding.encoded_length in
|
|
||||||
let len = String.length prefix in
|
|
||||||
let ignored = String.length encoding.prefix in
|
|
||||||
if len <= ignored then
|
|
||||||
[]
|
|
||||||
else begin
|
|
||||||
(* assert (String.sub prefix 0 ignored = encoding.prefix) ; *)
|
|
||||||
let msg = String.sub prefix ignored (len - ignored) in
|
|
||||||
let msgs = generator msg in
|
|
||||||
List.map
|
|
||||||
(fun msg -> simple_encode encoding ?alphabet msg)
|
|
||||||
msgs
|
|
||||||
end in
|
|
||||||
find request !generators
|
|
||||||
|
|
||||||
|
|
||||||
let () =
|
|
||||||
register Hash.Block_hash.b58check_encoding ;
|
|
||||||
register Hash.Protocol_hash.b58check_encoding ;
|
|
||||||
if not (!Sys.interactive) then begin
|
|
||||||
for i = 1 to Array.length Sys.argv - 1 do
|
|
||||||
List.iter
|
|
||||||
(Format.printf "%S@.")
|
|
||||||
(generate Sys.argv.(i))
|
|
||||||
done
|
|
||||||
end
|
|
@ -1,9 +0,0 @@
|
|||||||
COMMAND='gnome-terminal'
|
|
||||||
COUNT=2
|
|
||||||
for i in $(seq 1 $COUNT)
|
|
||||||
do
|
|
||||||
SUBCOMMAND="./tezos-node --net-addr :::$((9900 + i)) --local-discovery :::7732 --rpc-addr :::$((8800 + i)) --expected-connections $(($COUNT - 1)) --data-dir /tmp/tezos_$i"
|
|
||||||
COMMAND="$COMMAND --tab -e '$SUBCOMMAND'"
|
|
||||||
done
|
|
||||||
echo $COMMAND
|
|
||||||
eval $COMMAND
|
|
@ -1,19 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
DIR=$(dirname "$0")
|
|
||||||
cd "${DIR}"
|
|
||||||
|
|
||||||
CLIENT_DIR=$(mktemp -d /tmp/tezos_client.XXXXXXXXXX)
|
|
||||||
|
|
||||||
cleanup() {
|
|
||||||
rm -fr ${CLIENT_DIR}
|
|
||||||
}
|
|
||||||
trap cleanup EXIT QUIT INT
|
|
||||||
|
|
||||||
# export LWT_LOG="client.endorsement -> info; client.mining -> info"
|
|
||||||
|
|
||||||
CLIENT="../tezos-client -base-dir ${CLIENT_DIR}"
|
|
||||||
${CLIENT} bootstrap
|
|
||||||
${CLIENT} launch daemon $@
|
|
23
test/lib/.merlin
Normal file
23
test/lib/.merlin
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
REC
|
||||||
|
S .
|
||||||
|
B .
|
||||||
|
S ../../src/minutils
|
||||||
|
B ../../src/minutils
|
||||||
|
S ../../src/utils
|
||||||
|
B ../../src/utils
|
||||||
|
S ../../src/node/net
|
||||||
|
B ../../src/node/net
|
||||||
|
S ../../src/node/db
|
||||||
|
B ../../src/node/db
|
||||||
|
S ../../src/node/updater
|
||||||
|
B ../../src/node/updater
|
||||||
|
S ../../src/node/shell
|
||||||
|
B ../../src/node/shell
|
||||||
|
S ../lib
|
||||||
|
B ../lib
|
||||||
|
FLG -open Error_monad -open Hash -open Utils
|
||||||
|
FLG -w -40
|
||||||
|
PKG lwt
|
||||||
|
PKG sodium
|
||||||
|
PKG kaputt
|
||||||
|
PKG ipaddr
|
32
test/lib/Makefile
Normal file
32
test/lib/Makefile
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
SRCDIR=../../src
|
||||||
|
|
||||||
|
build: testlib.cmxa
|
||||||
|
|
||||||
|
TESTS :=
|
||||||
|
include ../Makefile.shared
|
||||||
|
|
||||||
|
SOURCE_DIRECTORIES := ${NODE_SOURCE_DIRECTORIES} ../lib
|
||||||
|
|
||||||
|
PACKAGES := \
|
||||||
|
${NODE_PACKAGES} \
|
||||||
|
kaputt \
|
||||||
|
|
||||||
|
OPENED_MODULES := ${NODE_OPENED_MODULES}
|
||||||
|
|
||||||
|
TESTLIB_INTFS := \
|
||||||
|
process.mli \
|
||||||
|
test.mli \
|
||||||
|
assert.mli \
|
||||||
|
node_helpers.mli \
|
||||||
|
|
||||||
|
TESTLIB_IMPLS := \
|
||||||
|
process.ml \
|
||||||
|
test.ml \
|
||||||
|
assert.ml \
|
||||||
|
node_helpers.ml \
|
||||||
|
|
||||||
|
${TESTLIB_IMPLS:.ml=.cmx} ${TESTLIB_INTFS:.mli=.cmi}: TARGET="(testlib.cmxa)"
|
||||||
|
testlib.cmxa: ${TESTLIB_IMPLS:.ml=.cmx}
|
||||||
|
@echo LINK $(notdir $@)
|
||||||
|
@${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ $^
|
@ -7,24 +7,31 @@
|
|||||||
(* *)
|
(* *)
|
||||||
(**************************************************************************)
|
(**************************************************************************)
|
||||||
|
|
||||||
|
open Error_monad
|
||||||
open Hash
|
open Hash
|
||||||
open Kaputt.Abbreviations
|
|
||||||
|
|
||||||
include Kaputt.Assertion
|
include Kaputt.Assertion
|
||||||
|
|
||||||
|
module Assert = Kaputt.Abbreviations.Assert
|
||||||
|
|
||||||
let format_msg = function None -> None | Some msg -> Some (msg ^ "\n")
|
let format_msg = function None -> None | Some msg -> Some (msg ^ "\n")
|
||||||
|
|
||||||
let is_error ?(msg="") x =
|
let is_error ?(msg="") = function
|
||||||
match x with
|
|
||||||
| Error _ -> ()
|
| Error _ -> ()
|
||||||
| Ok _ -> fail "Error _" "Ok _" msg
|
| Ok _ -> fail "Error _" "Ok _" msg
|
||||||
|
|
||||||
let is_ok ?(msg="") x =
|
let contain_error ?(msg="") ~f = function
|
||||||
match x with
|
| Ok _ -> fail "Error _" "Ok _" msg
|
||||||
|
| Error error when not (List.exists f error) ->
|
||||||
|
let error_str = Format.asprintf "%a" pp_print_error error in
|
||||||
|
fail "" error_str msg
|
||||||
|
| _ -> ()
|
||||||
|
|
||||||
|
let is_ok ?(msg="") = function
|
||||||
| Ok _ -> ()
|
| Ok _ -> ()
|
||||||
| Error _ -> fail "Ok _" "Error _" msg
|
| Error _ -> fail "Ok _" "Error _" msg
|
||||||
|
|
||||||
let equal_persist_list ?msg l1 l2 =
|
let equal_string_list_list ?msg l1 l2 =
|
||||||
let msg = format_msg msg in
|
let msg = format_msg msg in
|
||||||
let pr_persist l =
|
let pr_persist l =
|
||||||
let res =
|
let res =
|
||||||
@ -71,38 +78,12 @@ let equal_block_map ?msg ~eq map1 map2 =
|
|||||||
(fun (h1, _) -> Block_hash.to_string h1)
|
(fun (h1, _) -> Block_hash.to_string h1)
|
||||||
b1 b2
|
b1 b2
|
||||||
|
|
||||||
let equal_operation ?msg op1 op2 =
|
|
||||||
let msg = format_msg msg in
|
|
||||||
let eq op1 op2 =
|
|
||||||
match op1, op2 with
|
|
||||||
| None, None -> true
|
|
||||||
| Some op1, Some op2 ->
|
|
||||||
Store.Operation.equal op1 op2
|
|
||||||
| _ -> false in
|
|
||||||
let prn = function
|
|
||||||
| None -> "none"
|
|
||||||
| Some op -> Hash.Operation_hash.to_hex (Store.Operation.hash op) in
|
|
||||||
Assert.equal ?msg ~prn ~eq op1 op2
|
|
||||||
|
|
||||||
let equal_block ?msg st1 st2 =
|
|
||||||
let msg = format_msg msg in
|
|
||||||
let eq st1 st2 =
|
|
||||||
match st1, st2 with
|
|
||||||
| None, None -> true
|
|
||||||
| Some st1, Some st2 -> Store.Block_header.equal st1 st2
|
|
||||||
| _ -> false in
|
|
||||||
let prn = function
|
|
||||||
| None -> "none"
|
|
||||||
| Some st ->
|
|
||||||
Hash.Block_hash.to_hex (Store.Block_header.hash st) in
|
|
||||||
Assert.equal ?msg ~prn ~eq st1 st2
|
|
||||||
|
|
||||||
let equal_result ?msg r1 r2 ~equal_ok ~equal_err =
|
let equal_result ?msg r1 r2 ~equal_ok ~equal_err =
|
||||||
let msg = format_msg msg in
|
let msg = format_msg msg in
|
||||||
match r1, r2 with
|
match r1, r2 with
|
||||||
| Ok r1, Ok r2 -> equal_ok ?msg r1 r2
|
| Ok r1, Ok r2 -> equal_ok ?msg r1 r2
|
||||||
| Error e1, Error e2 -> equal_err ?msg e1 e2
|
| Error e1, Error e2 -> equal_err ?msg e1 e2
|
||||||
| Ok r, Error e | Error e, Ok r ->
|
| Ok _, Error _ | Error _, Ok _ ->
|
||||||
Assert.fail_msg "Results are not the same"
|
Assert.fail_msg "Results are not the same"
|
||||||
|
|
||||||
let equal_exn ?msg exn1 exn2 =
|
let equal_exn ?msg exn1 exn2 =
|
||||||
|
@ -9,24 +9,27 @@
|
|||||||
|
|
||||||
open Hash
|
open Hash
|
||||||
open Error_monad
|
open Error_monad
|
||||||
include (module type of struct include Kaputt.Assertion end)
|
include module type of Kaputt.Assertion
|
||||||
|
|
||||||
|
val format_msg : string option -> string option
|
||||||
|
|
||||||
val is_ok : ?msg:string -> 'a tzresult -> unit
|
val is_ok : ?msg:string -> 'a tzresult -> unit
|
||||||
val is_error : ?msg:string -> 'a tzresult -> unit
|
val is_error : ?msg:string -> 'a tzresult -> unit
|
||||||
|
val contain_error : ?msg:string -> f:(error -> bool) -> 'a tzresult -> unit
|
||||||
|
|
||||||
val fail_msg : ('a, Format.formatter, unit, 'b) format4 -> 'a
|
val fail_msg : ('a, Format.formatter, unit, 'b) format4 -> 'a
|
||||||
|
|
||||||
val fail : string -> string -> ('a, Format.formatter, unit, 'b) format4 -> 'a
|
val fail : string -> string -> ('a, Format.formatter, unit, 'b) format4 -> 'a
|
||||||
|
|
||||||
val equal_persist_list :
|
|
||||||
?msg:string -> Persist.key list -> Persist.key list -> unit
|
|
||||||
|
|
||||||
val equal_block_hash_list :
|
val equal_block_hash_list :
|
||||||
?msg:string -> Block_hash.t list -> Block_hash.t list -> unit
|
?msg:string -> Block_hash.t list -> Block_hash.t list -> unit
|
||||||
|
|
||||||
val equal_string_list :
|
val equal_string_list :
|
||||||
?msg:string -> string list -> string list -> unit
|
?msg:string -> string list -> string list -> unit
|
||||||
|
|
||||||
|
val equal_string_list_list :
|
||||||
|
?msg:string -> string list list -> string list list -> unit
|
||||||
|
|
||||||
val equal_string_option : ?msg:string -> string option -> string option -> unit
|
val equal_string_option : ?msg:string -> string option -> string option -> unit
|
||||||
|
|
||||||
val equal_error_monad :
|
val equal_error_monad :
|
||||||
@ -39,18 +42,6 @@ val equal_block_map :
|
|||||||
?msg:string -> eq:('a -> 'a -> bool) ->
|
?msg:string -> eq:('a -> 'a -> bool) ->
|
||||||
'a Block_hash.Map.t -> 'a Block_hash.Map.t -> unit
|
'a Block_hash.Map.t -> 'a Block_hash.Map.t -> unit
|
||||||
|
|
||||||
val equal_operation :
|
|
||||||
?msg:string ->
|
|
||||||
State.Operation.t option ->
|
|
||||||
State.Operation.t option ->
|
|
||||||
unit
|
|
||||||
|
|
||||||
val equal_block :
|
|
||||||
?msg:string ->
|
|
||||||
Store.Block_header.t option ->
|
|
||||||
Store.Block_header.t option ->
|
|
||||||
unit
|
|
||||||
|
|
||||||
val equal_result :
|
val equal_result :
|
||||||
?msg:string ->
|
?msg:string ->
|
||||||
('a, 'b) result ->
|
('a, 'b) result ->
|
||||||
|
70
test/lib/node_helpers.ml
Normal file
70
test/lib/node_helpers.ml
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
(**************************************************************************)
|
||||||
|
(* *)
|
||||||
|
(* Copyright (c) 2014 - 2016. *)
|
||||||
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
||||||
|
(* *)
|
||||||
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
||||||
|
(* *)
|
||||||
|
(**************************************************************************)
|
||||||
|
|
||||||
|
exception Node_exited_prematurely
|
||||||
|
|
||||||
|
let handle_error res log_file_name =
|
||||||
|
match res with
|
||||||
|
| 0, _ ->
|
||||||
|
()
|
||||||
|
| pid, Unix.WEXITED x ->
|
||||||
|
Printf.eprintf "Wait: %d, exit %d\n\nDumping log:\n\n%!" pid x ;
|
||||||
|
ignore (Sys.command (Printf.sprintf "cat %s" log_file_name) : int) ;
|
||||||
|
raise Node_exited_prematurely
|
||||||
|
| pid, Unix.WSIGNALED x ->
|
||||||
|
Printf.eprintf "Wait: %d, signaled %d\n\nDumping log:\n\n%!" pid x ;
|
||||||
|
ignore (Sys.command (Printf.sprintf "cat %s" log_file_name) : int) ;
|
||||||
|
raise Node_exited_prematurely
|
||||||
|
| pid, Unix.WSTOPPED x ->
|
||||||
|
Printf.eprintf "Wait: %d, stopped %d\n\nDumping log:\n\n%!" pid x ;
|
||||||
|
ignore (Sys.command (Printf.sprintf "cat %s" log_file_name) : int) ;
|
||||||
|
raise Node_exited_prematurely
|
||||||
|
|
||||||
|
|
||||||
|
let fork_node ?(timeout = 4) ?(port = 18732) ?sandbox () =
|
||||||
|
let data_dir =
|
||||||
|
Printf.sprintf
|
||||||
|
"%s/tezos_node_%6X"
|
||||||
|
(Filename.get_temp_dir_name ())
|
||||||
|
(Random.int 0xFF_FF_FF) in
|
||||||
|
let log_file_name, log_file =
|
||||||
|
Filename.open_temp_file "tezos_node_" ".log" in
|
||||||
|
let log_fd = Unix.descr_of_out_channel log_file in
|
||||||
|
let null_fd = Unix.(openfile "/dev/null" [O_RDONLY] 0o644) in
|
||||||
|
let pid =
|
||||||
|
Unix.create_process
|
||||||
|
Filename.(concat (dirname (Sys.getcwd ())) "tezos-node")
|
||||||
|
[| "tezos-node" ;
|
||||||
|
"run" ;
|
||||||
|
"--data-dir"; data_dir ;
|
||||||
|
(match sandbox with
|
||||||
|
| None -> "--sandbox"
|
||||||
|
| Some path -> "--sandbox=" ^ path);
|
||||||
|
"--rpc-addr"; "[::]:" ^ string_of_int port |]
|
||||||
|
null_fd log_fd log_fd in
|
||||||
|
Printf.printf "Created node, pid: %d, log: %s\n%!" pid log_file_name ;
|
||||||
|
Printf.printf "Waiting %d seconds for its initialisation\n%!" timeout ;
|
||||||
|
Unix.sleep timeout ;
|
||||||
|
match Unix.waitpid [Unix.WNOHANG] pid with
|
||||||
|
| 0, _ ->
|
||||||
|
Pervasives.at_exit begin fun () ->
|
||||||
|
begin
|
||||||
|
match Unix.waitpid [Unix.WNOHANG] pid with
|
||||||
|
| 0, _ ->
|
||||||
|
Unix.kill pid Sys.sigkill ;
|
||||||
|
Unix.sleep 1
|
||||||
|
| res ->
|
||||||
|
handle_error res log_file_name
|
||||||
|
end ;
|
||||||
|
ignore (Sys.command (Printf.sprintf "rm -fr \"%s\"" data_dir))
|
||||||
|
end ;
|
||||||
|
pid
|
||||||
|
| res ->
|
||||||
|
handle_error res log_file_name ;
|
||||||
|
0
|
16
test/lib/node_helpers.mli
Normal file
16
test/lib/node_helpers.mli
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
(**************************************************************************)
|
||||||
|
(* *)
|
||||||
|
(* Copyright (c) 2014 - 2016. *)
|
||||||
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
||||||
|
(* *)
|
||||||
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
||||||
|
(* *)
|
||||||
|
(**************************************************************************)
|
||||||
|
|
||||||
|
val fork_node:
|
||||||
|
?timeout:int -> ?port:int -> ?sandbox:string -> unit -> int
|
||||||
|
(** [fork_node ()] forks a node in sandbox mode listening to rpc on
|
||||||
|
`localhost:port` (where the default port is 18732) and returns the
|
||||||
|
PID of the forked process. It waits `timeout` seconds (default 4)
|
||||||
|
before to return and it may fails with an exception whenever the node
|
||||||
|
died during the wait. *)
|
@ -74,3 +74,4 @@ let rec wait processes =
|
|||||||
(fun () -> Lwt.join processes)
|
(fun () -> Lwt.join processes)
|
||||||
(fun _ -> Lwt.return_unit) >>= fun () ->
|
(fun _ -> Lwt.return_unit) >>= fun () ->
|
||||||
Pervasives.exit 2)
|
Pervasives.exit 2)
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
(* *)
|
(* *)
|
||||||
(**************************************************************************)
|
(**************************************************************************)
|
||||||
|
|
||||||
open Kaputt.Abbreviations
|
module Test = Kaputt.Abbreviations.Test
|
||||||
|
|
||||||
let keep_dir = try ignore (Sys.getenv "KEEPDIR") ; true with _ -> false
|
let keep_dir = try ignore (Sys.getenv "KEEPDIR") ; true with _ -> false
|
||||||
|
|
||||||
|
17
test/p2p/.merlin
Normal file
17
test/p2p/.merlin
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
REC
|
||||||
|
S .
|
||||||
|
B .
|
||||||
|
S ../../src/minutils
|
||||||
|
B ../../src/minutils
|
||||||
|
S ../../src/utils
|
||||||
|
B ../../src/utils
|
||||||
|
S ../../src/node/net
|
||||||
|
B ../../src/node/net
|
||||||
|
S ../lib
|
||||||
|
B ../lib
|
||||||
|
FLG -open Error_monad -open Hash -open Utils
|
||||||
|
FLG -w -40
|
||||||
|
PKG lwt
|
||||||
|
PKG sodium
|
||||||
|
PKG kaputt
|
||||||
|
PKG ipaddr
|
77
test/p2p/Makefile
Normal file
77
test/p2p/Makefile
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
|
||||||
|
SRCDIR=../../src
|
||||||
|
|
||||||
|
TESTS := \
|
||||||
|
p2p-connection \
|
||||||
|
p2p-connection-pool \
|
||||||
|
p2p-io-scheduler \
|
||||||
|
|
||||||
|
include ../Makefile.shared
|
||||||
|
|
||||||
|
SOURCE_DIRECTORIES := ${NODE_SOURCE_DIRECTORIES} ../lib
|
||||||
|
|
||||||
|
LIB := ${MINUTILSLIB} ${UTILSLIB} ${COMPILERLIB} ${NODELIB} ${TESTLIB}
|
||||||
|
|
||||||
|
PACKAGES := \
|
||||||
|
${NODE_PACKAGES} \
|
||||||
|
kaputt \
|
||||||
|
|
||||||
|
OPENED_MODULES := ${NODE_OPENED_MODULES}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## P2p_connection
|
||||||
|
|
||||||
|
.PHONY:run-test-p2p-connection
|
||||||
|
run-test-p2p-connection:
|
||||||
|
@echo
|
||||||
|
./test-p2p-connection
|
||||||
|
|
||||||
|
TEST_CONNECTION_IMPLS := \
|
||||||
|
test_p2p_connection.ml
|
||||||
|
|
||||||
|
test-p2p-connection: ${LIB} ${TEST_CONNECTION_IMPLS:.ml=.cmx}
|
||||||
|
@echo LINK $(notdir $@)
|
||||||
|
@${OCAMLOPT} -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
||||||
|
|
||||||
|
clean::
|
||||||
|
rm -f test-p2p-connection
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## P2p_connection_pool
|
||||||
|
|
||||||
|
.PHONY:run-test-p2p-connection-pool
|
||||||
|
run-test-p2p-connection-pool:
|
||||||
|
@echo
|
||||||
|
./test-p2p-connection-pool --clients 10 --repeat 5
|
||||||
|
|
||||||
|
TEST_CONNECTION_POOL_IMPLS := \
|
||||||
|
test_p2p_connection_pool.ml
|
||||||
|
|
||||||
|
test-p2p-connection-pool: ${LIB} ${TEST_CONNECTION_POOL_IMPLS:.ml=.cmx}
|
||||||
|
@echo LINK $(notdir $@)
|
||||||
|
@${OCAMLOPT} -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
||||||
|
|
||||||
|
clean::
|
||||||
|
rm -f test-p2p-connection-pool
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## P2p_io_scheduler
|
||||||
|
|
||||||
|
.PHONY:run-test-p2p-io-scheduler
|
||||||
|
run-test-p2p-io-scheduler:
|
||||||
|
@echo
|
||||||
|
./test-p2p-io-scheduler \
|
||||||
|
--delay 5 --clients 8 \
|
||||||
|
--max-upload-speed $$((1 << 18)) \
|
||||||
|
--max-download-speed $$((1 << 20))
|
||||||
|
|
||||||
|
TEST_IO_SCHEDULER_IMPLS := \
|
||||||
|
test_p2p_io_scheduler.ml
|
||||||
|
|
||||||
|
test-p2p-io-scheduler: ${LIB} ${TEST_IO_SCHEDULER_IMPLS:.ml=.cmx}
|
||||||
|
@echo LINK $(notdir $@)
|
||||||
|
@${OCAMLOPT} -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
||||||
|
|
||||||
|
clean::
|
||||||
|
rm -f test-p2p-io-scheduler
|
||||||
|
|
@ -99,7 +99,7 @@ let bytes_encoding = Data_encoding.Variable.bytes
|
|||||||
let server main_socket =
|
let server main_socket =
|
||||||
let sched = P2p_io_scheduler.create ~read_buffer_size:(1 lsl 12) () in
|
let sched = P2p_io_scheduler.create ~read_buffer_size:(1 lsl 12) () in
|
||||||
(* Low-level test. *)
|
(* Low-level test. *)
|
||||||
raw_accept sched main_socket >>= fun (fd, point) ->
|
raw_accept sched main_socket >>= fun (fd, _point) ->
|
||||||
lwt_log_notice "Low_level" >>= fun () ->
|
lwt_log_notice "Low_level" >>= fun () ->
|
||||||
P2p_io_scheduler.write fd simple_msg >>=? fun () ->
|
P2p_io_scheduler.write fd simple_msg >>=? fun () ->
|
||||||
P2p_io_scheduler.close fd >>=? fun _ ->
|
P2p_io_scheduler.close fd >>=? fun _ ->
|
||||||
@ -112,26 +112,26 @@ let server main_socket =
|
|||||||
P2p_connection.kick auth_fd >>= fun () ->
|
P2p_connection.kick auth_fd >>= fun () ->
|
||||||
lwt_log_notice "Kick OK" >>= fun () ->
|
lwt_log_notice "Kick OK" >>= fun () ->
|
||||||
(* Let's be rejected. *)
|
(* Let's be rejected. *)
|
||||||
accept sched main_socket >>=? fun (info, auth_fd) ->
|
accept sched main_socket >>=? fun (_info, auth_fd) ->
|
||||||
P2p_connection.accept auth_fd bytes_encoding >>= fun conn ->
|
P2p_connection.accept auth_fd bytes_encoding >>= fun conn ->
|
||||||
assert (is_rejected conn) ;
|
assert (is_rejected conn) ;
|
||||||
lwt_log_notice "Kicked OK" >>= fun () ->
|
lwt_log_notice "Kicked OK" >>= fun () ->
|
||||||
(* Accept and send a single message. *)
|
(* Accept and send a single message. *)
|
||||||
accept sched main_socket >>=? fun (info, auth_fd) ->
|
accept sched main_socket >>=? fun (_info, auth_fd) ->
|
||||||
lwt_log_notice "Single" >>= fun () ->
|
lwt_log_notice "Single" >>= fun () ->
|
||||||
P2p_connection.accept auth_fd bytes_encoding >>=? fun conn ->
|
P2p_connection.accept auth_fd bytes_encoding >>=? fun conn ->
|
||||||
P2p_connection.write_sync conn simple_msg >>=? fun () ->
|
P2p_connection.write_sync conn simple_msg >>=? fun () ->
|
||||||
P2p_connection.close conn >>= fun _stat ->
|
P2p_connection.close conn >>= fun _stat ->
|
||||||
lwt_log_notice "Single OK" >>= fun () ->
|
lwt_log_notice "Single OK" >>= fun () ->
|
||||||
(* Accept and send a single message, while the client expected 2. *)
|
(* Accept and send a single message, while the client expected 2. *)
|
||||||
accept sched main_socket >>=? fun (info, auth_fd) ->
|
accept sched main_socket >>=? fun (_info, auth_fd) ->
|
||||||
lwt_log_notice "Early close (read)" >>= fun () ->
|
lwt_log_notice "Early close (read)" >>= fun () ->
|
||||||
P2p_connection.accept auth_fd bytes_encoding >>=? fun conn ->
|
P2p_connection.accept auth_fd bytes_encoding >>=? fun conn ->
|
||||||
P2p_connection.write_sync conn simple_msg >>=? fun () ->
|
P2p_connection.write_sync conn simple_msg >>=? fun () ->
|
||||||
P2p_connection.close conn >>= fun _stat ->
|
P2p_connection.close conn >>= fun _stat ->
|
||||||
lwt_log_notice "Early close (read) OK" >>= fun () ->
|
lwt_log_notice "Early close (read) OK" >>= fun () ->
|
||||||
(* Accept and wait for the client to close the connection. *)
|
(* Accept and wait for the client to close the connection. *)
|
||||||
accept sched main_socket >>=? fun (info, auth_fd) ->
|
accept sched main_socket >>=? fun (_info, auth_fd) ->
|
||||||
lwt_log_notice "Early close (write)" >>= fun () ->
|
lwt_log_notice "Early close (write)" >>= fun () ->
|
||||||
P2p_connection.accept auth_fd bytes_encoding >>=? fun conn ->
|
P2p_connection.accept auth_fd bytes_encoding >>=? fun conn ->
|
||||||
P2p_connection.close conn >>= fun _stat ->
|
P2p_connection.close conn >>= fun _stat ->
|
||||||
@ -161,14 +161,14 @@ let client addr port =
|
|||||||
(* let's exchange a simple message. *)
|
(* let's exchange a simple message. *)
|
||||||
connect sched addr port id2 >>=? fun auth_fd ->
|
connect sched addr port id2 >>=? fun auth_fd ->
|
||||||
P2p_connection.accept auth_fd bytes_encoding >>=? fun conn ->
|
P2p_connection.accept auth_fd bytes_encoding >>=? fun conn ->
|
||||||
P2p_connection.read conn >>=? fun (msg_size, msg) ->
|
P2p_connection.read conn >>=? fun (_msg_size, msg) ->
|
||||||
assert (MBytes.compare simple_msg msg = 0) ;
|
assert (MBytes.compare simple_msg msg = 0) ;
|
||||||
P2p_connection.close conn >>= fun _stat ->
|
P2p_connection.close conn >>= fun _stat ->
|
||||||
lwt_log_notice "Simple OK" >>= fun () ->
|
lwt_log_notice "Simple OK" >>= fun () ->
|
||||||
(* let's detect a closed connection on `read`. *)
|
(* let's detect a closed connection on `read`. *)
|
||||||
connect sched addr port id2 >>=? fun auth_fd ->
|
connect sched addr port id2 >>=? fun auth_fd ->
|
||||||
P2p_connection.accept auth_fd bytes_encoding >>=? fun conn ->
|
P2p_connection.accept auth_fd bytes_encoding >>=? fun conn ->
|
||||||
P2p_connection.read conn >>=? fun (msg_size, msg) ->
|
P2p_connection.read conn >>=? fun (_msg_size, msg) ->
|
||||||
assert (MBytes.compare simple_msg msg = 0) ;
|
assert (MBytes.compare simple_msg msg = 0) ;
|
||||||
P2p_connection.read conn >>= fun msg ->
|
P2p_connection.read conn >>= fun msg ->
|
||||||
assert (is_connection_closed msg) ;
|
assert (is_connection_closed msg) ;
|
@ -190,7 +190,7 @@ let spec = Arg.[
|
|||||||
let main () =
|
let main () =
|
||||||
let open Utils in
|
let open Utils in
|
||||||
Logging.init Stderr >>= fun () ->
|
Logging.init Stderr >>= fun () ->
|
||||||
let anon_fun num_peers = raise (Arg.Bad "No anonymous argument.") in
|
let anon_fun _num_peers = raise (Arg.Bad "No anonymous argument.") in
|
||||||
let usage_msg = "Usage: %s <num_peers>.\nArguments are:" in
|
let usage_msg = "Usage: %s <num_peers>.\nArguments are:" in
|
||||||
Arg.parse spec anon_fun usage_msg ;
|
Arg.parse spec anon_fun usage_msg ;
|
||||||
let ports = !port -- (!port + !clients - 1) in
|
let ports = !port -- (!port + !clients - 1) in
|
@ -34,7 +34,7 @@ let rec listen ?port addr =
|
|||||||
end
|
end
|
||||||
|
|
||||||
let accept main_socket =
|
let accept main_socket =
|
||||||
Lwt_unix.accept main_socket >>= fun (fd, sockaddr) ->
|
Lwt_unix.accept main_socket >>= fun (fd, _sockaddr) ->
|
||||||
return fd
|
return fd
|
||||||
|
|
||||||
let rec accept_n main_socket n =
|
let rec accept_n main_socket n =
|
||||||
@ -121,7 +121,7 @@ let rec send conn nb_simple_msgs =
|
|||||||
P2p_io_scheduler.write conn msg >>=? fun () ->
|
P2p_io_scheduler.write conn msg >>=? fun () ->
|
||||||
send conn nb_simple_msgs
|
send conn nb_simple_msgs
|
||||||
|
|
||||||
let client ?max_upload_speed ?write_queue_size addr port time n =
|
let client ?max_upload_speed ?write_queue_size addr port time _n =
|
||||||
let sched =
|
let sched =
|
||||||
P2p_io_scheduler.create
|
P2p_io_scheduler.create
|
||||||
?max_upload_speed ?write_queue_size ~read_buffer_size:(1 lsl 12) () in
|
?max_upload_speed ?write_queue_size ~read_buffer_size:(1 lsl 12) () in
|
||||||
@ -215,7 +215,7 @@ let spec =
|
|||||||
]
|
]
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
let anon_fun num_peers = raise (Arg.Bad "No anonymous argument.") in
|
let anon_fun _num_peers = raise (Arg.Bad "No anonymous argument.") in
|
||||||
let usage_msg = "Usage: %s <num_peers>.\nArguments are:" in
|
let usage_msg = "Usage: %s <num_peers>.\nArguments are:" in
|
||||||
Arg.parse spec anon_fun usage_msg
|
Arg.parse spec anon_fun usage_msg
|
||||||
|
|
23
test/shell/.merlin
Normal file
23
test/shell/.merlin
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
REC
|
||||||
|
S .
|
||||||
|
B .
|
||||||
|
S ../../src/minutils
|
||||||
|
B ../../src/minutils
|
||||||
|
S ../../src/utils
|
||||||
|
B ../../src/utils
|
||||||
|
S ../../src/node/net
|
||||||
|
B ../../src/node/net
|
||||||
|
S ../../src/node/db
|
||||||
|
B ../../src/node/db
|
||||||
|
S ../../src/node/updater
|
||||||
|
B ../../src/node/updater
|
||||||
|
S ../../src/node/shell
|
||||||
|
B ../../src/node/shell
|
||||||
|
S ../lib
|
||||||
|
B ../lib
|
||||||
|
FLG -open Error_monad -open Hash -open Utils
|
||||||
|
FLG -w -40
|
||||||
|
PKG lwt
|
||||||
|
PKG sodium
|
||||||
|
PKG kaputt
|
||||||
|
PKG ipaddr
|
74
test/shell/Makefile
Normal file
74
test/shell/Makefile
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
|
||||||
|
SRCDIR=../../src
|
||||||
|
|
||||||
|
TESTS := \
|
||||||
|
store \
|
||||||
|
state \
|
||||||
|
context \
|
||||||
|
|
||||||
|
include ../Makefile.shared
|
||||||
|
|
||||||
|
SOURCE_DIRECTORIES := ${NODE_SOURCE_DIRECTORIES} ../lib
|
||||||
|
|
||||||
|
LIB := ${MINUTILSLIB} ${UTILSLIB} ${COMPILERLIB} ${NODELIB} ${EMBEDDED_NODE_PROTOCOLS} ${TESTLIB}
|
||||||
|
|
||||||
|
PACKAGES := \
|
||||||
|
${NODE_PACKAGES} \
|
||||||
|
kaputt \
|
||||||
|
|
||||||
|
OPENED_MODULES := ${NODE_OPENED_MODULES}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## Store
|
||||||
|
|
||||||
|
.PHONY:run-test-store
|
||||||
|
run-test-store:
|
||||||
|
@echo
|
||||||
|
./test-store
|
||||||
|
|
||||||
|
TEST_STORE_IMPLS := \
|
||||||
|
test_store.ml
|
||||||
|
|
||||||
|
test-store: ${LIB} ${TEST_STORE_IMPLS:.ml=.cmx}
|
||||||
|
@echo LINK $(notdir $@)
|
||||||
|
@${OCAMLOPT} -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
||||||
|
|
||||||
|
clean::
|
||||||
|
rm -f test-store
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## State
|
||||||
|
|
||||||
|
.PHONY:run-test-state
|
||||||
|
run-test-state:
|
||||||
|
@echo
|
||||||
|
./test-state
|
||||||
|
|
||||||
|
TEST_STATE_IMPLS := \
|
||||||
|
test_state.ml
|
||||||
|
|
||||||
|
test-state: ${LIB} ${TEST_STATE_IMPLS:.ml=.cmx}
|
||||||
|
@echo LINK $(notdir $@)
|
||||||
|
@${OCAMLOPT} -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
||||||
|
|
||||||
|
clean::
|
||||||
|
rm -f test-state
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## Context
|
||||||
|
|
||||||
|
.PHONY:run-test-context
|
||||||
|
run-test-context:
|
||||||
|
@echo
|
||||||
|
./test-context
|
||||||
|
|
||||||
|
TEST_CONTEXT_IMPLS := \
|
||||||
|
test_context.ml
|
||||||
|
|
||||||
|
test-context: ${LIB} ${TEST_CONTEXT_IMPLS:.ml=.cmx}
|
||||||
|
@echo LINK $(notdir $@)
|
||||||
|
@${OCAMLOPT} -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
||||||
|
|
||||||
|
clean::
|
||||||
|
rm -f test-context
|
||||||
|
|
@ -178,18 +178,18 @@ let test_list idx =
|
|||||||
set ctxt ["f";] (MBytes.of_string "Avril") >>= fun ctxt ->
|
set ctxt ["f";] (MBytes.of_string "Avril") >>= fun ctxt ->
|
||||||
set ctxt ["g"; "h"] (MBytes.of_string "Avril") >>= fun ctxt ->
|
set ctxt ["g"; "h"] (MBytes.of_string "Avril") >>= fun ctxt ->
|
||||||
list ctxt [[]] >>= fun l ->
|
list ctxt [[]] >>= fun l ->
|
||||||
Assert.equal_persist_list ~msg:__LOC__ [["a"];["f"];["g"]] l ;
|
Assert.equal_string_list_list ~msg:__LOC__ [["a"];["f"];["g"]] l ;
|
||||||
list ctxt [["a"]] >>= fun l ->
|
list ctxt [["a"]] >>= fun l ->
|
||||||
Assert.equal_persist_list
|
Assert.equal_string_list_list
|
||||||
~msg:__LOC__ [["a";"b"]; ["a";"c"]; ["a";"d"]] l ;
|
~msg:__LOC__ [["a";"b"]; ["a";"c"]; ["a";"d"]] l ;
|
||||||
list ctxt [["f"]] >>= fun l ->
|
list ctxt [["f"]] >>= fun l ->
|
||||||
Assert.equal_persist_list ~msg:__LOC__ [] l ;
|
Assert.equal_string_list_list ~msg:__LOC__ [] l ;
|
||||||
list ctxt [["g"]] >>= fun l ->
|
list ctxt [["g"]] >>= fun l ->
|
||||||
Assert.equal_persist_list ~msg:__LOC__ [["g";"h"]] l ;
|
Assert.equal_string_list_list ~msg:__LOC__ [["g";"h"]] l ;
|
||||||
list ctxt [["i"]] >>= fun l ->
|
list ctxt [["i"]] >>= fun l ->
|
||||||
Assert.equal_persist_list ~msg:__LOC__ [] l ;
|
Assert.equal_string_list_list ~msg:__LOC__ [] l ;
|
||||||
list ctxt [["a"];["g"]] >>= fun l ->
|
list ctxt [["a"];["g"]] >>= fun l ->
|
||||||
Assert.equal_persist_list ~msg:__LOC__
|
Assert.equal_string_list_list ~msg:__LOC__
|
||||||
[["a"; "b"]; ["a"; "c"]; ["a"; "d"]; ["g"; "h"]] l ;
|
[["a"; "b"]; ["a"; "c"]; ["a"; "d"]; ["g"; "h"]] l ;
|
||||||
Lwt.return ()
|
Lwt.return ()
|
||||||
|
|
@ -61,7 +61,7 @@ let operation op =
|
|||||||
op,
|
op,
|
||||||
Data_encoding.Binary.to_bytes Store.Operation.encoding op
|
Data_encoding.Binary.to_bytes Store.Operation.encoding op
|
||||||
|
|
||||||
let block state ?(operations = []) pred_hash pred name : Store.Block_header.t =
|
let block _state ?(operations = []) pred_hash pred name : Store.Block_header.t =
|
||||||
let operations =
|
let operations =
|
||||||
Operation_list_list_hash.compute
|
Operation_list_list_hash.compute
|
||||||
[Operation_list_hash.compute operations] in
|
[Operation_list_hash.compute operations] in
|
||||||
@ -74,15 +74,41 @@ let block state ?(operations = []) pred_hash pred name : Store.Block_header.t =
|
|||||||
proto = MBytes.of_string name ;
|
proto = MBytes.of_string name ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let equal_operation ?msg op1 op2 =
|
||||||
|
let msg = Assert.format_msg msg in
|
||||||
|
let eq op1 op2 =
|
||||||
|
match op1, op2 with
|
||||||
|
| None, None -> true
|
||||||
|
| Some op1, Some op2 ->
|
||||||
|
Store.Operation.equal op1 op2
|
||||||
|
| _ -> false in
|
||||||
|
let prn = function
|
||||||
|
| None -> "none"
|
||||||
|
| Some op -> Hash.Operation_hash.to_hex (Store.Operation.hash op) in
|
||||||
|
Assert.equal ?msg ~prn ~eq op1 op2
|
||||||
|
|
||||||
|
let equal_block ?msg st1 st2 =
|
||||||
|
let msg = Assert.format_msg msg in
|
||||||
|
let eq st1 st2 =
|
||||||
|
match st1, st2 with
|
||||||
|
| None, None -> true
|
||||||
|
| Some st1, Some st2 -> Store.Block_header.equal st1 st2
|
||||||
|
| _ -> false in
|
||||||
|
let prn = function
|
||||||
|
| None -> "none"
|
||||||
|
| Some st ->
|
||||||
|
Hash.Block_hash.to_hex (Store.Block_header.hash st) in
|
||||||
|
Assert.equal ?msg ~prn ~eq st1 st2
|
||||||
|
|
||||||
let build_chain state tbl otbl pred names =
|
let build_chain state tbl otbl pred names =
|
||||||
Lwt_list.fold_left_s
|
Lwt_list.fold_left_s
|
||||||
(fun (pred_hash, pred) name ->
|
(fun (pred_hash, pred) name ->
|
||||||
begin
|
begin
|
||||||
let oph, op, bytes = operation name in
|
let oph, op, _bytes = operation name in
|
||||||
State.Operation.store state oph op >>= fun created ->
|
State.Operation.store state oph op >>= fun created ->
|
||||||
Assert.is_true ~msg:__LOC__ created ;
|
Assert.is_true ~msg:__LOC__ created ;
|
||||||
State.Operation.read_opt state oph >>= fun op' ->
|
State.Operation.read_opt state oph >>= fun op' ->
|
||||||
Assert.equal_operation ~msg:__LOC__ (Some op) op' ;
|
equal_operation ~msg:__LOC__ (Some op) op' ;
|
||||||
State.Operation.mark_invalid state oph [] >>= fun store_invalid ->
|
State.Operation.mark_invalid state oph [] >>= fun store_invalid ->
|
||||||
Assert.is_true ~msg:__LOC__ store_invalid ;
|
Assert.is_true ~msg:__LOC__ store_invalid ;
|
||||||
Hashtbl.add otbl name (oph, Error []) ;
|
Hashtbl.add otbl name (oph, Error []) ;
|
||||||
@ -91,7 +117,7 @@ let build_chain state tbl otbl pred names =
|
|||||||
State.Block_header.store state hash block >>= fun created ->
|
State.Block_header.store state hash block >>= fun created ->
|
||||||
Assert.is_true ~msg:__LOC__ created ;
|
Assert.is_true ~msg:__LOC__ created ;
|
||||||
State.Block_header.read_opt state hash >>= fun block' ->
|
State.Block_header.read_opt state hash >>= fun block' ->
|
||||||
Assert.equal_block ~msg:__LOC__ (Some block) block' ;
|
equal_block ~msg:__LOC__ (Some block) block' ;
|
||||||
State.Block_header.mark_invalid state hash [] >>= fun store_invalid ->
|
State.Block_header.mark_invalid state hash [] >>= fun store_invalid ->
|
||||||
Assert.is_true ~msg:__LOC__ store_invalid ;
|
Assert.is_true ~msg:__LOC__ store_invalid ;
|
||||||
Hashtbl.add tbl name (hash, block) ;
|
Hashtbl.add tbl name (hash, block) ;
|
||||||
@ -105,7 +131,7 @@ let build_chain state tbl otbl pred names =
|
|||||||
names >>= fun _ ->
|
names >>= fun _ ->
|
||||||
Lwt.return ()
|
Lwt.return ()
|
||||||
|
|
||||||
let block state ?(operations = []) (pred: State.Valid_block.t) name
|
let block _state ?(operations = []) (pred: State.Valid_block.t) name
|
||||||
: State.Block_header.t =
|
: State.Block_header.t =
|
||||||
let operations =
|
let operations =
|
||||||
Operation_list_list_hash.compute
|
Operation_list_list_hash.compute
|
||||||
@ -122,11 +148,11 @@ let build_valid_chain state tbl vtbl otbl pred names =
|
|||||||
Lwt_list.fold_left_s
|
Lwt_list.fold_left_s
|
||||||
(fun pred name ->
|
(fun pred name ->
|
||||||
begin
|
begin
|
||||||
let oph, op, bytes = operation name in
|
let oph, op, _bytes = operation name in
|
||||||
State.Operation.store state oph op >>= fun created ->
|
State.Operation.store state oph op >>= fun created ->
|
||||||
Assert.is_true ~msg:__LOC__ created ;
|
Assert.is_true ~msg:__LOC__ created ;
|
||||||
State.Operation.read_opt state oph >>= fun op' ->
|
State.Operation.read_opt state oph >>= fun op' ->
|
||||||
Assert.equal_operation ~msg:__LOC__ (Some op) op' ;
|
equal_operation ~msg:__LOC__ (Some op) op' ;
|
||||||
Hashtbl.add otbl name (oph, Ok op) ;
|
Hashtbl.add otbl name (oph, Ok op) ;
|
||||||
let block = block state ~operations:[oph] pred name in
|
let block = block state ~operations:[oph] pred name in
|
||||||
let hash = Store.Block_header.hash block in
|
let hash = Store.Block_header.hash block in
|
||||||
@ -134,7 +160,7 @@ let build_valid_chain state tbl vtbl otbl pred names =
|
|||||||
Assert.is_true ~msg:__LOC__ created ;
|
Assert.is_true ~msg:__LOC__ created ;
|
||||||
State.Operation_list.store_all state hash [[oph]] >>= fun () ->
|
State.Operation_list.store_all state hash [[oph]] >>= fun () ->
|
||||||
State.Block_header.read_opt state hash >>= fun block' ->
|
State.Block_header.read_opt state hash >>= fun block' ->
|
||||||
Assert.equal_block ~msg:__LOC__ (Some block) block' ;
|
equal_block ~msg:__LOC__ (Some block) block' ;
|
||||||
Hashtbl.add tbl name (hash, block) ;
|
Hashtbl.add tbl name (hash, block) ;
|
||||||
Lwt.return (Proto.parse_block block pred.timestamp) >>=? fun block ->
|
Lwt.return (Proto.parse_block block pred.timestamp) >>=? fun block ->
|
||||||
Proto.apply pred.context block [] >>=? fun ctxt ->
|
Proto.apply pred.context block [] >>=? fun ctxt ->
|
||||||
@ -168,10 +194,10 @@ let build_example_tree net =
|
|||||||
let chain = [ "C1" ; "C2" ; "C3" ; "C4" ; "C5" ; "C6" ; "C7" ; "C8" ] in
|
let chain = [ "C1" ; "C2" ; "C3" ; "C4" ; "C5" ; "C6" ; "C7" ; "C8" ] in
|
||||||
build_chain net tbl otbl b7 chain >>= fun () ->
|
build_chain net tbl otbl b7 chain >>= fun () ->
|
||||||
let pending_op = "PP" in
|
let pending_op = "PP" in
|
||||||
let oph, op, bytes = operation pending_op in
|
let oph, op, _bytes = operation pending_op in
|
||||||
State.Operation.store net oph op >>= fun _ ->
|
State.Operation.store net oph op >>= fun _ ->
|
||||||
State.Operation.read_opt net oph >>= fun op' ->
|
State.Operation.read_opt net oph >>= fun op' ->
|
||||||
Assert.equal_operation ~msg:__LOC__ (Some op) op' ;
|
equal_operation ~msg:__LOC__ (Some op) op' ;
|
||||||
Hashtbl.add otbl pending_op (oph, Ok op) ;
|
Hashtbl.add otbl pending_op (oph, Ok op) ;
|
||||||
Lwt.return (tbl, vtbl, otbl)
|
Lwt.return (tbl, vtbl, otbl)
|
||||||
|
|
||||||
@ -221,11 +247,11 @@ let wrap_state_init f base_dir =
|
|||||||
init () >>=? fun state ->
|
init () >>=? fun state ->
|
||||||
State.Net.create state genesis >>= fun net ->
|
State.Net.create state genesis >>= fun net ->
|
||||||
build_example_tree net >>= fun (block, vblock, operation) ->
|
build_example_tree net >>= fun (block, vblock, operation) ->
|
||||||
f { state ; net ; block ; vblock ; operation ; init } >>=? fun s ->
|
f { state ; net ; block ; vblock ; operation ; init } >>=? fun () ->
|
||||||
return ()
|
return ()
|
||||||
end
|
end
|
||||||
|
|
||||||
let test_init (s: state) =
|
let test_init (_ : state) =
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
let test_read_operation (s: state) =
|
let test_read_operation (s: state) =
|
@ -116,7 +116,7 @@ let bh3' =
|
|||||||
let check_block s h b =
|
let check_block s h b =
|
||||||
Block_header.Contents.read_opt (s, h) >>= function
|
Block_header.Contents.read_opt (s, h) >>= function
|
||||||
| Some b' when Store.Block_header.equal b b' -> Lwt.return_unit
|
| Some b' when Store.Block_header.equal b b' -> Lwt.return_unit
|
||||||
| Some b' ->
|
| Some _ ->
|
||||||
Printf.eprintf "Error while reading block %s\n%!" (Block_hash.to_hex h);
|
Printf.eprintf "Error while reading block %s\n%!" (Block_hash.to_hex h);
|
||||||
exit 1
|
exit 1
|
||||||
| None ->
|
| None ->
|
||||||
@ -192,19 +192,19 @@ let test_generic_list (type t)
|
|||||||
Store.store s ["f";] (MBytes.of_string "Avril") >>= fun () ->
|
Store.store s ["f";] (MBytes.of_string "Avril") >>= fun () ->
|
||||||
Store.store s ["g"; "h"] (MBytes.of_string "Avril") >>= fun () ->
|
Store.store s ["g"; "h"] (MBytes.of_string "Avril") >>= fun () ->
|
||||||
list (module Store) s [] >>= fun l ->
|
list (module Store) s [] >>= fun l ->
|
||||||
Assert.equal_persist_list ~msg:__LOC__
|
Assert.equal_string_list_list ~msg:__LOC__
|
||||||
[["a";"b"];["a";"c"];["a";"d";"e"];["f"];["g";"h"]]
|
[["a";"b"];["a";"c"];["a";"d";"e"];["f"];["g";"h"]]
|
||||||
(List.sort compare l) ;
|
(List.sort compare l) ;
|
||||||
list (module Store) s ["a"] >>= fun l ->
|
list (module Store) s ["a"] >>= fun l ->
|
||||||
Assert.equal_persist_list
|
Assert.equal_string_list_list
|
||||||
~msg:__LOC__ [["a";"b"]; ["a";"c"]; ["a";"d";"e"]]
|
~msg:__LOC__ [["a";"b"]; ["a";"c"]; ["a";"d";"e"]]
|
||||||
(List.sort compare l) ;
|
(List.sort compare l) ;
|
||||||
list (module Store) s ["f"] >>= fun l ->
|
list (module Store) s ["f"] >>= fun l ->
|
||||||
Assert.equal_persist_list ~msg:__LOC__ [] l ;
|
Assert.equal_string_list_list ~msg:__LOC__ [] l ;
|
||||||
list (module Store) s ["g"] >>= fun l ->
|
list (module Store) s ["g"] >>= fun l ->
|
||||||
Assert.equal_persist_list ~msg:__LOC__ [["g";"h"]] (List.sort compare l) ;
|
Assert.equal_string_list_list ~msg:__LOC__ [["g";"h"]] (List.sort compare l) ;
|
||||||
list (module Store) s ["i"] >>= fun l ->
|
list (module Store) s ["i"] >>= fun l ->
|
||||||
Assert.equal_persist_list ~msg:__LOC__ [] l ;
|
Assert.equal_string_list_list ~msg:__LOC__ [] l ;
|
||||||
Lwt.return_unit
|
Lwt.return_unit
|
||||||
|
|
||||||
(** HashSet *)
|
(** HashSet *)
|
||||||
@ -291,7 +291,7 @@ let test_single (type t)
|
|||||||
Assert.is_true ~msg:__LOC__ known ;
|
Assert.is_true ~msg:__LOC__ known ;
|
||||||
Single.read_opt s >>= fun v' ->
|
Single.read_opt s >>= fun v' ->
|
||||||
Assert.equal ~msg:__LOC__ (Some v) v' ;
|
Assert.equal ~msg:__LOC__ (Some v) v' ;
|
||||||
Single.remove s >>= fun v' ->
|
Single.remove s >>= fun () ->
|
||||||
Single.known s >>= fun known ->
|
Single.known s >>= fun known ->
|
||||||
Assert.is_false ~msg:__LOC__ known ;
|
Assert.is_false ~msg:__LOC__ known ;
|
||||||
Single.read_opt s >>= fun v' ->
|
Single.read_opt s >>= fun v' ->
|
||||||
@ -355,8 +355,9 @@ let test_subblock s =
|
|||||||
and v2 = (12, "Beurk.") in
|
and v2 = (12, "Beurk.") in
|
||||||
SubBlocksMap.store s bh1 v1 >>= fun () ->
|
SubBlocksMap.store s bh1 v1 >>= fun () ->
|
||||||
SubBlocksMap.store s bh2 v2 >>= fun () ->
|
SubBlocksMap.store s bh2 v2 >>= fun () ->
|
||||||
SubBlocksMap.read_opt s bh1 >>= fun v1' ->
|
|
||||||
SubBlocksMap.known s bh1 >>= fun known ->
|
SubBlocksMap.known s bh1 >>= fun known ->
|
||||||
|
SubBlocksMap.read_opt s bh1 >>= fun v1' ->
|
||||||
|
Assert.equal ~msg:__LOC__ (Some v1) v1' ;
|
||||||
Assert.is_true ~msg:__LOC__ known ;
|
Assert.is_true ~msg:__LOC__ known ;
|
||||||
let map =
|
let map =
|
||||||
Block_hash.Map.empty
|
Block_hash.Map.empty
|
@ -1,212 +0,0 @@
|
|||||||
(**************************************************************************)
|
|
||||||
(* *)
|
|
||||||
(* Copyright (c) 2014 - 2016. *)
|
|
||||||
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
||||||
(* *)
|
|
||||||
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
||||||
(* *)
|
|
||||||
(**************************************************************************)
|
|
||||||
|
|
||||||
open Client_embedded_proto_alpha
|
|
||||||
open Client_alpha
|
|
||||||
open Tezos_context
|
|
||||||
open Error_monad
|
|
||||||
open Hash
|
|
||||||
|
|
||||||
let () =
|
|
||||||
Random.self_init () ;
|
|
||||||
Unix.chdir (Filename.dirname Sys.executable_name)
|
|
||||||
|
|
||||||
let cctxt =
|
|
||||||
let log channel msg = match channel with
|
|
||||||
| "stdout" ->
|
|
||||||
print_endline msg ;
|
|
||||||
Lwt.return ()
|
|
||||||
| "stderr" ->
|
|
||||||
prerr_endline msg ;
|
|
||||||
Lwt.return ()
|
|
||||||
| _ -> Lwt.return () in
|
|
||||||
Client_commands.make_context log
|
|
||||||
|
|
||||||
let should_fail f t =
|
|
||||||
t >>= function
|
|
||||||
| Ok _ -> failwith "Expected error found success."
|
|
||||||
| Error error ->
|
|
||||||
if not (List.exists f error) then
|
|
||||||
failwith "@[<v 2>Unexpected error@ %a@]" pp_print_error error
|
|
||||||
else
|
|
||||||
return ()
|
|
||||||
|
|
||||||
let fork_node () =
|
|
||||||
let init_timeout = 4 in
|
|
||||||
let data_dir =
|
|
||||||
Printf.sprintf
|
|
||||||
"%s/tezos_node_%6X"
|
|
||||||
(Filename.get_temp_dir_name ())
|
|
||||||
(Random.int 0xFF_FF_FF) in
|
|
||||||
let log_file_name, log_file = Filename.open_temp_file "tezos_node_" ".log" in
|
|
||||||
let log_fd = Unix.descr_of_out_channel log_file in
|
|
||||||
let null_fd = Unix.(openfile "/dev/null" [O_RDONLY] 0o644) in
|
|
||||||
let pid =
|
|
||||||
Unix.create_process
|
|
||||||
Filename.(concat (dirname (Sys.getcwd ())) "tezos-node")
|
|
||||||
[| "tezos-node" ;
|
|
||||||
"run" ;
|
|
||||||
"--data-dir"; data_dir ;
|
|
||||||
"--sandbox"; "./sandbox.json";
|
|
||||||
"--rpc-addr"; "[::]:8732" |]
|
|
||||||
null_fd log_fd log_fd in
|
|
||||||
Printf.printf "Created node, pid: %d, log: %s\n%!" pid log_file_name ;
|
|
||||||
at_exit
|
|
||||||
(fun () ->
|
|
||||||
Unix.kill pid Sys.sigkill;
|
|
||||||
ignore (Sys.command (Printf.sprintf "rm -fr \"%s\"" data_dir))) ;
|
|
||||||
Printf.printf "Waiting %d seconds for its initialisation\n%!" init_timeout;
|
|
||||||
Unix.sleep init_timeout ;
|
|
||||||
match Unix.waitpid [Unix.WNOHANG] pid with
|
|
||||||
| 0, _ -> ()
|
|
||||||
| pid, Unix.WEXITED x -> Printf.eprintf "Wait: %d, exit %d\n%!" pid x
|
|
||||||
| pid, Unix.WSIGNALED x -> Printf.eprintf "Wait: %d, signaled %d\n%!" pid x
|
|
||||||
| pid, Unix.WSTOPPED x -> Printf.eprintf "Wait: %d, stopped %d \n%!" pid x
|
|
||||||
|
|
||||||
type account = {
|
|
||||||
name : string ;
|
|
||||||
secret_key : Sodium.secret Sodium.Sign.key ;
|
|
||||||
public_key : Sodium.public Sodium.Sign.key ;
|
|
||||||
public_key_hash : public_key_hash ;
|
|
||||||
contract : Contract.t ;
|
|
||||||
}
|
|
||||||
|
|
||||||
let genesis_sk =
|
|
||||||
Environment.Ed25519.Secret_key.of_b58check_exn
|
|
||||||
"edskRhxswacLW6jF6ULavDdzwqnKJVS4UcDTNiCyiH6H8ZNnn2pmNviL7pRNz9kRxxaWQFzEQEcZExGHKbwmuaAcoMegj5T99z"
|
|
||||||
|
|
||||||
let bootstrap1_pk =
|
|
||||||
Environment.Ed25519.Public_key.of_b58check_exn
|
|
||||||
"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav"
|
|
||||||
let bootstrap2_pk =
|
|
||||||
Environment.Ed25519.Public_key.of_b58check_exn
|
|
||||||
"edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9"
|
|
||||||
let bootstrap3_pk =
|
|
||||||
Environment.Ed25519.Public_key.of_b58check_exn
|
|
||||||
"edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV"
|
|
||||||
let bootstrap4_pk =
|
|
||||||
Environment.Ed25519.Public_key.of_b58check_exn
|
|
||||||
"edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU"
|
|
||||||
let bootstrap5_pk =
|
|
||||||
Environment.Ed25519.Public_key.of_b58check_exn
|
|
||||||
"edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n"
|
|
||||||
let bootstrap1_sk =
|
|
||||||
Environment.Ed25519.Secret_key.of_b58check_exn
|
|
||||||
"edskRuR1azSfboG86YPTyxrQgosh5zChf5bVDmptqLTb5EuXAm9rsnDYfTKhq7rDQujdn5WWzwUMeV3agaZ6J2vPQT58jJAJPi"
|
|
||||||
let bootstrap2_sk =
|
|
||||||
Environment.Ed25519.Secret_key.of_b58check_exn
|
|
||||||
"edskRkJz4Rw2rM5NtabEWMbbg2bF4b1nfFajaqEuEk4SgU7eeDbym9gVQtBTbYo32WUg2zb5sNBkD1whRN7zX43V9bftBbtaKc"
|
|
||||||
let bootstrap3_sk =
|
|
||||||
Environment.Ed25519.Secret_key.of_b58check_exn
|
|
||||||
"edskS3qsqsNgdjUqeMsVcEwBn8dkZ5iDRz6aF21KhcCtRiAkWBypUSbicccR4Vgqm9UdW2Vabuos6seezqgbXTrmcbLUG4rdAC"
|
|
||||||
let bootstrap4_sk =
|
|
||||||
Environment.Ed25519.Secret_key.of_b58check_exn
|
|
||||||
"edskRg9qcPqaVQa6jXWNMU5p71tseSuR7NzozgqZ9URsVDi81wTyPJdFSBdeakobyHUi4Xgu61jgKRQvkhXrPmEdEUfiqfiJFL"
|
|
||||||
let bootstrap5_sk =
|
|
||||||
Environment.Ed25519.Secret_key.of_b58check_exn
|
|
||||||
"edskS7rLN2Df3nbS1EYvwJbWo4umD7yPM1SUeX7gp1WhCVpMFXjcCyM58xs6xsnTsVqHQmJQ2RxoAjJGedWfvFmjQy6etA3dgZ"
|
|
||||||
|
|
||||||
let switch_protocol () =
|
|
||||||
let fitness =
|
|
||||||
Client_embedded_proto_alpha.Fitness_repr.from_int64 0L in
|
|
||||||
Client_genesis.Client_proto_main.mine cctxt `Genesis
|
|
||||||
(Activate Client_alpha.Client_proto_main.protocol)
|
|
||||||
fitness genesis_sk >>=? fun () ->
|
|
||||||
Lwt_unix.sleep 2.0 >>= fun () ->
|
|
||||||
return ()
|
|
||||||
|
|
||||||
let bootstrap_accounts () =
|
|
||||||
let cpt = ref 0 in
|
|
||||||
Lwt.return
|
|
||||||
(List.map
|
|
||||||
(fun (public_key, secret_key) ->
|
|
||||||
incr cpt ;
|
|
||||||
let name = Printf.sprintf "bootstrap%d" !cpt in
|
|
||||||
let public_key_hash = Environment.Ed25519.Public_key.hash public_key in
|
|
||||||
{ name ; contract = Contract.default_contract public_key_hash;
|
|
||||||
public_key_hash ; public_key ; secret_key })
|
|
||||||
[ bootstrap1_pk, bootstrap1_sk;
|
|
||||||
bootstrap2_pk, bootstrap2_sk;
|
|
||||||
bootstrap3_pk, bootstrap3_sk;
|
|
||||||
bootstrap4_pk, bootstrap4_sk;
|
|
||||||
bootstrap5_pk, bootstrap5_sk; ])
|
|
||||||
|
|
||||||
let create_account name =
|
|
||||||
let secret_key, public_key = Sodium.Sign.random_keypair () in
|
|
||||||
let public_key_hash = Environment.Ed25519.Public_key.hash public_key in
|
|
||||||
let contract = Contract.default_contract public_key_hash in
|
|
||||||
Lwt.return { name ; contract ; public_key_hash ; public_key ; secret_key }
|
|
||||||
|
|
||||||
let transfer ?(block = `Prevalidation) ?(fee = 5L) ~src ~target amount =
|
|
||||||
let fee =
|
|
||||||
let fee = Tez.of_cents fee in
|
|
||||||
Assert.is_some ~msg:__LOC__ fee ;
|
|
||||||
match fee with
|
|
||||||
| Some x -> x
|
|
||||||
| None -> assert false in (* will be captured by the previous assert *)
|
|
||||||
let amount =
|
|
||||||
let amount = Tez.of_cents amount in
|
|
||||||
Assert.is_some ~msg:__LOC__ amount ;
|
|
||||||
match amount with
|
|
||||||
| Some x -> x
|
|
||||||
| None -> assert false in (* will be captured by the previous assert *)
|
|
||||||
Client_proto_context.transfer cctxt
|
|
||||||
block
|
|
||||||
~source:src.contract
|
|
||||||
~src_pk:src.public_key
|
|
||||||
~src_sk:src.secret_key
|
|
||||||
~destination:target.contract
|
|
||||||
~amount ~fee ()
|
|
||||||
|
|
||||||
let check_balance ?(block = `Prevalidation) account expected =
|
|
||||||
Client_proto_rpcs.Context.Contract.balance cctxt.rpc_config
|
|
||||||
block account.contract >>=? fun balance ->
|
|
||||||
let balance = Tez.to_cents balance in
|
|
||||||
Assert.equal_int64 ~msg:__LOC__ expected balance ;
|
|
||||||
return ()
|
|
||||||
|
|
||||||
let mine contract =
|
|
||||||
let block = `Head 0 in
|
|
||||||
Client_proto_rpcs.Context.level cctxt.rpc_config block >>=? fun level ->
|
|
||||||
let seed_nonce = Client_mining_forge.generate_seed_nonce () in
|
|
||||||
Client_mining_forge.forge_block cctxt.rpc_config
|
|
||||||
~timestamp:(Time.now ()) ~seed_nonce ~src_sk:contract.secret_key
|
|
||||||
block ~priority:(`Auto (contract.public_key_hash, None)) () >>=? fun block_hash ->
|
|
||||||
return ()
|
|
||||||
|
|
||||||
let ecoproto_error f = function
|
|
||||||
| Register_client_embedded_proto_alpha.Ecoproto_error errors ->
|
|
||||||
List.exists f errors
|
|
||||||
| _ -> false
|
|
||||||
|
|
||||||
let main () =
|
|
||||||
fork_node () ;
|
|
||||||
switch_protocol () >>=? fun () ->
|
|
||||||
bootstrap_accounts () >>= fun bootstrap_accounts ->
|
|
||||||
let bootstrap = List.hd bootstrap_accounts in
|
|
||||||
create_account "foo" >>= fun foo ->
|
|
||||||
create_account "bar" >>= fun bar ->
|
|
||||||
transfer ~src:bootstrap ~target:foo 1000_00L >>=? fun contracts ->
|
|
||||||
Assert.equal_int ~msg:__LOC__ 0 (List.length contracts) ;
|
|
||||||
transfer ~src:bootstrap ~target:bar 2000_00L >>=? fun contracts ->
|
|
||||||
Assert.equal_int ~msg:__LOC__ 0 (List.length contracts) ;
|
|
||||||
check_balance foo 1000_00L >>=? fun () ->
|
|
||||||
transfer ~src:bar ~target:foo 999_95L >>=? fun contracts ->
|
|
||||||
Assert.equal_int ~msg:__LOC__ 0 (List.length contracts) ;
|
|
||||||
check_balance foo 1999_95L >>=? fun () ->
|
|
||||||
check_balance bar 1000_00L >>=? fun () ->
|
|
||||||
should_fail
|
|
||||||
(ecoproto_error (function Contract.Balance_too_low _ -> true | _ -> false))
|
|
||||||
@@ transfer ~src:bar ~target:foo 1000_00L >>=? fun () ->
|
|
||||||
mine bootstrap
|
|
||||||
|
|
||||||
let tests = [ "main", fun _ -> main () ]
|
|
||||||
|
|
||||||
let () =
|
|
||||||
Test.run "basic." tests
|
|
13
test/utils/.merlin
Normal file
13
test/utils/.merlin
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
REC
|
||||||
|
S .
|
||||||
|
B .
|
||||||
|
S ../../src/minutils
|
||||||
|
B ../../src/minutils
|
||||||
|
S ../../src/utils
|
||||||
|
B ../../src/utils
|
||||||
|
S ../lib
|
||||||
|
B ../lib
|
||||||
|
FLG -open Error_monad -open Hash -open Utils
|
||||||
|
FLG -w -40
|
||||||
|
PKG lwt
|
||||||
|
PKG kaputt
|
73
test/utils/Makefile
Normal file
73
test/utils/Makefile
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
|
||||||
|
SRCDIR=../../src
|
||||||
|
|
||||||
|
TESTS := \
|
||||||
|
merkle \
|
||||||
|
data-encoding \
|
||||||
|
# lwt-pipe
|
||||||
|
|
||||||
|
include ../Makefile.shared
|
||||||
|
|
||||||
|
SOURCE_DIRECTORIES := ${UTILS_SOURCE_DIRECTORIES} ../lib
|
||||||
|
|
||||||
|
LIB := ${MINUTILSLIB} ${UTILSLIB} ${TESTLIB}
|
||||||
|
|
||||||
|
PACKAGES := \
|
||||||
|
${UTILS_PACKAGES} \
|
||||||
|
kaputt \
|
||||||
|
|
||||||
|
OPENED_MODULES := ${NODE_OPENED_MODULES}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## Lwt_pipe
|
||||||
|
|
||||||
|
.PHONY:run-test-lwt-pipe
|
||||||
|
run-test-lwt-pipe:
|
||||||
|
@echo
|
||||||
|
./test-lwt-pipe
|
||||||
|
|
||||||
|
TEST_PIPE_IMPLS := \
|
||||||
|
test_lwt_pipe.ml
|
||||||
|
|
||||||
|
test-lwt-pipe: ${LIB} ${TEST_PIPE_IMPLS:.ml=.cmx}
|
||||||
|
@echo LINK $(notdir $@)
|
||||||
|
@${OCAMLOPT} -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
||||||
|
|
||||||
|
clean::
|
||||||
|
rm -f test-lwt-pipe
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## Merkle
|
||||||
|
|
||||||
|
.PHONY:run-test-merkle
|
||||||
|
run-test-merkle:
|
||||||
|
@echo
|
||||||
|
./test-merkle
|
||||||
|
|
||||||
|
TEST_MERKLE_IMPLS := \
|
||||||
|
test_merkle.ml
|
||||||
|
|
||||||
|
test-merkle: ${LIB} ${TEST_MERKLE_IMPLS:.ml=.cmx}
|
||||||
|
@echo LINK $(notdir $@)
|
||||||
|
@${OCAMLOPT} -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
||||||
|
|
||||||
|
clean::
|
||||||
|
rm -f test-merkle
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
## Data_encoding
|
||||||
|
|
||||||
|
.PHONY:run-test-data-encoding
|
||||||
|
run-test-data-encoding:
|
||||||
|
@echo
|
||||||
|
./test-data-encoding
|
||||||
|
|
||||||
|
TEST_DATA_ENCODING_IMPLS := \
|
||||||
|
test_data_encoding.ml
|
||||||
|
|
||||||
|
test-data-encoding: ${LIB} ${TEST_DATA_ENCODING_IMPLS:.ml=.cmx}
|
||||||
|
@echo LINK $(notdir $@)
|
||||||
|
@${OCAMLOPT} -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
|
||||||
|
|
||||||
|
clean::
|
||||||
|
rm -f test-data-encoding
|
@ -1,5 +1,4 @@
|
|||||||
open Data_encoding
|
open Data_encoding
|
||||||
open Context
|
|
||||||
open Hash
|
open Hash
|
||||||
open Error_monad
|
open Error_monad
|
||||||
|
|
Loading…
Reference in New Issue
Block a user