owned this note
owned this note
Published
Linked with GitHub
---
title: "System Test for Facilitator"
disqus: https://hackmd.io/lk4D6ZVYRBOmU9QeexiafA
---
# System Test for Facilitator
| Version | Last Updated | Component |
| ------- | ------------ | --------------------------- |
| 0.14 | 02/03/2020 | System Test for Facilitator |
## Overview
A framework to test facilitator code over prolonged duration. This will test complex scenarios multiple deposits and withdraws for multiple random group of depositors and withdrawers. This framework will execute both the deposit and withdraw requests in a concurrent manner to test the limit of the M1 facilitator. This will also send summary reports with respect to change in balances and with respect to message hash validation.
## User stories
1. As a user, I should have the `config.json` with all the required configuration parameters
1. As a user, I should have at least 20 keystore addresses and their passwords and these should have Göerli Ether funded to them on the origin and utility token funded to them on the metachain
1. As a user, I should be able to select random addresses according to the concurrency count from the available keystore addresses
1. As a user, I should be able to fund the randomly selected addresses with the OST/value tokens on the origin and gas on the metachain using the faucet
1. As a user, I should be able to perform concurrent deposit and withdraw requests
1. As a user, I should be able to get the OST/value token balance on the origin
1. As a user, I should be able to get the utility token balance on the metachain
1. As a user, I should generate a random `amount` to be deposited within the provided `minAmount` and `maxAmount` values for the deposit and withdraw transaction object
1. As a user, I should generate a random `gasPrice` within the provided `minGasPrice` and `maxGasPrice` values for the deposit and withdraw transaction object
1. As a user, I should generate a random `gasLimit` within the provided `minGasLimit` and `maxGasLimit` values for the deposit and withdraw transaction object
1. As a user, I should be able to create transaction object for deposit for any of the selected random account
1. As a user, I should be able to broadcast the created deposit transaction object to the origin chain
1. As a user, I should get the expected random deposit amount for all the accounts when creating the deposit transaction object
1. As a user, I should be able to get the `DepositIntentDeclared` event parameters using the deposit transaction receipt and store them for report generation
1. As a user, I should be able to create transaction object for withdraw for any of the selected random account
1. As a user, I should be able to broadcast the created withdraw transaction object to the metachain
1. As a user, I should get the expected random withdraw amount for all the accounts when creating the withdraw transaction object
1. As a user, I should be able to get the `WithdrawIntentDeclared` event parameters using the deposit transaction receipt and store them for report generation
1. As a user, I should wait for `pollingInterval` when a iteration is complete
1. As a user, I should wait for `timeoutInterval` when all the iterations are complete
1. As a user, I should generate `Balance` and `MessageHash` reports after the `timeoutInterval` is complete
1. As a user, I should return the remaining OST/value tokens for all the test accounts on the origin chain to the funder address after the generation of report
1. As a user, I should return the remaining gas on the metachain for all the test accounts to the funder address after the generation of report
## Implementation Level Details
### Configuration file:
A json `config.json` file with below schema
```json
{
"chains": {
"origin": {
"wsEndpoint":"",
"graphEndpoint": "",
"valueToken": "",
"gateway":"",
"faucet": ""
},
"auxiliary": {
"wsEndpoint":"",
"graphEndpoint": "",
"utilityToken": "",
"cogateway":""
"faucet": ""
}
},
"testData": {
"deposit": {
"iterations": "10",
"depositorCount": "10",
"concurrencyCount": "5",
"pollingInterval": "1",
"timeoutInterval": "20",
"minAmount": "150",
"maxAmount": "250",
"minGasPrice": "5",
"maxGasPrice": "15",
"minGasLimit": "2",
"maxGasLimit": "5"
},
"withdraw": {
"iterations": "10",
"withdrawerCount": "6",
"concurrencyCount": "5",
"pollingInterval": "2",
"timeoutInterval": "20",
"minAmount": "150",
"maxAmount": "250",
"minGasPrice": "5",
"maxGasPrice": "15",
"minGasLimit": "2",
"maxGasLimit": "5"
}
},
"accounts": [
"0xqwe...iop",
"0xasd...jkl",
"0xzxc...bnm",
...
],
}
```
### System test steps:
1. Generate accounts(20) and save them in folder `accounts`
- If the address is `0xabc` then encrypted keys under file name `0xabc.json` and the password under the file name `0xabc.password`
1. Fund all the generated accounts sufficiently on the origin chain with the Göerli Ether for the deposit flow
1. Fund all the generated accounts sufficiently on the metachain with the utility token for the withdraw flow
Deposit flow:
1. Get the test depositor accounts at random from the `config.json` based on the `depositorCount` and `accounts`, these test depositor accounts will be decrypted and saved using the provided passwords
1. Start an iteration with all the bellow steps
1. Select random test depositor accounts based on the value of `depositorCount` and `concurrencyCount`
1. Fund the accounts with OST/value token on the origin chain using faucet
1. Store the initial OST/value token balances on the origin for the test accounts
1. Store the initial Utility token balances on the metachain for the test accounts
1. Create deposit transaction object for all the test accounts in an iteration
1. Store the expected decrease in origin account balances for all the test accounts in the iteration
1. Broadcast the created deposit transaction
1. Retrieve and store the values `amount`, `nonce`, `beneficiary`, `feeGasPrice`, `feeGasLimit`, `depositor`, `valueToken`, and `messageHash` from the event using the transaction receipt. These will be used for report generation
1. Wait for the `pollingInterval` at the end of every iteration
1. Wait for the `timeoutInterval` when all the iteration are completed
1. Calculate the final utility token balance on the metachain of the test accounts
1. Generate `balance` report
1. Generate `messageHash` report
Withdraw flow:
1. Get the test withdrawer accounts at random from the `config.json` based on the `withdrawerCount`, these test withdrawer accounts will be decrypted and saved using the provided passwords
1. Start an iteration with all the bellow steps
1. Select random test withdrawer accounts based on the value of `withdrawerCount` and `concurrencyCount`
1. Fund the accounts with Base token token on the metachain chain using faucet
1. Store the initial Utility token balances on the metachain for the test accounts
1. Store the initial OST/value token balances on the origin for the test accounts
1. Create withdraw transaction object for all the test accounts in an iteration
1. Store the expected decrease in metachain account utility token balances for all the test accounts in the iteration
1. Broadcast the created withdraw transaction
1. Retrieve and store the values `amount`, `nonce`, `beneficiary`, `feeGasPrice`, `feeGasLimit`, `withdrawer`, `utilityToken`, and `messageHash` from the event using the transaction receipt. These will be used for report generation
1. Wait for the `pollingInterval` at the end of every iteration
1. Wait for the `timeoutInterval` when all the iteration are completed
1. Calculate the final OST/value token balance on the origin of the test accounts
1. Generate `balance` report
1. Generate `messageHash` report
Finally:
- Check the OST/value token balances for all the test accounts on the origin chain and refund them to the funder
- Check the Base token balance for all the test accounts on the metachain and refund them to the funder
### Report
1. Balance report(Deposit flow):
![](https://i.imgur.com/01P3jr5.png)
This can be similarly generated for the withdraw flow
1. MessageHash report:
![](https://i.imgur.com/72rY2FD.png)
This will be generated for both the deposit and withdraw flow