Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • nodes/rust/duniter-v2s
  • llaq/lc-core-substrate
  • pini-gh/duniter-v2s
  • vincentux/duniter-v2s
  • mildred/duniter-v2s
  • d0p1/duniter-v2s
  • bgallois/duniter-v2s
  • Nicolas80/duniter-v2s
8 results
Show changes
Commits on Source (90)
Showing
with 1069 additions and 947 deletions
[alias] [alias]
cucumber = "test -p duniter-integration-tests --test cucumber_tests --" cucumber = "test -p duniter-end2end-tests --test cucumber_tests --"
tu = "test --workspace --exclude duniter-end2end-tests"
Dockerfile .editorconfig
.envrc
.git*
.vscode
docker/Dockerfile
docker-compose.yml docker-compose.yml
target target
...@@ -17,3 +17,12 @@ ...@@ -17,3 +17,12 @@
# build folder # build folder
build build
# Temporary files
tmp
# Local chain spec
*local-spec*.json
# Log files
*.log
...@@ -17,7 +17,7 @@ workflow: ...@@ -17,7 +17,7 @@ workflow:
.env: .env:
image: paritytech/ci-linux:production image: paritytech/ci-linux:production
tags: tags:
- elois-boson - elois-neutron
fmt_and_clippy: fmt_and_clippy:
extends: .env extends: .env
...@@ -41,37 +41,69 @@ build_debug: ...@@ -41,37 +41,69 @@ build_debug:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
when: never when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "master"' - if: '$CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "master"'
- when: manual changes:
- Cargo.lock
- when: never
stage: build stage: build
script: script:
- cargo clean -p duniter - cargo clean -p duniter
- cargo build - cargo build --locked
- mkdir build - mkdir build
- mv target/debug/duniter build/duniter - mv target/debug/duniter build/duniter
artifacts: artifacts:
paths: paths:
- build/ - build/
expire_in: 3 day
cache: cache:
- key: - key:
files: files:
- Cargo.lock - Cargo.lock
paths: paths:
- target/debug - target/debug
policy: push
build_debug_with_cache:
extends: .env
rules:
- changes:
- Cargo.lock
when: never
- if: $CI_COMMIT_TAG
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "master"'
- when: never
stage: build
script:
- cargo clean -p duniter
- cargo build --locked
- mkdir build
- mv target/debug/duniter build/duniter
artifacts:
paths:
- build/
expire_in: 3 day
cache:
- key:
files:
- Cargo.lock
paths:
- target/debug
policy: pull
build_release: build_release:
extends: .env extends: .env
rules: rules:
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH =~ /^release/' - if: "$CI_COMMIT_TAG || $CI_COMMIT_BRANCH =~ /^release/"
- when: never - when: never
stage: build stage: build
script: script:
- cargo build --release - cargo build --locked --release
- mkdir build - mkdir build
- mv target/release/duniter build/duniter - mv target/release/duniter build/duniter
artifacts: artifacts:
paths: paths:
- build/ - build/
expire_in: 1 day expire_in: 3 day
tests_debug: tests_debug:
extends: .env extends: .env
...@@ -85,23 +117,26 @@ tests_debug: ...@@ -85,23 +117,26 @@ tests_debug:
stage: tests stage: tests
variables: variables:
DUNITER_BINARY_PATH: "../build/duniter" DUNITER_BINARY_PATH: "../build/duniter"
DUNITER_INTEGRATION_TESTS_SPAWN_NODE_DURATION: "20" DUNITER_END2END_TESTS_SPAWN_NODE_TIMEOUT: "20"
script: script:
- cargo test - cargo test --workspace --exclude duniter-end2end-tests
dependencies: - cargo cucumber -i balance*
- build_debug - cargo cucumber -i monetary*
- cargo cucumber -i transfer*
tests_release: tests_release:
extends: .env extends: .env
rules: rules:
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH =~ /^release/' - if: "$CI_COMMIT_TAG || $CI_COMMIT_BRANCH =~ /^release/"
- when: never - when: never
stage: tests stage: tests
variables: variables:
DUNITER_BINARY_PATH: "../build/duniter" DUNITER_BINARY_PATH: "../build/duniter"
DUNITER_INTEGRATION_TESTS_SPAWN_NODE_DURATION: "10" DUNITER_INTEGRATION_TESTS_SPAWN_NODE_DURATION: "10"
script: script:
- cargo test - cargo test --workspace --exclude duniter-end2end-tests
- cargo cucumber -i monetary*
- cargo cucumber -i *transfer*
dependencies: dependencies:
- build_release - build_release
...@@ -128,8 +163,8 @@ deploy_docker_test_image: ...@@ -128,8 +163,8 @@ deploy_docker_test_image:
when: manual when: manual
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH == "master"' - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH == "master"'
when: never when: never
- if: $CI_MERGE_REQUEST_ID
- when: manual - when: manual
allow_failure: true
variables: variables:
DOCKERFILE_PATH: "docker/Dockerfile" DOCKERFILE_PATH: "docker/Dockerfile"
IMAGE_TAG: "test-image-$CI_COMMIT_SHORT_SHA" IMAGE_TAG: "test-image-$CI_COMMIT_SHORT_SHA"
...@@ -143,3 +178,7 @@ deploy_docker_debug: ...@@ -143,3 +178,7 @@ deploy_docker_debug:
variables: variables:
DOCKERFILE_PATH: "docker/Dockerfile" DOCKERFILE_PATH: "docker/Dockerfile"
IMAGE_TAG: "debug-sha-$CI_COMMIT_SHORT_SHA" IMAGE_TAG: "debug-sha-$CI_COMMIT_SHORT_SHA"
after_script:
- docker login -u "duniterteam" -p "$DUNITERTEAM_PASSWD"
- docker tag "duniter/duniter-v2s:$IMAGE_TAG" "duniter/duniter-v2s:debug-latest"
- docker push "duniter/duniter-v2s:debug-latest"
FROM docker.io/library/ubuntu:20.04
# metadata
ARG VCS_REF
ARG BUILD_DATE
# show backtraces
ENV RUST_BACKTRACE 1
# install tools and dependencies
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
libssl1.1 \
ca-certificates \
curl && \
# apt cleanup
apt-get autoremove -y && \
apt-get clean && \
find /var/lib/apt/lists/ -type f -not -name lock -delete; \
# add user
useradd -m -u 1000 -U -s /bin/sh -d /duniter duniter
# add duniter binary to docker image
COPY ./build/duniter /usr/local/bin
USER duniter
# check if executable works in this container
RUN /usr/local/bin/duniter --version
EXPOSE 30333 9933 9944
VOLUME ["/duniter"]
ENTRYPOINT ["/usr/local/bin/duniter"]
[hooks]
pre-commit = "cargo fmt -- --check"
[logging]
verbose = true
This diff is collapsed.
[package]
authors = ['Axiom-Team Developers <https://axiom-team.fr>']
build = 'node/build.rs'
description = 'Crypto-currency software (based on Substrate framework) to operate Ğ1 libre currency'
edition = '2018'
homepage = 'https://substrate.dev'
license = 'AGPL-3.0'
name = 'duniter'
repository = 'https://git.duniter.org/nodes/rust/duniter-v2s'
version = '3.0.0'
[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
[[bin]]
bench = false
name = 'duniter'
path = "node/src/main.rs"
[features]
default = ["gdev"]
g1 = ["g1-runtime"]
gdev = ["gdev-runtime"]
gtest = ["gtest-runtime"]
runtime-benchmarks = [
'g1-runtime',
'g1-runtime/runtime-benchmarks',
'gdev-runtime',
'gdev-runtime/runtime-benchmarks',
'gtest-runtime',
'gtest-runtime/runtime-benchmarks',
]
[build-dependencies]
clap = { version = "3.0" }
#clap_complete = { version = "3.0" }
substrate-build-script-utils = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02' }
[dev-dependencies]
rusty-hook = "^0.11.2"
[dependencies]
# local dependencies
common-runtime = { path = 'runtime/common' }
g1-runtime = { path = 'runtime/g1', optional = true }
gdev-runtime = { path = 'runtime/gdev', optional = true }
gtest-runtime = { path = 'runtime/gtest', optional = true }
pallet-certification = { path = 'pallets/certification' }
sp-membership = { path = 'primitives/membership' }
# crates.io dependencies
async-io = "1.3"
clap = { version = "3.0", features = ["derive"] }
futures = { version = "0.3.1", features = ["compat"] }
hex = "0.4.3"
jsonrpc-core = '18.0.0'
log = "0.4"
maplit = '1.0.2'
memmap2 = "0.5.0"
serde = "1.0"
serde_json = "1.0.64"
# substrate dependencies
frame-benchmarking = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
frame-benchmarking-cli = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
pallet-grandpa = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
pallet-transaction-payment-rpc = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-basic-authorship = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-chain-spec = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-cli = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-client-api = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-consensus = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
babe = { package = "sc-consensus-babe", git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
manual-seal = { package = "sc-consensus-manual-seal", git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-consensus-uncles = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-executor = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-finality-grandpa = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-keystore = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-network = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-rpc-api = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-service = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-telemetry = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-transaction-pool = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-transaction-pool-api = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-api = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-authority-discovery = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-block-builder = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-blockchain = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-consensus = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-consensus-babe = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-core = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-finality-grandpa = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-io = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-offchain = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-keyring = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-keystore = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-runtime = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-session = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-storage = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-timestamp = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-transaction-pool = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-trie = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
substrate-frame-rpc-system = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
[workspace] [workspace]
resolver = "2" resolver = "2"
members = [ members = [
'integration-tests', 'end2end-tests',
'node',
'pallets/certification', 'pallets/certification',
'pallets/duniter-test-parameters',
'pallets/duniter-test-parameters/macro',
'pallets/duniter-wot',
'pallets/identity', 'pallets/identity',
'pallets/membership', 'pallets/membership',
'pallets/authority-members',
'pallets/ud-accounts-storage', 'pallets/ud-accounts-storage',
'pallets/universal-dividend', 'pallets/universal-dividend',
'pallets/upgrade-origin',
'primitives/membership', 'primitives/membership',
'runtime/common',
'runtime/gdev',
] ]
# The list of dependencies below (which can be both direct and indirect dependencies) are crates # The list of dependencies below (which can be both direct and indirect dependencies) are crates
......
...@@ -20,7 +20,7 @@ corresponds to the first 8 hash characters of the commit. ...@@ -20,7 +20,7 @@ corresponds to the first 8 hash characters of the commit.
Usage: Usage:
```docker ```docker
docker run -it -p9944:9944 --name duniter-v2s duniter/duniter-v2s:debug-sha-cc648aaf docker run -it -p9944:9944 --name duniter-v2s duniter/duniter-v2s:debug-sha-b836f1a6
``` ```
Then open `https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944` in a browser. Then open `https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944` in a browser.
......
...@@ -3,7 +3,7 @@ version: "3.5" ...@@ -3,7 +3,7 @@ version: "3.5"
services: services:
duniter-v2s: duniter-v2s:
container_name: duniter-v2s container_name: duniter-v2s
image: duniter/duniter-v2s:debug-sha-cc648aaf image: duniter/duniter-v2s:debug-sha-b836f1a6
ports: ports:
# telemetry # telemetry
- "127.0.0.1:9615:9615" - "127.0.0.1:9615:9615"
......
version: "3.4"
services:
db:
image: postgres:12
restart: always
volumes:
- /var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
duniter-1:
image: duniter/duniter-v2s:debug-sha-b836f1a6
restart: unless-stopped
ports:
- "9944:9944"
indexer:
image: subsquid/hydra-indexer:5
restart: unless-stopped
environment:
- WORKERS_NUMBER=1
- DB_NAME=indexer
- DB_HOST=db
- DB_USER=postgres
- DB_PASS=postgres
- DB_PORT=5432
- REDIS_URI=redis://redis:6379/0
- FORCE_HEIGHT=true
- BLOCK_HEIGHT=0 # starting block height
- WS_PROVIDER_ENDPOINT_URI=ws://duniter-1:9944/
depends_on:
- db
- redis
command: >
sh -c "yarn db:bootstrap && yarn start:prod"
indexer-gateway:
image: subsquid/hydra-indexer-gateway:5
restart: unless-stopped
depends_on:
- redis
- db
- indexer-status-service
- indexer
ports:
- "4010:8080"
environment:
- DEV_MODE=true
- DB_NAME=indexer
- DB_HOST=db
- DB_USER=postgres
- DB_PASS=postgres
- DB_PORT=5432
- HYDRA_INDEXER_STATUS_SERVICE=http://indexer-status-service:8081/status
indexer-status-service:
image: subsquid/hydra-indexer-status-service:5
restart: unless-stopped
depends_on:
- redis
environment:
REDIS_URI: redis://redis:6379/0
PORT: 8081
redis:
image: redis:6.0-alpine
restart: always
ports:
- "6379"
...@@ -28,12 +28,10 @@ case "$DUNITER_CHAIN_NAME" in ...@@ -28,12 +28,10 @@ case "$DUNITER_CHAIN_NAME" in
;; ;;
esac esac
DUNITER_OPTS="${DUNITER_OPTS:---unsafe-ws-external}"
set -- "$@" \ set -- "$@" \
"${chain[@]}" \ "${chain[@]}" \
$(ternary "$DUNITER_DISABLE_PROMETHEUS" --no-prometheus) \ $(ternary "$DUNITER_DISABLE_PROMETHEUS" --no-prometheus) \
-d /var/lib/duniter -d /var/lib/duniter --unsafe-ws-external
echo "Starting duniter with parameters:" "$@" echo "Starting duniter with parameters:" "$@"
exec duniter "$DUNITER_OPTS" "$@" exec duniter "$@"
[package] [package]
authors = ['Axiom-Team Developers <https://axiom-team.fr>'] authors = ['Axiom-Team Developers <https://axiom-team.fr>']
description = 'duniter integration tests.' description = 'duniter end2end tests.'
edition = '2018' edition = '2018'
homepage = 'https://substrate.dev' homepage = 'https://substrate.dev'
license = 'AGPL-3.0' license = 'AGPL-3.0'
name = 'duniter-integration-tests' name = 'duniter-end2end-tests'
repository = 'https://git.duniter.org/nodes/rust/duniter-v2s' repository = 'https://git.duniter.org/nodes/rust/duniter-v2s'
version = '3.0.0' version = '3.0.0'
...@@ -12,11 +12,12 @@ version = '3.0.0' ...@@ -12,11 +12,12 @@ version = '3.0.0'
async-trait = "0.1" async-trait = "0.1"
cucumber = "0.11" cucumber = "0.11"
env_logger = "0.9.0" env_logger = "0.9.0"
notify = "4.0"
parity-scale-codec = "2.3.1" parity-scale-codec = "2.3.1"
portpicker = "0.1.1" portpicker = "0.1.1"
serde_json = "1.0.64" serde_json = "1.0.64"
sp-keyring = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-01" } sp-keyring = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
subxt = { git = 'https://github.com/librelois/subxt.git', branch = 'duniter-monthly-2022-01' } subxt = { git = 'https://github.com/librelois/subxt.git', branch = 'duniter-monthly-2022-02' }
tokio = { version = "1.15.0", features = ["macros"] } tokio = { version = "1.15.0", features = ["macros"] }
[[test]] [[test]]
......
File moved
File moved
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>. // along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
#![allow(clippy::enum_variant_names)] #![allow(clippy::enum_variant_names, dead_code, unused_imports)]
pub mod balances; pub mod balances;
...@@ -23,12 +23,17 @@ pub mod node_runtime {} ...@@ -23,12 +23,17 @@ pub mod node_runtime {}
use serde_json::Value; use serde_json::Value;
use sp_keyring::AccountKeyring; use sp_keyring::AccountKeyring;
use std::io::prelude::*;
use std::process::Command; use std::process::Command;
use std::str::FromStr;
use subxt::rpc::{rpc_params, ClientT, SubscriptionClientT};
use subxt::{ClientBuilder, DefaultConfig, DefaultExtra}; use subxt::{ClientBuilder, DefaultConfig, DefaultExtra};
pub type Api = node_runtime::RuntimeApi<DefaultConfig, DefaultExtra<DefaultConfig>>; pub type Api = node_runtime::RuntimeApi<DefaultConfig, DefaultExtra<DefaultConfig>>;
pub type Client = subxt::Client<DefaultConfig>; pub type Client = subxt::Client<DefaultConfig>;
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
pub type TransactionProgress<'client> =
subxt::TransactionProgress<'client, DefaultConfig, node_runtime::DispatchError>;
pub const SUDO_ACCOUNT: AccountKeyring = AccountKeyring::Alice; pub const SUDO_ACCOUNT: AccountKeyring = AccountKeyring::Alice;
...@@ -40,41 +45,23 @@ impl Drop for Process { ...@@ -40,41 +45,23 @@ impl Drop for Process {
} }
} }
struct FullNode {
process: Process,
p2p_port: u16,
ws_port: u16,
}
pub async fn spawn_node() -> (Api, Client, Process) { pub async fn spawn_node() -> (Api, Client, Process) {
let duniter_binary_path = std::env::var("DUNITER_BINARY_PATH") let duniter_binary_path = std::env::var("DUNITER_BINARY_PATH")
.unwrap_or_else(|_| "../target/debug/duniter".to_owned()); .unwrap_or_else(|_| "../target/debug/duniter".to_owned());
let FullNode {
let p2p_port = portpicker::pick_unused_port().expect("No ports free"); process,
let rpc_port = portpicker::pick_unused_port().expect("No ports free"); p2p_port: _,
let ws_port = portpicker::pick_unused_port().expect("No ports free"); ws_port,
let process = Process( } = spawn_full_node(
Command::new(duniter_binary_path) &duniter_binary_path,
.args([ &["--dev", "--execution=Native", "--sealing=manual"],
"--execution=Native",
"--no-telemetry",
"--no-prometheus",
"--dev",
"--sealing=manual",
"--tmp",
"--port",
&p2p_port.to_string(),
"--rpc-port",
&rpc_port.to_string(),
"--ws-port",
&ws_port.to_string(),
])
.spawn()
.expect("failed to spawn node"),
); );
let duration_secs = if let Ok(duration_string) =
std::env::var("DUNITER_INTEGRATION_TESTS_SPAWN_NODE_DURATION")
{
duration_string.parse().unwrap_or(4)
} else {
4
};
std::thread::sleep(std::time::Duration::from_secs(duration_secs));
let client = ClientBuilder::new() let client = ClientBuilder::new()
.set_url(format!("ws://127.0.0.1:{}", ws_port)) .set_url(format!("ws://127.0.0.1:{}", ws_port))
.build() .build()
...@@ -90,10 +77,7 @@ pub async fn create_empty_block(client: &Client) -> Result<()> { ...@@ -90,10 +77,7 @@ pub async fn create_empty_block(client: &Client) -> Result<()> {
let _: Value = client let _: Value = client
.rpc() .rpc()
.client .client
.request( .request("engine_createBlock", rpc_params![true, false, Value::Null])
"engine_createBlock",
&[Value::Bool(true), Value::Bool(false), Value::Null],
)
.await?; .await?;
Ok(()) Ok(())
...@@ -108,16 +92,13 @@ pub async fn create_block_with_extrinsic( ...@@ -108,16 +92,13 @@ pub async fn create_block_with_extrinsic(
let ext_hash = <DefaultConfig as subxt::Config>::Hashing::hash_of(&extrinsic); let ext_hash = <DefaultConfig as subxt::Config>::Hashing::hash_of(&extrinsic);
// Submit and watch for transaction progress. // Submit and watch for transaction progress.
let sub = client.rpc().watch_extrinsic(extrinsic).await?; let sub = client.rpc().watch_extrinsic(extrinsic).await?;
let watcher = subxt::TransactionProgress::new(sub, client, ext_hash); let watcher = TransactionProgress::new(sub, client, ext_hash);
// Create a non-empty block // Create a non-empty block
let _: Value = client let _: Value = client
.rpc() .rpc()
.client .client
.request( .request("engine_createBlock", rpc_params![false, false, Value::Null])
"engine_createBlock",
&[Value::Bool(false), Value::Bool(false), Value::Null],
)
.await?; .await?;
// Get extrinsic events // Get extrinsic events
...@@ -128,3 +109,84 @@ pub async fn create_block_with_extrinsic( ...@@ -128,3 +109,84 @@ pub async fn create_block_with_extrinsic(
.await .await
.map_err(Into::into) .map_err(Into::into)
} }
fn spawn_full_node(duniter_binary_path: &str, args: &[&str]) -> FullNode {
let p2p_port = portpicker::pick_unused_port().expect("No ports free");
let rpc_port = portpicker::pick_unused_port().expect("No ports free");
let ws_port = portpicker::pick_unused_port().expect("No ports free");
let log_file_path = format!("duniter-v2s-{}.log", ws_port);
let log_file = std::fs::File::create(&log_file_path).expect("fail to create log file");
let process = Process(
Command::new(duniter_binary_path)
.args(
[
"--no-telemetry",
"--no-prometheus",
"--tmp",
"--port",
&p2p_port.to_string(),
"--rpc-port",
&rpc_port.to_string(),
"--ws-port",
&ws_port.to_string(),
]
.iter()
.chain(args),
)
.stdout(std::process::Stdio::null())
.stderr(log_file)
.spawn()
.expect("failed to spawn node"),
);
let timeout =
if let Ok(duration_string) = std::env::var("DUNITER_END2END_TESTS_SPAWN_NODE_TIMEOUT") {
duration_string.parse().unwrap_or(4)
} else {
4
};
wait_until_log_line(
"***** Duniter has fully started *****",
&log_file_path,
std::time::Duration::from_secs(timeout),
);
FullNode {
process,
p2p_port,
ws_port,
}
}
fn wait_until_log_line(expected_log_line: &str, log_file_path: &str, timeout: std::time::Duration) {
let (tx, rx) = std::sync::mpsc::channel();
let mut watcher = notify::watcher(tx, std::time::Duration::from_millis(100)).unwrap();
use notify::Watcher as _;
watcher
.watch(&log_file_path, notify::RecursiveMode::NonRecursive)
.unwrap();
let mut pos = 0;
loop {
match rx.recv_timeout(timeout) {
Ok(notify::DebouncedEvent::Write(_)) => {
let mut file = std::fs::File::open(&log_file_path).unwrap();
file.seek(std::io::SeekFrom::Start(pos)).unwrap();
pos = file.metadata().unwrap().len();
let reader = std::io::BufReader::new(file);
for line in reader.lines() {
if line.expect("fail to read line").contains(expected_log_line) {
return;
}
}
}
Ok(_) => {}
Err(err) => {
eprintln!("Error: {:?}", err);
std::process::exit(1);
}
}
}
}