# Implémentation de Duniter en Rust?

**URL:** <https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543>\
**Category:** Dunitrust\
**Created:** [2 November 2017 15:25 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543 "2017-11-02T15:25:07Z")\
**Posts on this page:** 20\
**Page:** 5

<div class="post-metadata">

**Author:** ![nanocryk](https://forum.duniter.org/user_avatar/forum.duniter.org/nanocryk/32/4599_2.png) [@nanocryk](https://forum.duniter.org/u/nanocryk)\
**Post date:** [10 November 2017 09:54 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/81 "2017-11-10T09:54:53Z")

</div>

@cgeek Ca serait possible de tester a nouveau `yarn run test` ? Chez moi yarn plante avec le code `3221225477`. Apparemment c’est un bug avec Windows, et là je vois pas trop comment faire.

---

<div class="post-metadata">

**Author:** ![cgeek](https://forum.duniter.org/user_avatar/forum.duniter.org/cgeek/32/279_2.png) [@cgeek](https://forum.duniter.org/u/cgeek)\
**Post date:** [10 November 2017 13:19 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/82 "2017-11-10T13:19:24Z")

</div>

J’essaierai de tester en fin d’après-midi, ce soir ou demain.

---

<div class="post-metadata">

**Author:** ![cgeek](https://forum.duniter.org/user_avatar/forum.duniter.org/cgeek/32/279_2.png) [@cgeek](https://forum.duniter.org/u/cgeek)\
**Post date:** [11 November 2017 09:41 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/83 "2017-11-11T09:41:07Z")

</div>

J’ai seulement 2 tests qui échouent :

```
$ yarn run test
yarn run v1.3.2
$ node "node_modules/mocha/bin/mocha" tests/

  Testing getPaths()
    ✓ wotb.getPaths() should return arrays with the size of the paths

  MEMORY
    Basic operations
      ✓ should have a file path in FILE mode
      ✓ should have an initial size of 0
      ✓ should not throw if testing isEnabled() with out-of-bounds node
      ✓ should give number 0 if we add a node
      ✓ should add certs only in the boundaries of maxCert
      ✓ should not throw if testing existsLink() with inbounds link
      ✓ should not throw if testing existsLink() with out-of-bounds source
      ✓ should not throw if testing existsLink() with out-of-bounds target
      ✓ first 4 nodes should be enabled
      ✓ last node should be enabled
      ✓ should be able to disable some nodes
      ✓ nodes 0 and 2 should be disabled
      ✓ should not exist a link from 2 to 0
      ✓ should be able to add some links
      ✓ should exist new links
      ✓ should be able to remove some links
      ✓ should exist less links
      ✓ should successfully use distance rule
      ✓ should have 12 nodes
      ✓ delete top node
      ✓ should have 11 nodes
      ✓ should work with member 3 disabled
      ✓ should be able to make a mem copy
    Building a larger WoT
      ✓ should have an initial size of 0
      testing around 2 with d = 1
        ✓ should have 10 sentries
        ✓ distance k = 1
        ✓ distance k = 2
        1) distance k = 5
      testing around 2 with d = 2
        ✓ should have 2 sentries
        ✓ distance k = 1
        ✓ distance k = 2
        ✓ distance k = 3
        ✓ distance k = 4
        ✓ distance k = 5
      testing around 2 with d = 3
        ✓ distance k = 1
        ✓ distance k = 2
        ✓ distance k = 5

  MEMORY 2
    Basic operations
      ✓ should have a file path in FILE mode
      ✓ should have an initial size of 0
      ✓ should not throw if testing isEnabled() with out-of-bounds node
      ✓ should give number 0 if we add a node
      ✓ should add certs only in the boundaries of maxCert
      ✓ should not throw if testing existsLink() with inbounds link
      ✓ should not throw if testing existsLink() with out-of-bounds source
      ✓ should not throw if testing existsLink() with out-of-bounds target
      ✓ first 4 nodes should be enabled
      ✓ last node should be enabled
      ✓ should be able to disable some nodes
      ✓ nodes 0 and 2 should be disabled
      ✓ should not exist a link from 2 to 0
      ✓ should be able to add some links
      ✓ should exist new links
      ✓ should be able to remove some links
      ✓ should exist less links
      ✓ should successfully use distance rule
      ✓ should have 12 nodes
      ✓ delete top node
      ✓ should have 11 nodes
      ✓ should work with member 3 disabled
      ✓ should be able to make a mem copy
    Building a larger WoT
      ✓ should have an initial size of 0
      testing around 2 with d = 1
        ✓ should have 10 sentries
        ✓ distance k = 1
        ✓ distance k = 2
        2) distance k = 5
      testing around 2 with d = 2
        ✓ should have 2 sentries
        ✓ distance k = 1
        ✓ distance k = 2
        ✓ distance k = 3
        ✓ distance k = 4
        ✓ distance k = 5
      testing around 2 with d = 3
        ✓ distance k = 1
        ✓ distance k = 2
        ✓ distance k = 5

  FILE
    Basic operations
Segmentation fault (core dumped)
error Command failed with exit code 139.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```

---

<div class="post-metadata">

**Author:** ![nanocryk](https://forum.duniter.org/user_avatar/forum.duniter.org/nanocryk/32/4599_2.png) [@nanocryk](https://forum.duniter.org/u/nanocryk)\
**Post date:** [11 November 2017 13:04 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/84 "2017-11-11T13:04:40Z")

</div>

C’est bizarre, il me semble qu’ils sont présent dans le code Rust et qu’ils passent. Je ne suis pas chez moi, je regarde quand je rentre.

---

<div class="post-metadata">

**Author:** ![cgeek](https://forum.duniter.org/user_avatar/forum.duniter.org/cgeek/32/279_2.png) [@cgeek](https://forum.duniter.org/u/cgeek)\
**Post date:** [11 November 2017 13:52 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/85 "2017-11-11T13:52:36Z")

</div>

En tous les cas à la fin je tombe sur un :

```
Segmentation fault (core dumped)

```

Donc tous les tests ne passent pas encore, la procédure s’arrête aux test mémoire.

---

<div class="post-metadata">

**Author:** ![nanocryk](https://forum.duniter.org/user_avatar/forum.duniter.org/nanocryk/32/4599_2.png) [@nanocryk](https://forum.duniter.org/u/nanocryk)\
**Post date:** [13 November 2017 12:49 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/86 "2017-11-13T12:49:50Z")

</div>

> [@cgeek](#):
>
> En tous les cas à la fin je tombe sur un :
> 
> Segmentation fault (core dumped)

J’ai le même log que toi, sauf que moi ça ne me donne pas le message d’erreur.  
Hmm … D’où sort le `wot.bin` utilisé dans le test original ?  
Je vais rajouter le fait que si le fichier n’existe pas alors il créé une WoT vide.

---

<div class="post-metadata">

**Author:** ![cgeek](https://forum.duniter.org/user_avatar/forum.duniter.org/cgeek/32/279_2.png) [@cgeek](https://forum.duniter.org/u/cgeek)\
**Post date:** [13 November 2017 13:14 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/87 "2017-11-13T13:14:19Z")

</div>

> [@nanocryk](#):
>
> D’où sort le wot.bin utilisé dans le test original ?

Dès que `newFileInstance(...)` est appelé, le fichier est créé.

---

<div class="post-metadata">

**Author:** ![nanocryk](https://forum.duniter.org/user_avatar/forum.duniter.org/nanocryk/32/4599_2.png) [@nanocryk](https://forum.duniter.org/u/nanocryk)\
**Post date:** [13 November 2017 13:28 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/88 "2017-11-13T13:28:23Z")

</div>

Hmm, ça plante encore. En mettant un `console.log` dans `AtomicFileWebOfTrust::constructor` avant et après mon appel natif, j’obtient 6 paires de log. Du coup ça ne plante pas au niveau de mon appel natif, mais plus tard. J’ai trouvé comment debug avec `mocha`, mais je n’arrive pas à catch le `Segmentation fault`. 😕

---

<div class="post-metadata">

**Author:** ![cgeek](https://forum.duniter.org/user_avatar/forum.duniter.org/cgeek/32/279_2.png) [@cgeek](https://forum.duniter.org/u/cgeek)\
**Post date:** [13 November 2017 13:49 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/89 "2017-11-13T13:49:04Z")

</div>

Le segfault ne se catch pas, il se situe dans NodeJS lui-même (le “meta-monde” C++ qui interprète le JS). Il te faut le trouver en débogant Rust directement.

---

<div class="post-metadata">

**Author:** ![nanocryk](https://forum.duniter.org/user_avatar/forum.duniter.org/nanocryk/32/4599_2.png) [@nanocryk](https://forum.duniter.org/u/nanocryk)\
**Post date:** [13 November 2017 13:52 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/90 "2017-11-13T13:52:39Z")

</div>

Je n’ai pas ce bug quand je lance le test en Rust. Là je suis en train de chercher où ça plante dans le code JS à coup debug, espions et point d’arrêt. Il faut que j’ai au moins une idée d’où ça peut se situer. Je ne pense pas que la segfault se trouve dans `duniter-rs-wotb`, mais peut-être dans le code Rust de `duniter-rs-wotb-js` car il interragis avec du code unsafe de `neon`.

---

<div class="post-metadata">

**Author:** ![nanocryk](https://forum.duniter.org/user_avatar/forum.duniter.org/nanocryk/32/4599_2.png) [@nanocryk](https://forum.duniter.org/u/nanocryk)\
**Post date:** [13 November 2017 13:59 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/91 "2017-11-13T13:59:06Z")

</div>

Il plante en dehors des tests. J’ai suivi en pas à pas et il plante dans du code de Mocha après avoir fini

```auto
testSuite("FILE3", FILE_MODE);

```

---

<div class="post-metadata">

**Author:** ![nanocryk](https://forum.duniter.org/user_avatar/forum.duniter.org/nanocryk/32/4599_2.png) [@nanocryk](https://forum.duniter.org/u/nanocryk)\
**Post date:** [13 November 2017 14:12 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/92 "2017-11-13T14:12:27Z")

</div>

@cgeek Tu pourrais me dire si tu as une segfault en lançant :

```auto
yarn
node ./build/index.js

```

Je n’ai pas d’affichage du segfault dans mon terminal (surement l’OS qui ne l’affiche pas contrairement à Linux)

---

<div class="post-metadata">

**Author:** ![nanocryk](https://forum.duniter.org/user_avatar/forum.duniter.org/nanocryk/32/4599_2.png) [@nanocryk](https://forum.duniter.org/u/nanocryk)\
**Post date:** [13 November 2017 14:41 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/93 "2017-11-13T14:41:01Z")

</div>

Quelle version de NodeJS je dois utiliser pour être compatible avec duniter-ts ?

---

<div class="post-metadata">

**Author:** ![elois](https://forum.duniter.org/user_avatar/forum.duniter.org/elois/32/1541_2.png) [@elois](https://forum.duniter.org/u/elois)\
**Post date:** [13 November 2017 14:42 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/94 "2017-11-13T14:42:12Z")

</div>

> [@nanocryk](#):
>
> Quelle version de NodeJS je dois utiliser pour être compatible avec duniter-ts ?

la version 6.11

---

<div class="post-metadata">

**Author:** ![cgeek](https://forum.duniter.org/user_avatar/forum.duniter.org/cgeek/32/279_2.png) [@cgeek](https://forum.duniter.org/u/cgeek)\
**Post date:** [13 November 2017 14:45 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/95 "2017-11-13T14:45:21Z")

</div>

> [@nanocryk](#):
>
> Tu pourrais me dire si tu as une segfault en lançant :

Je n’ai aucune sortie.

> [@nanocryk](#):
>
> Je n’ai pas d’affichage du segfault dans mon terminal (surement l’OS qui ne l’affiche pas contrairement à Linux)

Peut-être devrais-tu avoir une VM à Linux à côté, pour faire ce genre de comparaisons tranquillement.

---

<div class="post-metadata">

**Author:** ![cgeek](https://forum.duniter.org/user_avatar/forum.duniter.org/cgeek/32/279_2.png) [@cgeek](https://forum.duniter.org/u/cgeek)\
**Post date:** [13 November 2017 14:46 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/96 "2017-11-13T14:46:23Z")

</div>

> [@elois](#):
>
> la version 6.11

On peut mettre directement “6” : [Nouveau tutoriel de développement - #14 by cgeek](https://forum.duniter.org/t/nouveau-tutoriel-de-developpement/3570/14)

Moul avait mis 6.11 mais c’est trop restrictif.

---

<div class="post-metadata">

**Author:** ![nanocryk](https://forum.duniter.org/user_avatar/forum.duniter.org/nanocryk/32/4599_2.png) [@nanocryk](https://forum.duniter.org/u/nanocryk)\
**Post date:** [13 November 2017 14:47 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/97 "2017-11-13T14:47:41Z")

</div>

Je vais essayer avec le sous-système Linux de Win10. Je pourrais aussi essayer avec la bonne version de Node, je n’arrive pas à avoir `nvm` sous Win.

---

<div class="post-metadata">

**Author:** ![cgeek](https://forum.duniter.org/user_avatar/forum.duniter.org/cgeek/32/279_2.png) [@cgeek](https://forum.duniter.org/u/cgeek)\
**Post date:** [13 November 2017 14:51 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/98 "2017-11-13T14:51:22Z")

</div>

Je te conseille vraiment l’utilisation d’une VM Ubuntu, ça coûte vraiment pas cher à ça te donne l’assurance d’un système isolé.

Personnellement, je ne veux pas t’aider à déboguer les problèmes Windows.

---

<div class="post-metadata">

**Author:** ![nanocryk](https://forum.duniter.org/user_avatar/forum.duniter.org/nanocryk/32/4599_2.png) [@nanocryk](https://forum.duniter.org/u/nanocryk)\
**Post date:** [13 November 2017 14:57 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/99 "2017-11-13T14:57:37Z")

</div>

D’acc, je vais installer une VM. Tu me conseille quoi ? VirtualBox ?

---

<div class="post-metadata">

**Author:** ![cgeek](https://forum.duniter.org/user_avatar/forum.duniter.org/cgeek/32/279_2.png) [@cgeek](https://forum.duniter.org/u/cgeek)\
**Post date:** [13 November 2017 14:59 UTC](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543/100 "2017-11-13T14:59:51Z")

</div>

Oui, VirtualBox est sous licence GPLv2 et fait très bien le boulot.

Je te conseille aussi une Ubuntu pour aller au plus simple possible.

[Previous page](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543.md?page=4)

[Next page](https://forum.duniter.org/t/implementation-de-duniter-en-rust/3543.md?page=6)
