Skip to content

Commit 2dba602

Browse files
Rename test_ to step_ for clarity
1 parent 14b51cb commit 2dba602

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

contract-examples/test/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# Testing Precompiles
22

3-
If you can, put all of your test logic into DS-test tests. Prefix test functions with `test_`. There's also a `setUp` function that gets called before the test contract is deployed. The current best-practice is to re-deploy one test contract per `test` function called in `*.ts` test definitions. The `setUp` method should be called once, then `test_` functions passed in as the 2nd argument to `test("<description>", <test_function_name_OR_array_of_test_function_names>)` will be called in order. `test.only` and `test.skip` behave the same way as `it.only` and `it.skip`. There's also a `test.debug` that combines `test.only` with some extra event logging (you can use `emit log_string` to help debug Solidity test code).
3+
If you can, put all of your test logic into DS-test tests. Prefix test functions with `step_`. There's also a `setUp` function that gets called before the test contract is deployed. The current best-practice is to re-deploy one test contract per `test` function called in `*.ts` test definitions. The `setUp` method should be called once, then `step_` functions passed in as the 2nd argument to `test("<description>", <step_function_name_OR_array_of_step_function_names>)` will be called in order. `test.only` and `test.skip` behave the same way as `it.only` and `it.skip`. There's also a `test.debug` that combines `test.only` with some extra event logging (you can use `emit log_string` to help debug Solidity test code).
44

55
The `test` function is a wrapper around Mocha's `it` function. It provides a normalized framework for running the
66
majority of your test assertions inside of a smart-contract, using `DS-Test`.
77
The API can be used as follows (all of the examples are equivalent):
88

99
```ts
10-
test("<test_name>", "<contract_function_name>");
10+
test("<step_name>", "<contract_function_name>");
1111

12-
test("<test_name>", ["<contract_function_name>"]);
12+
test("<step_name>", ["<contract_function_name>"]);
1313

14-
test("<test_name>", {
14+
test("<step_name>", {
1515
method: "<contract_function_name>",
1616
overrides: {},
1717
shouldFail: false,
1818
debug: false,
1919
});
2020

21-
test("<test_name>", [
21+
test("<step_name>", [
2222
{
2323
method: "<contract_function_name>",
2424
overrides: {},
@@ -28,7 +28,7 @@ test("<test_name>", [
2828
]);
2929

3030
test(
31-
"<test_name>",
31+
"<step_name>",
3232
[{ method: "<contract_function_name>", shouldFail: false, debug: false }],
3333
{}
3434
);
@@ -37,7 +37,7 @@ test(
3737
Many contract functions can be called as a part of the same test:
3838

3939
```ts
40-
test("<test_name>", ["<test_fn1>", "<test_fn2>", "<test_fn3>"])
40+
test("<test_name>", ["<step_fn1>", "<step_fn2>", "<step_fn3>"])
4141
```
4242

4343
Individual test functions can describe their own overrides with the `overrides` property.
@@ -46,11 +46,11 @@ functions.
4646
The following are equivalent:
4747

4848
```ts
49-
test("<test_name>", [
49+
test("<step_name>", [
5050
{ method: "<contract_function_name>", overrides: { from: "0x123" } },
5151
]);
5252

53-
test("<test_name>", [{ method: "<contract_function_name>" }], {
53+
test("<step_name>", [{ method: "<contract_function_name>" }], {
5454
from: "0x123",
5555
});
5656
```

contract-examples/test/utils.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ const assert = require("assert")
88
* majority of your test assertions inside of a smart-contract, using `DS-Test`.
99
* The API can be used as follows (all of the examples are equivalent):
1010
* ```ts
11-
* test("<test_name>", "<contract_function_name>")
12-
* test("<test_name>", ["<contract_function_name>"])
13-
* test("<test_name>", { method: "<contract_function_name>", overrides: {}, shouldFail: false, debug: false })
14-
* test("<test_name>", [{ method: "<contract_function_name>", overrides: {}, shouldFail: false, debug: false }])
15-
* test("<test_name>", [{ method: "<contract_function_name>", shouldFail: false, debug: false }], {})
11+
* test("<step_name>", "<contract_function_name>")
12+
* test("<step_name>", ["<contract_function_name>"])
13+
* test("<step_name>", { method: "<contract_function_name>", overrides: {}, shouldFail: false, debug: false })
14+
* test("<step_name>", [{ method: "<contract_function_name>", overrides: {}, shouldFail: false, debug: false }])
15+
* test("<step_name>", [{ method: "<contract_function_name>", shouldFail: false, debug: false }], {})
1616
* ```
1717
* Many contract functions can be called as a part of the same test:
1818
* ```ts
19-
* test("<test_name>", ["<test_fn1>", "<test_fn2>", "<test_fn3>"])
19+
* test("<step_name>", ["<step_fn1>", "<step_fn2>", "<step_fn3>"])
2020
* ```
2121
* Individual test functions can describe their own overrides with the `overrides` property.
2222
* If an object is passed in as the third argument to `test`, it will be used as the default overrides for all test
2323
* functions.
2424
* The following are equivalent:
2525
* ```ts
26-
* test("<test_name>", [{ method: "<contract_function_name>", overrides: { from: "0x123" } }])
27-
* test("<test_name>", [{ method: "<contract_function_name>" }], { from: "0x123" })
26+
* test("<step_name>", [{ method: "<contract_function_name>", overrides: { from: "0x123" } }])
27+
* test("<step_name>", [{ method: "<contract_function_name>" }], { from: "0x123" })
2828
* ```
2929
* In the above cases, the `from` override must be a signer.
3030
* The `shouldFail` property can be used to indicate that the test function should fail. This should be used sparingly
@@ -69,8 +69,8 @@ const buildTestFn = (fnNameOrObject: FnNameOrObject, overrides = {}, debug = fal
6969
return fnNameOrObject as MethodWithDebugAndOverrides
7070
})
7171

72-
// only `test_` prefixed functions can be called on the `DSTest` contracts to clearly separate tests and helpers
73-
assert(fnObjects.every(({ method }) => method.startsWith('test_')), "Solidity test functions must be prefixed with 'test_'")
72+
// only `step_` prefixed functions can be called on the `DSTest` contracts to clearly separate tests and helpers
73+
assert(fnObjects.every(({ method }) => method.startsWith('step_')), "Solidity test functions must be prefixed with 'step_'")
7474

7575
// return the test function that will be used by `it`
7676
// this function must be defined with the `function` keyword so that `this` is bound to the Mocha context

0 commit comments

Comments
 (0)