dtr-org / unit-e

A digital currency for a new era of decentralized trust
https://unit-e.io
MIT License
45 stars 15 forks source link

Write functional test that checks p2p messages serialization/deserialization #1020

Open AM5800 opened 5 years ago

AM5800 commented 5 years ago

Currently we don't have any dedicated tests for the test framework itself - we only test what we use. One thing that seems important is messages serialization/deserialization.

I propose to write a test that will look like following:

node0                 node1
   \                    /
   mininode0 ------ mininode1

So all network traffic goes through mininodes. And we ensure that it is not altered during serialization/deserialization

kostyantyn commented 5 years ago

Technically we should have p2p_*.py test for every p2p message we have. But I see our p2p tests check too much. Should we have p2p_<message>_schema.py separately or you plan to list all p2p messages in one test and send them through the proposed setup?

Also, If I understood correctly, you expect that node0 or node1 sends messages, right? For some p2p messages, a particular setup is required. Do you plan to "bypass" this setup or create such an environment for node0/node1 that it will start producing such messages?

AM5800 commented 5 years ago

Should we have p2p__schema.py separately or you plan to list all p2p messages in one test and send them through the proposed setup?

Initial idea was to list them in one test. However it might get too big and perhaps we will have to split by feature or something else. I would say that this will be better to decide once we start working on this test(s).

There is another option though: we can create a MininodeRelay class that will just connect two nodes. And replace direct nodes connection with this relay in several existing tests which allow this.

Also, If I understood correctly, you expect that node0 or node1 sends messages, right?

Right.

create such an environment for node0/node1 that it will start producing such messages

This is what I would like to test - real messages. Not carefully hand-constructed ones

cmihai commented 5 years ago

There is another option though: we can create a MininodeRelay class that will just connect two nodes. And replace direct nodes connection with this relay in several existing tests which allow this.

For an example of this, check out esperanza_expired_vote_conflict.py.

AM5800 commented 5 years ago

@cmihai yeah, the thing you pointed was actually created by me. But It unfortunately skips serialization/deserialization completely - it relays the whole received buffer.