Skip to content

Commit

Permalink
dex/testing: Clean up markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
xorzero777 committed Jul 10, 2023
1 parent 987ac91 commit b028ec1
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 121 deletions.
104 changes: 42 additions & 62 deletions dex/testing/firo/README_ELECTRUM_HARNESSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,116 +11,100 @@ See Also: README_HARNESS.md

## 2. ElectrumX-Firo Test Harness

The harness is a script named **electrumx.sh** which downloads a git repo
The harness is a script named **electrumx.sh** which downloads a git repo
containing a release version of ElectrumX-Firo server.

It requires **harness.sh** Firo chain server harness running
It requires **harness.sh** Firo chain server harness running.

## 3. Electrum-Firo Test Harness

The harness is a script named **electrum.sh** which downloads a git repo containg
release version of Electrum-Firo wallet client.
The harness is a script named **electrum.sh** which downloads a git repo containing
a release version of Electrum-Firo wallet client.

It requires **electrumx.sh** Firo ElectrumX-Firo server harness running
It requires **electrumx.sh** Firo ElectrumX-Firo server harness running.

Which in turn requires **harness.sh** Firo chain server harness running
Which in turn requires **harness.sh** Firo chain server harness running.

## Dependencies

The **harness.sh** script depends on [firod] and [firo-cli] to run.
https://github.com/firoorg/firo/releases binaries or build from source
Go to <https://github.com/firoorg/firo/releases> for binaries or source.

The **electrumx.sh** script depends on [python3], [python3 pip] and [git] to run.
Python3 v3.6 is coded but this script was tested using python3.10. Some testing
Python3 v3.6 is coded but this script was tested using python3.10. Some testing
(minimal) was done with 3.7. Git should be latest. Pip will be downloaded and it's version upgraded by the script into a virtual environment each time.

The **electrum.sh** script depends on [python3], [python3 pip] and [git] to run.
Python3 v3.6 is coded but this script was tested using python3.10. Some testing
(minimal) was done with 3.7. Python 3.8, 3.9 would be expected to work although
untested. However using Python 3.11 there are dependencies which will not build
and are unsupported by their repective maintainers on PyPI.

Git should be latest. Pip will be downloaded and
veriosn upgraded by the script into a virtual environment each time.
and are unsupported by their respective maintainers on PyPI. Git should be latest.Pip will be re-downloaded and it's version upgraded by the script into a virtual environment each time.

The **electrum.sh** script depends on [python3], [python3 pip] and [git] to run.
Python3 v3.6 is coded but this script was tested using python3.10. Some testing
(minimal) was done with 3.7. Git should be latest. Pip will be re-downloaded and
version upgraded by the script into a virtual environment each time.
### Architecture

_Architecture_
```
ELECTRUM WALLET CLIENT
```
```
ELECTRUMX SERVER
```
```
FIRO CHAIN HARNESS
```
- ELECTRUM WALLET CLIENT
- ELECTRUMX SERVER
- FIRO CHAIN HARNESS

All three scripts store data in **~/dextest/...** dirsectory tree.

## Using

You must have `firod` and `firo-cli` in `PATH` to use the harness. Use 3 tty's
and run each line below in a separate tty:
You must have `firod` and `firo-cli` in `PATH` to use the chain server harness. Use 3 tty's
and run each line below in a **separate** tty:

```
```bash
$ ./harness.sh
```
```
$ ./electrumx.sh
```
```
$ ./electrum.sh
```

The Electrum-Firo wallet client will have a prepared, empty but encrypted
regtest wallet.

Password is "abc"
Password is "abc".

## Dev
## Development

### Firo Chain Server

For the Firo chain server see the README_HARNESS.md in this directory
For the Firo chain server see the README_HARNESS.md in this directory.

### Server

The **electrumx.sh** script first cleans part of the **~/dextest/electrum/firo/server...**
directory tree.

The script then downloads a specific commit from:
https://github.com/firoorg/electrumx-firo.git
to the ../server/electrumx-repo directory
<https://github.com/firoorg/electrumx-firo.git> to the .../server/electrumx-repo directory.

It then creates a python virtual environment (venv) sandbox and installs the
It then creates a python virtual environment (venv) sandbox and installs the
requesting python3 interpreter, latest version of pip and all required modules
in `setup.py` into the sandbox.
If any need building from C source it will be done at this point.

Server certificates are created. Then all the required environment veriables to
configure the server exported. and the electrumX daemon started
in `setup.py` into the sandbox.
If any need building from C source it will be done at this point.

The electrumX daemon will connect to the firo chain harness node __alpha__
Server certificates are created. Then all the required environment variables to
configure the server exported; and the electrumX daemon started

The electrumX daemon will connect to the firo chain harness node **alpha**

### Client

The **electrum.sh** script first cleans part of the **~/dextest/electrum/firo/client...**
directory tree.

The script then downloads a specific commit from:
https://github.com/firoorg/electrum-firo.git
to the ../client/electrum-repo directory
<https://github.com/firoorg/electrum-firo.git> to the ../client/electrum-repo directory.

It then creates a python virtual environment (venv) sandbox and installs the
It then creates a python virtual environment (venv) sandbox and installs the
requesting python3 interpreter, latest version of pip and all required modules
from files in `contrib/requirements`
directory into the sandbox. If any need building from C source it will be done at
from files in `contrib/requirements` directory into the sandbox. If any need building from C source it will be done at
this point.

A prepared, empty but encrypted electrum wallet is copied to the electrum data
directory at **~/dextest/electrum/firo/client/wallet/regtest/wallets** directory.

The electrum client wallet will connect to the firo electrumX daemon

The electrum client wallet will connect to the firo electrumX daemon.

### Simnet Trade Testing

Expand All @@ -133,15 +117,11 @@ In seperate tty's start up:
- electrum.sh Electrum-Firo regtest wallet
- dcrdex harness

ensure dcrctl, firod and firo-cli are in PATH for simnet-trade-tests exec process
mining

$ ./run dcrfiroelectrum --runonce \<testcase\>

Example:
Ensure dcrctl, firod and firo-cli are in PATH for simnet-trade-tests exec process
mining.

`$ ./run dcrfiroelectrum --runonce --all`


Best results by nuking everything after each run
```bash
$ ./run dcrfiroelectrum --runonce --all
```

Best results by nuking everything after each run.
97 changes: 48 additions & 49 deletions dex/testing/firo/README_HARNESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,82 +6,80 @@ sandboxed environment for testing dex swap transactions.
## Dependencies

The harness depends on [firod] and [firo-cli] to run.
https://github.com/firoorg/firo/releases binaries or build from source
Go to <https://github.com/firoorg/firo/releases> for binaries or source.

## Using

You must have `firod` and `firo-cli` in `PATH` to use the harness.

The harness script will create four connected regtest nodes **alpha**, **beta**,
**gamma**, **delta**. Each node will have one empty but encrypted wallet. The script
will mine some blocks and send some regular transactions.

```
# This simnet harness sets up 4 Firo nodes and a set of harness controls
# Each node has a prepared, encrypted, empty wallet
# alpha/
# ├── alpha.conf
# └── regtest
# ├── wallet.dat
# beta/
# ├── beta.conf
# └── regtest
# ├── wallet.dat
# gamma/
# ├── gamma.conf
# └── regtest
# ├── wallet.dat
# delta/
# ├── delta.conf
# └── regtest
# ├── wallet.dat
# └── harness-ctl
# ├── alpha
# ├── beta
# ├── connect-alpha
# ├── delta
# ├── gamma
# ├── mine-alpha
# ├── mine-beta
# ├── quit
# ├── reorg
# ├── start-wallet
# └── stop-wallet
**gamma**, **delta**. Each node will have one empty but encrypted wallet. The script will mine some blocks and send some regular transactions.

