Testing
Last updated
Was this helpful?
Last updated
Was this helpful?
To aid in testing we provide a separate mock_dependencies_custom
function that provides handlers for specific ADO contracts. This can be found . The following mock variables are used:
To use the dependencies simply create your mock dependencies variable like so:
To get started you must first create an instance of the MockAndromeda
struct:
This process will set up the aOS mock contracts and make them accessible through this struct.
The admin_address
has ownership of the aOS and as such can make adjustments as required. It is also registered under the VFS as user am
, therefore any ADOs registered with the admin address would be accessible via ~/am/...
when using the VFS.
The next step is to add some ADOs to the setup, this can be done with the store_ado
method:
All our mock contracts implement two structs; MockContract
and MockADO
. The MockContract
struct exposes simple query and execute methods while MockADO
exposes any messages that an ADO may provide such as ownership and permissioning. To implement both these structs in a quick and easy manner we have provided a macro:
Once this is done you can either create the contract directly or you can create it as part of an app. If you create it using the MockApp
struct provided in andromeda-app-contract
the mock contract struct can be created via a query:
Mock structs have been provided for most ADOs however they are still a work in progress.
To help with setting up a testing environment using aOS we can use the MockAndromedaBuilder
struct. This allows definition of what wallets and contracts you would like to use while testing:
In the above example we specify a few things:
Here we set the wallet name that has admin privileges over the aOS, in this case "admin"
. Next up we define a few extra wallets:
This generates two wallets ("owner"
and "user1"
) and assigns 1000 uandr to the "owner"
wallet. Here the provided names are not addresses but are simply names. These can be accessed using:
Next we include the contracts we would like to use:
In this case we would like to use the CW721 contract and the App contract, the provided names can also be version (e.g. "[email protected]"
). The stored code IDs for these can be accessed via their names like so:
The rest of the integration test should continue as usual.
A cw-multi-test
based testing library for integration testing custom ADO contracts and how they interact with the aOS. Source code is found .
Here the second parameter is a cw-multi-test
and the third is a name for the ADO. This can be used to access the code id by calling andr.get_code_id(&router, "app")
. Repeat this process for any ADOs you wish to add (including your own).