How to test that NEAR was transferred?

Viewed 84

Given a contract method that transfer funds:

Promise::new("b.testnet".to_string()).transfer(near_sdk::env::attached_deposit())

How should you write a unit test that checks that the funds were transferred?

1 Answers

Because this is call from one contract to another, you cannot use unit tests to verify expected behavior.

Check out simulation tests here https://crates.io/crates/near-sdk-sim

This works on Rust as well as AssemblyScript contracts because you're actually testing the compiled contract as a Wasm binary

Related