You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a EOS smart-contract developer I need plain and simple API to manage local testnets.
I need API to start and stop a testnet and query its status.
I may want to start more then one testnet (eg. in CI environments)
Testnets created with EOS Factory should be isolated from each other and should not interfere with a testnet I may have spawned on my own using stardard EOS tools.
Below is an example and of how new API (let's call it EOS Factory 2.0 for the time being) could feel like. It should be considered a starting point for a discussion with the EOS community about how ideal API for testing smart-contract should look like and what features should it provide. Everyone is welcome to contribute proposition, opinion and - what would be most valuable - describe real-live use cases. Let's discuss the idea and try to specify the API in comments.
eosf.TestnetCfg is a constructor of a testnet configuration.
Options used in the above example were taken from a command line used by EOS Factory to spawn nodeos processes and should be considered only as an example and not an exhaustive list of all the options.
All the options supported by EOS Factory should have reasonable default values. For example:
For network addresses - if not specified, localhost should be used
For port numbers - if not specified, an unused number from documented range should be taken
For paths - if not specified, random not existing folder under /tmp should be used (e.g. /tmp/eosf-XXXXX where XXXXX is a random number)
Why separate configuration from the actual command
The testnet on its own is of no use. It brings a value only if we can interact with it, for example, to create a user account and its keys or to deploy a smart-contract. To support those interactions, we will have separate APIs, and we need an easy way to configure them to work with a specified testnet.
Below is an example of how this other APIs could use testnet configuration (note: this is just an example and not specification - we will have a discussion on this in a separate issue):
import eosfactory as eosf
eosf.cleos_for_net(testnet_cfg).deploy_smart_contract(....)
The other example of configuration object usage is a cfg.file_in_workspace function from the first listing. It creates a path to file in a folder where other data related to given testnet reside.
Why separate command from its execution
The cmd value returned from nodeos_cmd function in the first example above is a sequence of nodeos arguments (first item of which is a path to binary itself) suitable to be used as the first argument to Popen constructor from Python standard subprocess module. This way developer can have full control over how nodeos is executed.
We should also provide convenient functions to execute and manage EOS binaries. One of such function is eosf.run_cmd_async(). It uses Popen internally to hide some nasty details from smart-contract developers (like the need for pipelines creation). It could also wait for nodeos to become responsive (i.e. ready to serve requests) before it returns execution. eosf.kill_and_wait() is another one, that sends a TERM signal to a process, waits for it to stop and returns its status code.
The text was updated successfully, but these errors were encountered:
It seems fairily straightforward and intuitive, so I would say so. One thing that I think is fairly lacking in the current verson of eosfactory is the ability to include external contracts from other repositories. For instance, I need to use the eosio.token contract in some of my tests but in order to do so, I need to clone the eosio.contracts repository and link it in each of my tests.
With this new api you could have some like include_contracts, which will clone the repository in a cache, build it, and make it readily avaliable. Of course this will require each repository to have a standard way of buidling the contracts (some repository may just use cmake directly, while others use a shell script); a eosfactory.cfg file could work
As a EOS smart-contract developer I need plain and simple API to manage local testnets.
Below is an example and of how new API (let's call it EOS Factory 2.0 for the time being) could feel like. It should be considered a starting point for a discussion with the EOS community about how ideal API for testing smart-contract should look like and what features should it provide. Everyone is welcome to contribute proposition, opinion and - what would be most valuable - describe real-live use cases. Let's discuss the idea and try to specify the API in comments.
Testnet configuration
eosf.TestnetCfg
is a constructor of a testnet configuration.Options used in the above example were taken from a command line used by EOS Factory to spawn
nodeos
processes and should be considered only as an example and not an exhaustive list of all the options.All the options supported by EOS Factory should have reasonable default values. For example:
localhost
should be used/tmp
should be used (e.g./tmp/eosf-XXXXX
where XXXXX is a random number)Why separate configuration from the actual command
The testnet on its own is of no use. It brings a value only if we can interact with it, for example, to create a user account and its keys or to deploy a smart-contract. To support those interactions, we will have separate APIs, and we need an easy way to configure them to work with a specified testnet.
Below is an example of how this other APIs could use testnet configuration (note: this is just an example and not specification - we will have a discussion on this in a separate issue):
The other example of configuration object usage is a
cfg.file_in_workspace
function from the first listing. It creates a path to file in a folder where other data related to given testnet reside.Why separate command from its execution
The
cmd
value returned fromnodeos_cmd
function in the first example above is a sequence ofnodeos
arguments (first item of which is a path to binary itself) suitable to be used as the first argument toPopen
constructor from Python standardsubprocess
module. This way developer can have full control over hownodeos
is executed.We should also provide convenient functions to execute and manage EOS binaries. One of such function is
eosf.run_cmd_async()
. It usesPopen
internally to hide some nasty details from smart-contract developers (like the need for pipelines creation). It could also wait fornodeos
to become responsive (i.e. ready to serve requests) before it returns execution.eosf.kill_and_wait()
is another one, that sends a TERM signal to a process, waits for it to stop and returns its status code.The text was updated successfully, but these errors were encountered: