Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch committed Dec 20, 2024
1 parent 3c0fc3c commit 0def230
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
8 changes: 4 additions & 4 deletions docs/build/guides/testing/differential-tests.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Assuming the contract has been deployed, and changes are being made to the local
}
```

3. Run the test to compare the baseline and local observable outcomes.
4. Run the test to compare the baseline and local observable outcomes.

This test uses the same patterns used in [unit tests] and [integration tests]:

Expand All @@ -112,8 +112,8 @@ Depending on the test complexity it can be desirable to use an independent `Env`

[Getting Started]: ../../smart-contracts/getting-started
[increment example]: https://github.com/stellar/soroban-examples/blob/main/increment/src/lib.rs
[Differential Testing with Test Snapshots]: ./differential-testing-with-test-snapshots
[Differential Testing with Test Snapshots]: differential-testing-with-test-snapshots.mdx
[stellar contract fetch]: ../../tools/developer-tools/cli/stellar-cli#stellar-contract-fetch
[integration tests]: ./integration-tests
[unit tests]: ./unit-tests
[integration tests]: integration-tests.mdx
[unit tests]: unit-tests.mdx
[stellar/rs-soroban-sdk#1360]: https://github.com/stellar/rs-soroban-sdk/issues/1360
56 changes: 28 additions & 28 deletions docs/build/guides/testing/integration-tests.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,34 @@ The following tests set up the `increment-with-pause` contract, as well as impor
}
```

3. Write a test similar to the following that registers not only the increment-with-pause contract, but also the pause contract that was imported. The test checks that when the pause contract is not paused that the increment contract operates as expected. When it is paused, the increment function errors. Once it's unpaused the function operates as expected.

```rust
#[test]
fn test() {
let env = Env::default();

// highlight-start
let pause_id = env.register(pause::WASM, ());
let pause_client = pause::Client::new(&env, &pause_id);
// highlight-end

let contract_id = env.register(
IncrementContract,
IncrementContractArgs::__constructor(&pause_id),
);
let client = IncrementContractClient::new(&env, &contract_id);

pause_client.set(&false);
assert_eq!(client.increment(), 1);

pause_client.set(&true);
assert_eq!(client.try_increment(), Err(Ok(Error::Paused)));

pause_client.set(&false);
assert_eq!(client.increment(), 2);
}
```
3. Write a test similar to the following that registers not only the increment-with-pause contract, but also the pause contract that was imported. The test checks that when the pause contract is not paused that the increment contract operates as expected. When it is paused, the increment function errors. Once it's unpaused the function operates as expected.

```rust
#[test]
fn test() {
let env = Env::default();

// highlight-start
let pause_id = env.register(pause::WASM, ());
let pause_client = pause::Client::new(&env, &pause_id);
// highlight-end

let contract_id = env.register(
IncrementContract,
IncrementContractArgs::__constructor(&pause_id),
);
let client = IncrementContractClient::new(&env, &contract_id);

pause_client.set(&false);
assert_eq!(client.increment(), 1);

pause_client.set(&true);
assert_eq!(client.try_increment(), Err(Ok(Error::Paused)));

pause_client.set(&false);
assert_eq!(client.increment(), 2);
}
```

Most tests, whether they're unit, mocks, or integration tests, will look very similar to the test above. The tests will do four things:

Expand Down

0 comments on commit 0def230

Please sign in to comment.