rust-ipfs icon indicating copy to clipboard operation
rust-ipfs copied to clipboard

More interop tests

Open ljedrz opened this issue 4 years ago • 0 comments

Since we can now run interop tests against go-ipfs and js-ipfs quite easily, we could adjust some of our existing tests so that they automatically become interop tests with the right feature turned on.

Consider the recent changes to tests::connect_two::connect_two_nodes_by_addr, where the following piece of code:

let node_b = Node::new("b").await;

became:

#[cfg(any(feature = "test_go_interop", feature = "test_js_interop"))]
mod common;
#[cfg(any(feature = "test_go_interop", feature = "test_js_interop"))]
use common::interop::ForeignNode;

...

#[cfg(all(not(feature = "test_go_interop"), not(feature = "test_js_interop")))]
let node_b = Node::new("b").await;
#[cfg(any(feature = "test_go_interop", feature = "test_js_interop"))]
let node_b = ForeignNode::new();

It should be as simple with many other tests, as it's very often just a 2-node setup where the first one connects to the other after learning its Multiaddr or PeerId via a call to .identity(), which is also implemented by ForeignNode.

While not much can be done about the unsightly extra top-module test imports, the creation of either Node or ForeignNode can probably be delegated to a nice macro that would reside in tests::common. Note: in order to avoid a headache, remember that macros reside at the top-level of a crate.

ljedrz avatar Sep 08 '20 14:09 ljedrz