This simnet harness sets up 4 Firo nodes and a set of harness controls
Each node has a prepared, encrypted, empty wallet

```text
alpha/
├── alpha.conf
└── regtest
├── wallet.dat
beta/
├── beta.conf
└── regtest
├── wallet.dat
gamma/
├── gamma.conf
└── regtest
├── wallet.dat
delta/
├── delta.conf
└── regtest
├── wallet.dat
└── harness-ctl
├── alpha
├── beta
├── connect-alpha
├── delta
├── gamma
├── mine-alpha
├── mine-beta
├── quit
├── reorg
├── start-wallet
└── stop-wallet
```

**alpha** is purely a mining node/wallet, and will have mostly coinbase
UTXOs to spend.

**beta**, **gamma**, **delta** will all connect to **alpha** as peers
**beta**, **gamma**, **delta** will all connect to **alpha** as peers.

## Harness Control Scripts

The `./harness.sh` script will drop you into a tmux window in a directory
called `harness-ctl`. Inside of this directory are a number of scripts to
called `harness-ctl`. Inside this directory are a number of scripts to
allow you to perform RPC calls against each wallet.

`./alpha` `./beta` `./gamma` `./delta` are just `firo-cli` configured for their
respective node-wallets.

`./alpha getbalance`, for example.

__Other Examples__
### Other Examples

`./reorg` will step through a script that causes the alpha node to
undergo a reorg.
`./reorg` will step through a script that causes the alpha node to undergo a reorg.

`./quit` shuts down the nodes and closes the tmux session.

## Background Miner

By default the harness also sets up a background miner which mines on the alpha
node every 15s. This can upset some test logic so it can be disabled by
setting envoronment var NOMINER="1"
setting environment var NOMINER="1"

## Dev Stuff

Expand All @@ -97,10 +95,11 @@ zombie firod processes preventing the harness nodes from binding to the
specified ports. You'll have to manually hunt down the zombie PIDs and `kill`
them if this happens.

__Zombie Killer__
### Zombie Killer

(debian)
```

```bash
$ killall -9 firod # kill running daemons
$ tmux kill-session -t firo-harness # kill firo-harness session
```
```
20 changes: 10 additions & 10 deletions dex/testing/firo/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@
## ElectrumX Test

This runs a test which accesses:

- Firo testnet electrumX server: __95.179.164.13:51002__
- Firo mainnet electrumX server: __electrumx.firo.org:50002__

Optionally:
- Firo simnet ElectrumX server running a dex testing harness chain

It tests the capabilities of the server
- Firo simnet ElectrumX server running a dex testing harness chain.

It tests the capabilities of the server.

## Dependencies

The regtest/simnet server test has a dependency on:

- The Firo harness chain: __harness.sh__
- The Firo simnet electrumx server: __electrumx.sh__

The simnet ElectrumX server (electrumx.sh) should connect over RPC to the
The simnet ElectrumX server (electrumx.sh) should connect over RPC to the
harness chain.

## Testing mainnet, testnet only
Expand All @@ -28,17 +31,14 @@ __go test -v -count=1 ./...__

## Testing mainnet, testnet and additionally with regtest

Start **./harness.sh** tmux script which starts 4 instances of the Firo regtest
harness chain
Start **./harness.sh__ tmux script which starts 4 instances of the Firo regtest
harness chain.

Set environment REGTEST="1"

Run **./electrumx.sh** which starts a Firo ElectrumX server that accesses the
harness chain over RPC
Run __./electrumx.sh__ which starts a Firo ElectrumX server that accesses the
harness chain over RPC.

Run as a Go test:

__go test -v -count=1 ./...__



0 comments on commit b028ec1

Please sign in to comment.