rust-ipfs
rust-ipfs copied to clipboard
More interop tests
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.