hyperlane-xyz / fuel-contracts

5 stars 2 forks source link

Hyperlane Fuel / Sway contracts

Getting set up

Follow the Sway book's installation instructions.

Building and testing everything

To build all packages:

forc build && cargo build

To test all packages:

forc test && cargo test

How to work in this repo

A package defines a single contract, and possibly many libraries.

Libraries that require testing should be implemented in their own package, and another test package should exist with the same name and a suffix -test.

There are two types of tests in Fuel/Sway - unit tests that are implemented fully in Sway, and "integration tests" in Rust that involve deploying contracts and making calls against them. Unit tests are not fully built out, so we instead opt for Rust-based tests. See the Sway book for more info. See Testing with Rust to set up Rust tests in a new package.

To build a single package, from its directory:

forc build

To test a single package, from its directory run the following. This requires Rust integration tests to be present. Add on -- --nocapture to observe logs.

cargo test

To format a package:

forc fmt

Fuel / Sway resources

Troubleshooting

If cargo build or cargo test fails with a message like:

attempted ssh-agent authentication, but no usernames succeeded: `git`

Try following these instructions: https://github.com/rust-lang/cargo/issues/3381#issuecomment-308460530