Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Feb 18, 2019
1 parent 5b7c22b commit 6f7fa5a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
10 changes: 6 additions & 4 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Editing the Config File

Every project has a file ``brownie-config.json`` that holds all the configuration settings.

The defaut configuration is as follows. When using the brownie console you can view or edit configuration settings through the ``config`` dict.
The defaut configuration is as follows. When using the brownie console or writing scripts, you can view and edit configuration settings through the ``config`` dict. Any changes made in this way are temporary and will be reset when you exit brownie or reset the network.

.. literalinclude:: ../config.json
:linenos:
Expand Down Expand Up @@ -39,16 +39,18 @@ The following settings are available:

* ``optimize``: Set to true if you wish to use contract optimization.
* ``runs``: The number of times the optimizer should run.
* ``version``: The version of solc to use. Should be written as ``v0.x.x``
* ``version``: The version of solc to use. Should be written as ``v0.x.x``.

.. py:attribute:: test
Properties that affect the configuration while running tests. See :ref:`test` for detailed information on the effects of these settings.
Properties that affect only affect Brownie's configuration when running scripts and tests. See :ref:`test` for detailed information on the effects and implications of these settings.

* ``always_transact``: If ``true``, calls to ``view`` and ``pure`` functions will still execute as transactions during tests.

* ``gas_limit``: If set to an integer, this value will over-ride the default gas limit setting when running tests.

* ``default_contract_owner``: If ``false``, deployed contracts will not remember the account that they were created by and you will have to supply a ``from`` kwarg for every contract transaction.

.. py:attribute:: logging
Default logging levels for each brownie mode.
Expand All @@ -65,4 +67,4 @@ The following settings are available:
Default Settings
================

The default settings are found in ``config.json`` in the brownie install folder. Omitting any setting within a project's configuration file will cause Brownie to use the default setting instead.
When you create a new project the configuration file is copied from ``config.json`` in the brownie install folder. Modifying this file will change the default settings for all future projects. Removing any setting within a project's local configuration file will cause Brownie to use the default setting instead.
4 changes: 3 additions & 1 deletion docs/coverage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
Checking Test Coverage
======================

.. warning:: Test coverage analysis is still under development. You may encounter errors or inaccurate results.
.. warning:: Test coverage evaluation is still under development. There may be undiscovered issues, particularly cases where conditional True/False evaluation is incorrect. Use common sense when viewing coverage reports and please report any issues you encounter.

Test coverage is estimated by generating a map of opcodes associated with each function and line of the smart contract source code, and then analyzing the stack trace of each transaction to see which opcodes were executed.

Because calls to view and pure methods typically are not done with a transaction, you must enable the ``always_transact`` configuration setting or your coverage for these methods will show as 0%. See the test :ref:`test_settings` documentation for more information.

To check your unit test coverage, type:

::
Expand Down
16 changes: 13 additions & 3 deletions docs/tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ When running tests, the sequence of events is as follows:

* The EVM is reverted to the snapshot in between calling each method.

* After the final method has completed the test RPC is restarted, the next script is loaded and the process begins again.
* After the final method has completed the test RPC is restarted, configuration settings are reset, the next script is loaded and the process begins again.

Writing Tests
=============

As with scripts, every test should begin with ``from brownie import *`` in order to give access to the :ref:`api`. You can also import and execute scripts as a part of your setup process.

You can define unique configuration settings for each test by modifying the ``config`` dictionary in the ``setup`` method. Any changes that you make are reset when the test completes.

You can optionally include a docstring in each test method to give more verbosity during the testing process.

The following keyword arguments can be used to affect how a test runs:
Expand All @@ -57,7 +59,6 @@ Here is an example test script from ``projects/token/tests/approve_transferFrom.
:language: python
:lines: 3-


Below you can see an example of the output from Brownie when the test script executes. For the example, one of the tests was modified so that it would fail.

::
Expand Down Expand Up @@ -89,6 +90,8 @@ Below you can see an example of the output from Brownie when the test script exe

For available classes and methods when writing a test script, see the :ref:`api` documentation.

.. _test_settings:

Settings and Considerations
===========================

Expand All @@ -99,7 +102,8 @@ The following test configuration settings are available in ``brownie-config.json
{
"test": {
"always_transact": true,
"gas_limit": 65000000
"gas_limit": 65000000,
"default_contract_owner": false
}
}
Expand Down Expand Up @@ -131,3 +135,9 @@ The following test configuration settings are available in ``brownie-config.json
* Transactions that revert will be broadcasted, but still raise a ``VirtualMachineError``.
* Unless the call is handled with ``check.reverts`` the exception will cause the test to fail.
* If you need to access the ``TransactionReceipt`` you can find it the ``history`` list.

.. py:attribute:: default_contract_owner
If ``True``, calls to contract transactions that do not specify a sender are broadcast from the same address that deployed the contract.

If ``False``, contracts will not remember which account they were created by. You must explicitely declare the sender of every transaction with a `transaction parameters <https://web3py.readthedocs.io/en/stable/web3.eth.html#web3.eth.Eth.sendTransaction>`__ dictionary as the last method argument. This may be considered similar to a strict mode.

0 comments on commit 6f7fa5a

Please sign in to comment.