From 5202477675608182ed49bc9b13d16794ff8a3499 Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 5 Jul 2024 14:03:46 +0100 Subject: [PATCH 1/2] feat(tests): sharechain unit tests --- Cargo.lock | 234 ++++++++++++++++++++++------------- Cargo.toml | 9 +- src/sharechain/mod.rs | 1 + src/sharechain/tests/mod.rs | 1 + src/sharechain/tests/test.rs | 163 ++++++++++++++++++++++++ 5 files changed, 315 insertions(+), 93 deletions(-) create mode 100644 src/sharechain/tests/mod.rs create mode 100644 src/sharechain/tests/test.rs diff --git a/Cargo.lock b/Cargo.lock index 7624ca1..150547e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -641,7 +641,7 @@ dependencies = [ "iana-time-zone", "num-traits", "serde", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -2666,8 +2666,8 @@ dependencies = [ [[package]] name = "minotari_app_grpc" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "argon2", "base64 0.13.1", @@ -2679,11 +2679,11 @@ dependencies = [ "rand", "rcgen", "subtle", - "tari_common_types", + "tari_common_types 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_comms", "tari_core", "tari_crypto", - "tari_features", + "tari_features 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_script", "tari_utilities", "thiserror", @@ -2696,7 +2696,7 @@ dependencies = [ [[package]] name = "minotari_node_grpc_client" version = "0.1.0" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "minotari_app_grpc", ] @@ -3125,7 +3125,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -3821,7 +3821,7 @@ dependencies = [ "once_cell", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.4", + "rustls-webpki 0.102.5", "subtle", "zeroize", ] @@ -3862,9 +3862,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.4" +version = "0.102.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" dependencies = [ "ring 0.17.8", "rustls-pki-types", @@ -4057,11 +4057,13 @@ dependencies = [ "minotari_app_grpc", "minotari_node_grpc_client", "moka", + "rand", "serde", "serde_cbor", - "tari_common", - "tari_common_types", + "tari_common 1.0.0-pre.15 (git+https://github.com/tari-project/tari.git)", + "tari_common_types 1.0.0-pre.15 (git+https://github.com/tari-project/tari.git)", "tari_core", + "tari_crypto", "tari_utilities", "thiserror", "tokio", @@ -4376,8 +4378,8 @@ dependencies = [ [[package]] name = "tari_common" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "anyhow", "blake2", @@ -4394,16 +4396,40 @@ dependencies = [ "sha2", "structopt", "tari_crypto", - "tari_features", + "tari_features 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tempfile", "thiserror", "toml 0.5.11", ] +[[package]] +name = "tari_common" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#43b76d993d7ada9db2a8ebbc9b7969ba19279d6d" +dependencies = [ + "anyhow", + "blake2", + "config", + "dirs-next", + "log", + "log4rs", + "multiaddr 0.14.0", + "path-clean", + "serde", + "serde_json", + "serde_yaml", + "sha2", + "structopt", + "tari_crypto", + "tari_features 1.0.0-pre.15 (git+https://github.com/tari-project/tari.git)", + "tempfile", + "thiserror", +] + [[package]] name = "tari_common_sqlite" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "diesel", "diesel_migrations", @@ -4416,8 +4442,33 @@ dependencies = [ [[package]] name = "tari_common_types" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" +dependencies = [ + "base64 0.21.7", + "bitflags 2.6.0", + "blake2", + "borsh", + "bs58 0.5.1", + "chacha20poly1305", + "digest", + "newtype-ops", + "once_cell", + "primitive-types", + "rand", + "serde", + "strum", + "strum_macros", + "tari_common 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", + "tari_crypto", + "tari_utilities", + "thiserror", +] + +[[package]] +name = "tari_common_types" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#43b76d993d7ada9db2a8ebbc9b7969ba19279d6d" dependencies = [ "base64 0.21.7", "bitflags 2.6.0", @@ -4433,7 +4484,7 @@ dependencies = [ "serde", "strum", "strum_macros", - "tari_common", + "tari_common 1.0.0-pre.15 (git+https://github.com/tari-project/tari.git)", "tari_crypto", "tari_utilities", "thiserror", @@ -4441,8 +4492,8 @@ dependencies = [ [[package]] name = "tari_comms" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "anyhow", "async-trait", @@ -4468,7 +4519,7 @@ dependencies = [ "serde_derive", "sha3", "snow", - "tari_common", + "tari_common 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_crypto", "tari_shutdown", "tari_storage", @@ -4485,8 +4536,8 @@ dependencies = [ [[package]] name = "tari_comms_dht" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "anyhow", "bitflags 2.6.0", @@ -4504,7 +4555,7 @@ dependencies = [ "prost", "rand", "serde", - "tari_common", + "tari_common 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_common_sqlite", "tari_comms", "tari_comms_rpc_macros", @@ -4520,8 +4571,8 @@ dependencies = [ [[package]] name = "tari_comms_rpc_macros" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "proc-macro2", "quote", @@ -4530,8 +4581,8 @@ dependencies = [ [[package]] name = "tari_core" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "async-trait", "bincode", @@ -4569,14 +4620,14 @@ dependencies = [ "strum", "strum_macros", "tari-tiny-keccak", - "tari_common", + "tari_common 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_common_sqlite", - "tari_common_types", + "tari_common_types 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_comms", "tari_comms_dht", "tari_comms_rpc_macros", "tari_crypto", - "tari_features", + "tari_features 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_hashing", "tari_key_manager", "tari_mmr", @@ -4595,9 +4646,9 @@ dependencies = [ [[package]] name = "tari_crypto" -version = "0.20.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b549b292deddde212f389f345ef58c0bffb552b7e0f561f5504859ca82466" +checksum = "22b761f7cf1754eb2223286c9d437c81737526f393f09f69b2456bf49ba25a5b" dependencies = [ "blake2", "borsh", @@ -4619,13 +4670,18 @@ dependencies = [ [[package]] name = "tari_features" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" + +[[package]] +name = "tari_features" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#43b76d993d7ada9db2a8ebbc9b7969ba19279d6d" [[package]] name = "tari_hashing" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "borsh", "digest", @@ -4634,8 +4690,8 @@ dependencies = [ [[package]] name = "tari_key_manager" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "argon2", "async-trait", @@ -4656,7 +4712,7 @@ dependencies = [ "strum_macros", "subtle", "tari_common_sqlite", - "tari_common_types", + "tari_common_types 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_crypto", "tari_service_framework", "tari_utilities", @@ -4667,14 +4723,14 @@ dependencies = [ [[package]] name = "tari_mmr" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "borsh", "digest", "log", "serde", - "tari_common", + "tari_common 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_crypto", "tari_utilities", "thiserror", @@ -4682,8 +4738,8 @@ dependencies = [ [[package]] name = "tari_p2p" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "anyhow", "fs2", @@ -4694,7 +4750,7 @@ dependencies = [ "rand", "rustls 0.20.9", "serde", - "tari_common", + "tari_common 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_comms", "tari_comms_dht", "tari_crypto", @@ -4712,8 +4768,8 @@ dependencies = [ [[package]] name = "tari_script" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "blake2", "borsh", @@ -4729,8 +4785,8 @@ dependencies = [ [[package]] name = "tari_service_framework" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "anyhow", "async-trait", @@ -4744,16 +4800,16 @@ dependencies = [ [[package]] name = "tari_shutdown" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "futures 0.3.30", ] [[package]] name = "tari_storage" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "bincode", "lmdb-zero", @@ -4764,8 +4820,8 @@ dependencies = [ [[package]] name = "tari_test_utils" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "futures 0.3.30", "rand", @@ -5565,7 +5621,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -5583,7 +5639,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -5603,18 +5659,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -5625,9 +5681,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -5637,9 +5693,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -5649,15 +5705,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -5667,9 +5723,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -5679,9 +5735,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -5691,9 +5747,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -5703,9 +5759,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -5830,18 +5886,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 99e076f..33d3978 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,15 +7,15 @@ edition = "2021" #sha_p2pool_grpc = { path = "../sha_p2pool_grpc" } #minotari_app_grpc = { git = "https://github.com/tari-project/tari.git" } #minotari_node_grpc_client = { git = "https://github.com/tari-project/tari.git" } -#tari_common_types = { git = "https://github.com/tari-project/tari.git" } - minotari_app_grpc = { git = "https://github.com/ksrichard/tari.git", branch = "p2pool" } minotari_node_grpc_client = { git = "https://github.com/ksrichard/tari.git", branch = "p2pool" } -tari_common_types = { git = "https://github.com/ksrichard/tari.git", branch = "p2pool" } -tari_common = { git = "https://github.com/ksrichard/tari.git", branch = "p2pool" } tari_core = { git = "https://github.com/ksrichard/tari.git", branch = "p2pool" } +tari_crypto = "0.20.1" +tari_common_types = { git = "https://github.com/tari-project/tari.git" } +tari_common = { git = "https://github.com/tari-project/tari.git" } tari_utilities = { version = "0.7", features = ["borsh"] } + libp2p = { version = "0.53.2", features = [ "dns", "identify", @@ -45,5 +45,6 @@ blake2 = "0.10.6" digest = "0.10.7" clap = { version = "4.5.7", features = ["derive"] } moka = { version = "0.12.7", features = ["future"] } +rand = "0.8.0" diff --git a/src/sharechain/mod.rs b/src/sharechain/mod.rs index f81a27a..b70ca42 100644 --- a/src/sharechain/mod.rs +++ b/src/sharechain/mod.rs @@ -13,6 +13,7 @@ pub const SHARE_COUNT: u64 = 100; pub mod block; pub mod error; pub mod in_memory; +pub mod tests; pub type ShareChainResult = Result; diff --git a/src/sharechain/tests/mod.rs b/src/sharechain/tests/mod.rs new file mode 100644 index 0000000..5857229 --- /dev/null +++ b/src/sharechain/tests/mod.rs @@ -0,0 +1 @@ +mod test; diff --git a/src/sharechain/tests/test.rs b/src/sharechain/tests/test.rs new file mode 100644 index 0000000..3be77be --- /dev/null +++ b/src/sharechain/tests/test.rs @@ -0,0 +1,163 @@ +#[cfg(test)] +mod tests { + use minotari_app_grpc::tari_rpc::{Block, BlockHeader, ProofOfWork, SubmitBlockRequest}; + use tari_common::configuration::Network; + use tari_common_types::tari_address::{TariAddress, TariAddressFeatures}; + use tari_crypto::{keys::PublicKey as CryptoPubKey, ristretto::RistrettoPublicKey}; + + use crate::{ + sharechain::{ + block::{Block as ShareChainBlock, BlockBuilder}, + ShareChain, + }, + InMemoryShareChain, + }; + + fn new_random_address() -> TariAddress { + let mut rng = rand::thread_rng(); + let (_, pk) = RistrettoPublicKey::random_keypair(&mut rng); + TariAddress::new_single_address(pk, Network::LocalNet, TariAddressFeatures::INTERACTIVE) + } + + fn new_sharechain_blocks(n: u64) -> Vec { + let mut blocks = Vec::new(); + for i in 1..n + 1 { + let block = BlockBuilder::new() + .with_height(i) + .with_miner_wallet_address(new_random_address()) + .build(); + blocks.push(block); + } + blocks + } + + async fn generate_block_request(payment_address: String) -> SubmitBlockRequest { + SubmitBlockRequest { + block: Some(Block { + header: Some(BlockHeader { + hash: [0; 32].to_vec(), + version: 0, + height: 1, + prev_hash: [0; 32].to_vec(), + timestamp: 1720167829, + output_mr: [0; 32].to_vec(), + kernel_mr: [0; 32].to_vec(), + input_mr: [0; 32].to_vec(), + total_kernel_offset: [0; 32].to_vec(), + nonce: 119018423820796913, + pow: Some(ProofOfWork { + pow_algo: 1, + pow_data: Vec::new(), + }), + kernel_mmr_size: 795, + output_mmr_size: 804, + total_script_offset: [0; 32].to_vec(), + validator_node_mr: [0; 32].to_vec(), + validator_node_size: 0, + }), + body: None, + }), + wallet_payment_address: payment_address, + } + } + + #[tokio::test] + async fn submit_blocks_nominal_case() { + let chain = InMemoryShareChain::default(); + + let block_1 = BlockBuilder::new().with_height(1).build(); + let op = chain.submit_block(&block_1).await; + assert!(op.is_ok()); + + let tip = chain.tip_height().await; + assert!(tip.is_ok()); + assert_eq!(tip.unwrap(), 1); + + let block_2 = BlockBuilder::new().with_height(2).build(); + let block_3 = BlockBuilder::new().with_height(3).build(); + let blocks = vec![block_2.clone(), block_3.clone()]; + let op = chain.submit_blocks(blocks.clone(), false).await; + assert!(op.is_ok()); + + let tip = chain.tip_height().await; + assert!(tip.is_ok()); + assert_eq!(tip.unwrap(), 3); + + // only block with height greater than 1 + let blocks = chain.blocks(1).await; + assert!(blocks.is_ok()); + let blocks = blocks.unwrap(); + assert_eq!(blocks.clone().len(), 2); + assert_eq!(blocks[0], block_2); + assert_eq!(blocks[1], block_3); + } + + #[tokio::test] + async fn generate_shares_nominal_case() { + let chain = InMemoryShareChain::default(); + + let blocks = new_sharechain_blocks(3); + let op = chain.submit_blocks(blocks.clone(), false).await; + assert!(op.is_ok()); + + // every miner has obtained 1% of 100 shares (= 1) + let shares = chain.generate_shares(100).await; + assert_eq!(shares.len(), 3); + for share in shares { + assert_eq!(share.value, 1); + } + let chain = InMemoryShareChain::default(); + let _ = chain.submit_blocks(blocks, false).await; + + // every miner has obtained 2% of 100 shares (= 2) + let shares = chain.generate_shares(200).await; + assert_eq!(shares.len(), 3); + for share in shares { + assert_eq!(share.value, 2); + } + } + + #[tokio::test] + async fn new_block_nominal_case() { + let chain = InMemoryShareChain::default(); + + let req = generate_block_request(new_random_address().to_hex()).await; + let op = chain.new_block(&req).await; + assert!(op.is_ok()); + + let block = op.unwrap(); + assert!(block.height() == 1); + } + + #[tokio::test] + async fn new_block_error_no_block() { + let chain = InMemoryShareChain::default(); + + let req = SubmitBlockRequest { + block: None, + wallet_payment_address: new_random_address().to_hex(), + }; + let op = chain.new_block(&req).await; + + assert!(op.is_err()); + assert_eq!( + op.err().unwrap().to_string(), + "gRPC Block conversion error: Missing field: block" + ); + } + + #[tokio::test] + async fn new_block_error_invalid_address() { + let chain = InMemoryShareChain::default(); + + // not in hex format, error + let req = generate_block_request(new_random_address().to_string()).await; + let op = chain.new_block(&req).await; + + assert!(op.is_err()); + assert_eq!( + op.err().unwrap().to_string(), + "Tari address error: Cannot recover public key" + ); + } +} From 211af17d843747fde34ad319cfc4e7b848d2f022 Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 5 Jul 2024 15:56:53 +0100 Subject: [PATCH 2/2] chore: fix linters and workflow --- .github/workflows/ci.yml | 2 +- .github/workflows/integration_tests.yml | 28 ------------- src/server/grpc/base_node.rs | 56 +++++-------------------- src/server/grpc/p2pool.rs | 27 +++++------- src/server/p2p/client.rs | 4 +- src/server/p2p/error.rs | 7 +--- src/server/p2p/messages.rs | 8 +++- src/server/p2p/mod.rs | 4 +- src/server/p2p/{p2p.rs => network.rs} | 29 ++++--------- src/server/p2p/peer_store.rs | 2 +- src/server/server.rs | 9 ++-- src/sharechain/in_memory.rs | 31 +++++--------- src/sharechain/tests/mod.rs | 3 ++ src/sharechain/tests/test.rs | 8 +++- 14 files changed, 67 insertions(+), 151 deletions(-) rename src/server/p2p/{p2p.rs => network.rs} (98%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5da496e..b430dcd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -209,7 +209,7 @@ jobs: - name: cargo test compile run: cargo test -vv --no-run --locked --all-features --release - name: cargo test - run: cargo nextest run --all-features --release -E "not package(tari_integration_tests)" --profile ci + run: cargo nextest run --all-features --release - name: upload artifact uses: actions/upload-artifact@v4 # upload test results as artifact if: always() diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 921ab95..63f7d99 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -94,20 +94,6 @@ jobs: - name: cargo test compile run: cargo test --no-run --locked --all-features --release ${{ env.TARGET_BINS }} - - name: Run ${{ env.CI_PROFILE }} integration tests for binaries - if: ${{ env.CI_BINS == 'true' }} - timeout-minutes: 90 - run: | - cargo test \ - --test cucumber \ - -v \ - --all-features \ - --release \ - --package tari_integration_tests \ - -- -t "${{ env.CI_PROFILE }} and (not @wallet-ffi) and (not @chat-ffi) and (not @broken)" \ - -c 5 \ - --retry 2 - - name: upload artifact uses: actions/upload-artifact@v4 # upload test results as artifact if: always() @@ -176,20 +162,6 @@ jobs: if: ${{ env.CI_FFI == 'true' }} run: cargo test --no-run --locked --all-features --release ${{ env.TARGET_BINS }} - - name: Run ${{ env.CI_PROFILE }} integration tests for ffi - if: ${{ env.CI_FFI == 'true' }} - timeout-minutes: 90 - run: | - cargo test \ - --test cucumber \ - -v \ - --all-features \ - --release \ - --package tari_integration_tests \ - -- -t "(@wallet-ffi or @chat-ffi) and ${{ env.CI_PROFILE }} and (not @broken)" \ - -c 1 \ - --retry 2 - - name: upload artifact uses: actions/upload-artifact@v4 # upload test results as artifact if: always() diff --git a/src/server/grpc/base_node.rs b/src/server/grpc/base_node.rs index 23dcf15..145167e 100644 --- a/src/server/grpc/base_node.rs +++ b/src/server/grpc/base_node.rs @@ -8,52 +8,16 @@ use log::error; use minotari_app_grpc::{ tari_rpc, tari_rpc::{ - base_node_client::BaseNodeClient, - Block, - BlockBlobRequest, - BlockGroupRequest, - BlockGroupResponse, - BlockHeaderResponse, - BlockHeight, - BlockTimingResponse, - ConsensusConstants, - Empty, - FetchMatchingUtxosRequest, - GetActiveValidatorNodesRequest, - GetBlocksRequest, - GetHeaderByHashRequest, - GetMempoolTransactionsRequest, - GetNewBlockBlobResult, - GetNewBlockResult, - GetNewBlockTemplateWithCoinbasesRequest, - GetNewBlockWithCoinbasesRequest, - GetPeersRequest, - GetShardKeyRequest, - GetShardKeyResponse, - GetSideChainUtxosRequest, - GetTemplateRegistrationsRequest, - HeightRequest, - HistoricalBlock, - ListConnectedPeersResponse, - ListHeadersRequest, - MempoolStatsResponse, - NetworkStatusResponse, - NewBlockTemplate, - NewBlockTemplateRequest, - NewBlockTemplateResponse, - NodeIdentity, - SearchKernelsRequest, - SearchUtxosRequest, - SoftwareUpdate, - StringValue, - SubmitBlockResponse, - SubmitTransactionRequest, - SubmitTransactionResponse, - SyncInfoResponse, - SyncProgressResponse, - TipInfoResponse, - TransactionStateRequest, - TransactionStateResponse, + base_node_client::BaseNodeClient, Block, BlockBlobRequest, BlockGroupRequest, BlockGroupResponse, + BlockHeaderResponse, BlockHeight, BlockTimingResponse, ConsensusConstants, Empty, FetchMatchingUtxosRequest, + GetActiveValidatorNodesRequest, GetBlocksRequest, GetHeaderByHashRequest, GetMempoolTransactionsRequest, + GetNewBlockBlobResult, GetNewBlockResult, GetNewBlockTemplateWithCoinbasesRequest, + GetNewBlockWithCoinbasesRequest, GetPeersRequest, GetShardKeyRequest, GetShardKeyResponse, + GetSideChainUtxosRequest, GetTemplateRegistrationsRequest, HeightRequest, HistoricalBlock, + ListConnectedPeersResponse, ListHeadersRequest, MempoolStatsResponse, NetworkStatusResponse, NewBlockTemplate, + NewBlockTemplateRequest, NewBlockTemplateResponse, NodeIdentity, SearchKernelsRequest, SearchUtxosRequest, + SoftwareUpdate, StringValue, SubmitBlockResponse, SubmitTransactionRequest, SubmitTransactionResponse, + SyncInfoResponse, SyncProgressResponse, TipInfoResponse, TransactionStateRequest, TransactionStateResponse, ValueAtHeightResponse, }, }; diff --git a/src/server/grpc/p2pool.rs b/src/server/grpc/p2pool.rs index 7620863..cf99faa 100644 --- a/src/server/grpc/p2pool.rs +++ b/src/server/grpc/p2pool.rs @@ -5,17 +5,9 @@ use std::sync::Arc; use log::{debug, info, warn}; use minotari_app_grpc::tari_rpc::{ - base_node_client::BaseNodeClient, - pow_algo::PowAlgos, - sha_p2_pool_server::ShaP2Pool, - GetNewBlockRequest, - GetNewBlockResponse, - GetNewBlockTemplateWithCoinbasesRequest, - HeightRequest, - NewBlockTemplateRequest, - PowAlgo, - SubmitBlockRequest, - SubmitBlockResponse, + base_node_client::BaseNodeClient, pow_algo::PowAlgos, sha_p2_pool_server::ShaP2Pool, GetNewBlockRequest, + GetNewBlockResponse, GetNewBlockTemplateWithCoinbasesRequest, HeightRequest, NewBlockTemplateRequest, PowAlgo, + SubmitBlockRequest, SubmitBlockResponse, }; use tari_core::proof_of_work::sha3x_difficulty; use tokio::sync::Mutex; @@ -33,7 +25,8 @@ const LOG_TARGET: &str = "p2pool_grpc"; /// P2Pool specific gRPC service to provide `get_new_block` and `submit_block` functionalities. pub struct ShaP2PoolGrpc -where S: ShareChain + Send + Sync + 'static +where + S: ShareChain + Send + Sync + 'static, { /// Base node client client: Arc>>, @@ -44,7 +37,8 @@ where S: ShareChain + Send + Sync + 'static } impl ShaP2PoolGrpc -where S: ShareChain + Send + Sync + 'static +where + S: ShareChain + Send + Sync + 'static, { pub async fn new( base_node_address: String, @@ -73,7 +67,8 @@ where S: ShareChain + Send + Sync + 'static #[tonic::async_trait] impl ShaP2Pool for ShaP2PoolGrpc -where S: ShareChain + Send + Sync + 'static +where + S: ShareChain + Send + Sync + 'static, { /// Returns a new block (that can be mined) which contains all the shares generated /// from the current share chain as coinbase transactions. @@ -173,8 +168,8 @@ where S: ShareChain + Send + Sync + 'static .into_inner(); let mut network_difficulty_matches = false; while let Ok(Some(diff_resp)) = network_difficulty_stream.message().await { - if origin_block_header.height == diff_resp.height + 1 && - request_block_difficulty.as_u64() > diff_resp.difficulty + if origin_block_header.height == diff_resp.height + 1 + && request_block_difficulty.as_u64() > diff_resp.difficulty { network_difficulty_matches = true; } diff --git a/src/server/p2p/client.rs b/src/server/p2p/client.rs index dc96dd0..ff73b80 100644 --- a/src/server/p2p/client.rs +++ b/src/server/p2p/client.rs @@ -13,8 +13,7 @@ use tokio::{ sync::{ broadcast, broadcast::error::{RecvError, SendError}, - mpsc, - Mutex, + mpsc, Mutex, }, time::sleep, }; @@ -110,6 +109,7 @@ impl ServiceClient { Ok(()) } + #[allow(clippy::cast_possible_truncation)] async fn validate_block_with_retries(&self, block: &Block, mut retries: u64) -> Result { if retries >= self.config.validate_block_max_retries { warn!(target: LOG_TARGET, "❗Too many validation retries!"); diff --git a/src/server/p2p/error.rs b/src/server/p2p/error.rs index b73ad38..5921469 100644 --- a/src/server/p2p/error.rs +++ b/src/server/p2p/error.rs @@ -2,12 +2,7 @@ // SPDX-License-Identifier: BSD-3-Clause use libp2p::{ - gossipsub::PublishError, - identity::DecodingError, - kad::NoKnownPeers, - multiaddr, - noise, - swarm::DialError, + gossipsub::PublishError, identity::DecodingError, kad::NoKnownPeers, multiaddr, noise, swarm::DialError, TransportError, }; use thiserror::Error; diff --git a/src/server/p2p/messages.rs b/src/server/p2p/messages.rs index cc9e3ca..2e60deb 100644 --- a/src/server/p2p/messages.rs +++ b/src/server/p2p/messages.rs @@ -29,12 +29,16 @@ macro_rules! impl_conversions { }; } pub fn deserialize_message<'a, T>(raw_message: &'a [u8]) -> Result -where T: Deserialize<'a> { +where + T: Deserialize<'a>, +{ serde_cbor::from_slice(raw_message).map_err(Error::SerializeDeserialize) } pub fn serialize_message(input: &T) -> Result, Error> -where T: Serialize { +where + T: Serialize, +{ serde_cbor::to_vec(input).map_err(Error::SerializeDeserialize) } diff --git a/src/server/p2p/mod.rs b/src/server/p2p/mod.rs index 62cdba3..e8505a6 100644 --- a/src/server/p2p/mod.rs +++ b/src/server/p2p/mod.rs @@ -6,10 +6,10 @@ pub use client::*; pub use error::*; -pub use p2p::*; +pub use network::*; pub(crate) mod client; mod error; pub mod messages; -mod p2p; +mod network; pub mod peer_store; diff --git a/src/server/p2p/p2p.rs b/src/server/p2p/network.rs similarity index 98% rename from src/server/p2p/p2p.rs rename to src/server/p2p/network.rs index 1ac1370..15f0833 100644 --- a/src/server/p2p/p2p.rs +++ b/src/server/p2p/network.rs @@ -18,15 +18,10 @@ use libp2p::{ mdns, mdns::tokio::Tokio, multiaddr::Protocol, - noise, - request_response, + noise, request_response, request_response::{cbor, ResponseChannel}, swarm::{NetworkBehaviour, SwarmEvent}, - tcp, - yamux, - Multiaddr, - StreamProtocol, - Swarm, + tcp, yamux, Multiaddr, StreamProtocol, Swarm, }; use log::{debug, error, info, warn}; use tari_common::configuration::Network; @@ -43,20 +38,12 @@ use crate::{ server::{ config, p2p::{ - client, - messages, + client, messages, messages::{ - PeerInfo, - ShareChainSyncRequest, - ShareChainSyncResponse, - ValidateBlockRequest, - ValidateBlockResult, + PeerInfo, ShareChainSyncRequest, ShareChainSyncResponse, ValidateBlockRequest, ValidateBlockResult, }, peer_store::PeerStore, - Error, - LibP2PError, - ServiceClient, - ServiceClientChannels, + Error, LibP2PError, ServiceClient, ServiceClientChannels, }, }, sharechain::{block::Block, ShareChain}, @@ -102,7 +89,8 @@ pub struct ServerNetworkBehaviour { /// Service is the implementation that holds every peer-to-peer related logic /// that makes sure that all the communications, syncing, broadcasting etc... are done. pub struct Service -where S: ShareChain + Send + Sync + 'static +where + S: ShareChain + Send + Sync + 'static, { swarm: Swarm, port: u16, @@ -122,7 +110,8 @@ where S: ShareChain + Send + Sync + 'static } impl Service -where S: ShareChain + Send + Sync + 'static +where + S: ShareChain + Send + Sync + 'static, { /// Constructs a new Service from the provided config. /// It also instantiates libp2p swarm inside. diff --git a/src/server/p2p/peer_store.rs b/src/server/p2p/peer_store.rs index 56208f6..7f4c788 100644 --- a/src/server/p2p/peer_store.rs +++ b/src/server/p2p/peer_store.rs @@ -125,7 +125,7 @@ impl PeerStore { pub async fn cleanup(&self) -> Vec { let mut expired_peers = vec![]; - for (k, v) in self.inner.iter() { + for (k, v) in &self.inner { debug!(target: LOG_TARGET, "{:?} -> {:?}", k, v); let elapsed = v.created.elapsed(); let expired = elapsed.gt(&self.ttl); diff --git a/src/server/server.rs b/src/server/server.rs index 45c5b08..5154c61 100644 --- a/src/server/server.rs +++ b/src/server/server.rs @@ -13,8 +13,7 @@ use thiserror::Error; use crate::{ server::{ - config, - grpc, + config, grpc, grpc::{base_node::TariBaseNodeGrpc, error::TonicError, p2pool::ShaP2PoolGrpc}, p2p, }, @@ -35,7 +34,8 @@ pub enum Error { /// Server represents the server running all the necessary components for sha-p2pool. pub struct Server -where S: ShareChain + Send + Sync + 'static +where + S: ShareChain + Send + Sync + 'static, { config: config::Config, p2p_service: p2p::Service, @@ -45,7 +45,8 @@ where S: ShareChain + Send + Sync + 'static // TODO: add graceful shutdown impl Server -where S: ShareChain + Send + Sync + 'static +where + S: ShareChain + Send + Sync + 'static, { pub async fn new(config: config::Config, share_chain: S) -> Result { let share_chain = Arc::new(share_chain); diff --git a/src/sharechain/in_memory.rs b/src/sharechain/in_memory.rs index 446bc3f..aa1957a 100644 --- a/src/sharechain/in_memory.rs +++ b/src/sharechain/in_memory.rs @@ -13,11 +13,7 @@ use tokio::sync::{RwLock, RwLockWriteGuard}; use crate::sharechain::{ error::{BlockConvertError, Error}, - Block, - ShareChain, - ShareChainResult, - MAX_BLOCKS_COUNT, - SHARE_COUNT, + Block, ShareChain, ShareChainResult, MAX_BLOCKS_COUNT, SHARE_COUNT, }; const LOG_TARGET: &str = "in_memory_share_chain"; @@ -97,22 +93,14 @@ impl InMemoryShareChain { in_sync: bool, ) -> ShareChainResult<()> { let block = block.clone(); - let last_block = blocks.last(); - if in_sync && last_block.is_some() { - // validate - if !self.validate_block(last_block.unwrap(), &block).await? { - error!(target: LOG_TARGET, "Invalid block!"); - return Err(Error::InvalidBlock(block)); - } - } else if !in_sync && last_block.is_none() { + if !in_sync && last_block.is_none() { return Err(Error::Empty); - } else if !in_sync && last_block.is_some() { - // validate - if !self.validate_block(last_block.unwrap(), &block).await? { - error!(target: LOG_TARGET, "Invalid block!"); - return Err(Error::InvalidBlock(block)); - } + } + + if last_block.is_some() && !self.validate_block(last_block.unwrap(), &block).await? { + error!(target: LOG_TARGET, "Invalid block!"); + return Err(Error::InvalidBlock(block)); } if blocks.len() >= self.max_blocks_count { @@ -142,8 +130,8 @@ impl ShareChain for InMemoryShareChain { let mut blocks_write_lock = self.blocks.write().await; let last_block = blocks_write_lock.last(); - if (sync && last_block.is_none()) || - (sync && last_block.is_some() && !blocks.is_empty() && last_block.unwrap().height() < blocks[0].height()) + if (sync && last_block.is_none()) + || (sync && last_block.is_some() && !blocks.is_empty() && last_block.unwrap().height() < blocks[0].height()) { blocks_write_lock.clear(); } @@ -162,6 +150,7 @@ impl ShareChain for InMemoryShareChain { Ok(last_block.height()) } + #[allow(clippy::cast_possible_truncation)] async fn generate_shares(&self, reward: u64) -> Vec { let mut result = vec![]; let miners = self.miners_with_shares().await; diff --git a/src/sharechain/tests/mod.rs b/src/sharechain/tests/mod.rs index 5857229..2ead599 100644 --- a/src/sharechain/tests/mod.rs +++ b/src/sharechain/tests/mod.rs @@ -1 +1,4 @@ +// Copyright 2024 The Tari Project +// SPDX-License-Identifier: BSD-3-Clause + mod test; diff --git a/src/sharechain/tests/test.rs b/src/sharechain/tests/test.rs index 3be77be..ced8c23 100644 --- a/src/sharechain/tests/test.rs +++ b/src/sharechain/tests/test.rs @@ -1,3 +1,6 @@ +// Copyright 2024 The Tari Project +// SPDX-License-Identifier: BSD-3-Clause + #[cfg(test)] mod tests { use minotari_app_grpc::tari_rpc::{Block, BlockHeader, ProofOfWork, SubmitBlockRequest}; @@ -21,7 +24,7 @@ mod tests { fn new_sharechain_blocks(n: u64) -> Vec { let mut blocks = Vec::new(); - for i in 1..n + 1 { + for i in 1..=n { let block = BlockBuilder::new() .with_height(i) .with_miner_wallet_address(new_random_address()) @@ -107,7 +110,8 @@ mod tests { assert_eq!(share.value, 1); } let chain = InMemoryShareChain::default(); - let _ = chain.submit_blocks(blocks, false).await; + let op = chain.submit_blocks(blocks, false).await; + drop(op); // every miner has obtained 2% of 100 shares (= 2) let shares = chain.generate_shares(200).await;