Building SAFE network crates in Linux

Environment: Linux Mint 17.2 Cinnamon 64-bit
Testing Crate: Crust

I’m sharing my current steps for building and testing crust. I have used @philip_rhoades’s script in the past to update and build everything, but it can take quite a while to build everything from scratch. So, a lot of times including after the latest developer update, I just use the text commands to build a single crate at a time. This is the full process:

  1. Run a script to update rust nightly to the current version, which just runs this command “curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly”. I saved it into a bash script so I wouldn’t have to remember that, called update-rust.sh. You don’t need to run under sudo, it will ask for permission during the script.
  2. If you don’t have the source downloaded, clone the crust repository with “git clone https://github.com/maidsafe/crust.git”. Otherwise, change dir into the crust directory, and run “git pull”. (It’s possible this won’t get the latest versions if you’ve been modifying the source, so look in the output for issues like this.)
  3. From within the crust directory, run “cargo clean”, removing all previous built code in this crate.
  4. Run “cargo update”, updating cargo’s knowledge of its crate repositories.
  5. Run “cargo build”.
  6. Run “EXPORT RUST_TEST_THREADS=1”, setting this environment variable that some tests need (it seems like this can be combined on one line with the test command below separated by space, but I haven’t tried it. I wonder if this sets the value just for the duration of the command.).
  7. Run “cargo test”.

And the test results were as follows:

running 20 tests
test beacon::test::test_avoid_beacon … ok
test beacon::test::test_beacon … ok
test bootstrap_handler::test::duplicates … ok
test bootstrap_handler::test::max_contacts … ok
test bootstrap_handler::test::oldest … ok
test bootstrap_handler::test::prune … ok
test bootstrap_handler::test::serialisation … ok
test config_utils::test::read_config_file_test … ok
test connection_manager::test::bootstrap … ok
test connection_manager::test::bootstrap_off_list_connects … ok
test connection_manager::test::bootstrap_off_list_connects_multiple … ok
test connection_manager::test::connection_manager … ok
test connection_manager::test::connection_manager_start … ok
test connection_manager::test::network … ignored
test getifaddrs::test::test_filter_loopback … ok
test getifaddrs::test::test_getifaddrs … ok
test tcp_connections::test::test_multiple_nodes_small_stream … ok
test tcp_connections::test::test_small_stream … ok
test test::check_rust_unit_testing_is_not_parallel … ok
test transport::test::test_ord … ok

test result: ok. 19 passed; 0 failed; 1 ignored; 0 measured

If you’re building other crates, you don’t need to update rust or update cargo again. That is a global update. Let me know if you have any questions for me about the process.

Thanks,
Noah

4 Likes

I’m on Fedora, how would I adapt this to do it here? Also what exactly does this test do exactly? Does it just connect to the network? Can you exchange data? What?

These tests are just tests - verifying expected behaviour. They don’t offer useful functionality - for that, wait for the installers which are due any day now.

1 Like

I’m not that familiar with Fedora. I would think the same exact commands would most likely work, though. The only thing really required to be installed before hand is git, which is used to download the source and update it from github. Git was installed by default in Linux Mint, but the normal software installation repositories in Fedora would have it for sure. Cargo is installed through the rust install. The rust install command should work for anything Linux or Mac according to the rust install page:

I guess let us know if you run into problems with those commands.

Any day now you say? Now don’t you know the dangers of dangling carrots? :smiley:

1 Like