Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on imdl to run tests? #241

Closed
josecelano opened this issue Aug 1, 2023 · 0 comments
Closed

Remove dependency on imdl to run tests? #241

josecelano opened this issue Aug 1, 2023 · 0 comments
Labels
Code Cleanup / Refactoring Tidying and Making Neat Question / Discussion Community Feedback

Comments

@josecelano
Copy link
Member

We are using the intermodal console command to generate torrents for testing.

Whenever we need a test torrent, we generate a random text file and then use the imdl command to create the torrent file. You can read this PR comment to understand how test torrent can be generated using imdl.

We have a wrapper for the imdl command. See https://github.com/torrust/torrust-index-backend/blob/develop/tests/common/contexts/torrent/file.rs#L32-L52

Recently we have started creating the test torrent direct the same way we build to torrent files for the API endpoint to download the torrent file. That endpoint builds the torrent file from that data in the database. On this PR, we introduced a new endpoint to generate random torrent files we needed to test the frontend. We wanted to test the torrent upload with cypress.

Now that we have started generating test torrents directly without using a third-party package, I suggest removing the dependency on imdl to run unit tests.

The module to generate and parse torrent files for testing is: https://github.com/torrust/torrust-index-backend/blob/develop/tests/common/contexts/torrent/file.rs

But I see two problems:

  1. We also use the imdl to parse torrent files. We could also use our code to parse torrent files but ...
  2. I do not like to use production code to test production code.

I've opened an issue on the intermodal repo asking them for a package. If they release a package, we could start using the package instead using the console command. Alternatively, we could create our own package to create/parse torrent files.

One thing I miss from imdl is it does not give you the pieces. THis is an example output for imdl in json format:

{
  "name": "file-d6170378-2c14-4ccc-870d-2a8e15195e23.txt",
  "comment": null,
  "creation_date": 1690537323,
  "created_by": "imdl/0.1.12",
  "source": null,
  "info_hash": "a366418d2ac082bcdd57ddae3449ab4ad52f6a84",
  "torrent_size": 201,
  "content_size": 37,
  "private": false,
  "tracker": null,
  "announce_list": [],
  "update_url": null,
  "dht_nodes": [],
  "piece_size": 16384,
  "piece_count": 1,
  "file_count": 1,
  "files": [
    "file-d6170378-2c14-4ccc-870d-2a8e15195e23.txt"
  ]
}

And this is what you get using another service like: https://chocobo1.github.io/bencode_online/

{
   "created by": "imdl/0.1.12",
   "creation date": 1690537323,
   "encoding": "UTF-8",
   "info": {
      "length": 37,
      "name": "file-d6170378-2c14-4ccc-870d-2a8e15195e23.txt",
      "piece length": 16384,
      "pieces": "<hex>3E E7 F3 33 EA A5 CC D1 33 84 A3 85 F9 32 6B 2E 18 0F FB 20</hex>"
   }
}
@josecelano josecelano added Code Cleanup / Refactoring Tidying and Making Neat Question / Discussion Community Feedback labels Aug 1, 2023
@cgbosse cgbosse moved this to Maintenance in Torrust Solution Jan 10, 2024
@cgbosse cgbosse moved this from Maintenance to Help Wanted in Torrust Solution Jan 11, 2024
@torrust torrust locked and limited conversation to collaborators Jan 16, 2024
@cgbosse cgbosse converted this issue into discussion #435 Jan 16, 2024
@github-project-automation github-project-automation bot moved this from Help Wanted to Done in Torrust Solution Jan 16, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Code Cleanup / Refactoring Tidying and Making Neat Question / Discussion Community Feedback
Projects
Status: Done
Development

No branches or pull requests

1 participant