fuels-rs Testing

note This page is still a work in progress.

Running a Sway script

run_compiled_script is a helper function for testing simple Sway scripts and reducing boilerplate code related to setting up contracts and deployment. It takes the path to the generated .bin file as an argument.

  • You can use it this way:
        let path_to_bin = "../fuels/tests/test_projects/logging/out/debug/logging.bin";
        let return_val = run_compiled_script(path_to_bin).await?;

        let correct_hex =
            hex::decode("ef86afa9696cf0dc6385e2c407a6e159a1103cefb7e2ae0636fb33d3cb2a9e4a");

        assert_eq!(correct_hex?, return_val[0].data().unwrap());

Here you'll find an overview of the various test helpers located in fuels-test-helpers: