Skip to content

Commit 17e86c6

Browse files
committed
Merge #1112: Extract duplicate code into new package: bittorrent-http-protocol
2bc44af test: add test for percent_encode_byte_array (Jose Celano) a62ae82 fix: cargo machete warning (Jose Celano) 39716a8 ci: fix testing workflow. Run doc tests for all packages (Jose Celano) c61cc9a fix: doc tests (Jose Celano) 555d5b8 fix: [#1097] by extracting duplicate module (Jose Celano) Pull request description: For now, it only contains percent encoding functions. This removes duplicate code and fixes the problem of slow doc tests. On my machine, it takes 40 seconds to run all doc tests with one job. ```console time cargo test --doc --workspace --jobs=1 real 0m40.443s user 6m6.863s sys 0m22.609s ``` I have also fixed the `testing` workflow, it was using `cargo test --doc` to run doc-tests without including doc-test is workspace packages. ACKs for top commit: josecelano: ACK 2bc44af Tree-SHA512: 82b6cfb3ac40ffce437717d800388ab3f4968dc0e73dbb25eae4160378f8280ec3569381d5b58f8d3884ad839b5be320f43e2e246b527932e72ca8572fa79397
2 parents e0245f0 + 2bc44af commit 17e86c6

File tree

16 files changed

+734
-144
lines changed

16 files changed

+734
-144
lines changed

.github/workflows/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ jobs:
5555
env:
5656
CARGO_REGISTRY_TOKEN: "${{ secrets.TORRUST_UPDATE_CARGO_REGISTRY_TOKEN }}"
5757
run: |
58+
cargo publish -p bittorrent-http-protocol
5859
cargo publish -p bittorrent-tracker-client
5960
cargo publish -p torrust-tracker
6061
cargo publish -p torrust-tracker-client

.github/workflows/testing.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ jobs:
140140

141141
- id: test-docs
142142
name: Run Documentation Tests
143-
run: cargo test --doc
143+
run: cargo test --doc --workspace
144144

145145
- id: test
146146
name: Run Unit Tests

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ axum = { version = "0", features = ["macros"] }
3636
axum-client-ip = "0"
3737
axum-extra = { version = "0", features = ["query"] }
3838
axum-server = { version = "0", features = ["tls-rustls-no-provider"] }
39+
bittorrent-http-protocol = { version = "3.0.0-develop", path = "packages/http-protocol" }
3940
bittorrent-primitives = "0.1.0"
4041
bittorrent-tracker-client = { version = "3.0.0-develop", path = "packages/tracker-client" }
4142
blowfish = "0"

contrib/bencode/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
//! Decoding bencoded data:
66
//!
77
//! ```rust
8-
//! extern crate bencode;
8+
//! extern crate torrust_tracker_contrib_bencode;
99
//!
10-
//! use bencode::{BencodeRef, BRefAccess, BDecodeOpt};
10+
//! use torrust_tracker_contrib_bencode::{BencodeRef, BRefAccess, BDecodeOpt};
1111
//!
1212
//! fn main() {
1313
//! let data = b"d12:lucky_numberi7ee"; // cspell:disable-line
@@ -22,7 +22,7 @@
2222
//!
2323
//! ```rust
2424
//! #[macro_use]
25-
//! extern crate bencode;
25+
//! extern crate torrust_tracker_contrib_bencode;
2626
//!
2727
//! fn main() {
2828
//! let message = (ben_map!{

packages/http-protocol/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
description = "A library with the primitive types and functions for the BitTorrent HTTP tracker protocol."
3+
keywords = ["api", "library", "primitives"]
4+
name = "bittorrent-http-protocol"
5+
readme = "README.md"
6+
7+
authors.workspace = true
8+
documentation.workspace = true
9+
edition.workspace = true
10+
homepage.workspace = true
11+
license.workspace = true
12+
publish.workspace = true
13+
repository.workspace = true
14+
rust-version.workspace = true
15+
version.workspace = true
16+
17+
[dependencies]
18+
aquatic_udp_protocol = "0"
19+
bittorrent-primitives = "0.1.0"
20+
percent-encoding = "2"
21+
torrust-tracker-primitives = { version = "3.0.0-develop", path = "../primitives" }

packages/http-protocol/LICENSE

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

packages/http-protocol/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# BitTorrent HTTP Tracker Protocol
2+
3+
A library with the primitive types and functions used by BitTorrent HTTP trackers.
4+
5+
## Documentation
6+
7+
[Crate documentation](https://docs.rs/bittorrent-http-protocol).
8+
9+
## License
10+
11+
The project is licensed under the terms of the [GNU AFFERO GENERAL PUBLIC LICENSE](./LICENSE).

packages/http-protocol/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//! Primitive types and function for `BitTorrent` HTTP trackers.
2+
pub mod percent_encoding;

src/servers/http/percent_encoding.rs renamed to packages/http-protocol/src/percent_encoding.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use torrust_tracker_primitives::peer;
2727
///
2828
/// ```rust
2929
/// use std::str::FromStr;
30-
/// use torrust_tracker::servers::http::percent_encoding::percent_decode_info_hash;
30+
/// use bittorrent_http_protocol::percent_encoding::percent_decode_info_hash;
3131
/// use bittorrent_primitives::info_hash::InfoHash;
3232
/// use torrust_tracker_primitives::peer;
3333
///
@@ -60,7 +60,7 @@ pub fn percent_decode_info_hash(raw_info_hash: &str) -> Result<InfoHash, info_ha
6060
/// use std::str::FromStr;
6161
///
6262
/// use aquatic_udp_protocol::PeerId;
63-
/// use torrust_tracker::servers::http::percent_encoding::percent_decode_peer_id;
63+
/// use bittorrent_http_protocol::percent_encoding::percent_decode_peer_id;
6464
/// use bittorrent_primitives::info_hash::InfoHash;
6565
///
6666
/// let encoded_peer_id = "%2DqB00000000000000000";
@@ -85,7 +85,7 @@ mod tests {
8585
use aquatic_udp_protocol::PeerId;
8686
use bittorrent_primitives::info_hash::InfoHash;
8787

88-
use crate::servers::http::percent_encoding::{percent_decode_info_hash, percent_decode_peer_id};
88+
use crate::percent_encoding::{percent_decode_info_hash, percent_decode_peer_id};
8989

9090
#[test]
9191
fn it_should_decode_a_percent_encoded_info_hash() {

0 commit comments

Comments
 (0)