forked from marmarachain/marmara
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jl777#1757 from jl777/FSM
FSM
- Loading branch information
Showing
15 changed files
with
1,892 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: CI test | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
ci: | ||
name: ${{ matrix.os }} CI | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
os: [macOS-latest, ubuntu-18.04] | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Install deps (Linux) | ||
if: runner.os == 'Linux' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get upgrade -y | ||
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool libncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libboost-all-dev libssl-dev libprotobuf-dev protobuf-compiler libqrencode-dev libdb++-dev ntp ntpdate nano software-properties-common curl libevent-dev libcurl4-gnutls-dev cmake clang libsodium-dev -y | ||
# params we will need for tests execution | ||
./zcutil/fetch-params.sh | ||
- name: Build (Linux) | ||
if: runner.os == 'Linux' | ||
run: | | ||
# flag for some CC tests transactions - so DO NOT USE THIS CI ARTIFACTS IN PRODUCTION!!! | ||
CONFIGURE_FLAGS='CPPFLAGS=-DTESTMODE' ./zcutil/build.sh -j$(nproc) | ||
- name: Install deps (macOS) | ||
if: runner.os == 'macOS' | ||
run: | | ||
brew update | ||
brew upgrade | ||
brew tap discoteq/discoteq; brew install flock | ||
brew install autoconf autogen automake | ||
brew install gcc@8 | ||
brew install binutils | ||
brew install protobuf | ||
brew install coreutils | ||
brew install wget | ||
./zcutil/fetch-params.sh | ||
- name: Build (macOS) | ||
if: runner.os == 'macOS' | ||
run: | | ||
# flag for some CC tests transactions - so DO NOT USE THIS CI ARTIFACTS IN PRODUCTION!!! | ||
export CPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ | ||
CONFIGURE_FLAGS='CPPFLAGS=-DTESTMODE' ./zcutil/build-mac.sh -j4 | ||
- name: Run CC tests | ||
if: runner.os == 'Linux' || runner.os == 'macOS' | ||
run: | | ||
cd qa/rpc-tests/cc_pytest | ||
./ci_setup.sh | ||
job-win-build: | ||
|
||
name: Win Build | ||
runs-on: ubuntu-16.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Build Win on Unix | ||
env: | ||
DEBIAN_FRONTEND: noninteractive | ||
if: runner.os == 'Linux' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get upgrade -y | ||
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool libncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libboost-all-dev libssl-dev libprotobuf-dev protobuf-compiler libqrencode-dev libdb++-dev ntp ntpdate nano software-properties-common curl libevent-dev libcurl4-gnutls-dev cmake clang libsodium-dev -y | ||
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl cmake mingw-w64 | ||
curl https://sh.rustup.rs -sSf | sh -s -- -y | ||
source $HOME/.cargo/env | ||
rustup target add x86_64-pc-windows-gnu | ||
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix | ||
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix | ||
./zcutil/build-win.sh -j 2 | ||
- name: Upload komodod.exe as artifact | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: komodod.exe | ||
path: ./src/komodod.exe | ||
|
||
#TODO: windows tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Updated RPC unit-tests infrastructure for Antara smart-chain custom modules | ||
|
||
Using pytest as testing framework and slickrpc as rpc proxy. No more python2 support. | ||
|
||
To start just set test nodes RPC credentials in `test_config.json`. | ||
I thought such config usage might be useful as in some manual testing plays as well as in some CI configuration tests integration. | ||
|
||
`is_fresh_chain=False` param allows to run tests on existing chains (it skips some tests which expecting first CC usage on chain) | ||
|
||
So yes - you can run these tests on existing chains, just RPC creds (and wallets with some balance) needed. | ||
|
||
# Dependencies | ||
|
||
`pip3 install setuptools wheel slick-bitcoinrpc pytest wget` | ||
|
||
# Usage | ||
|
||
In `~/komodo/qa/rpc-tests/cc_pytest` directory: | ||
|
||
`python3 -m pytest -s` - starts all tests suite | ||
`python3 -m pytest test_dice.py -s` - starts specific test, dice in this case | ||
|
||
`-s` flag is optional, just displaying python prints which might be helpful in debugging | ||
|
||
`ci_test.sh` script will start a all CCs full test suite from bootstrapped chain - best way to start the tests | ||
|
||
The `start_chains.py` script can spin needed amount of nodes and start the test chain. | ||
You can find an example of this script usage in `ci_setup.sh`. Don't forget to change `test_config.json` accordingly to the chain params. | ||
|
||
Also there is bootstrap downloading functionality in `start_chains.py` what should be quite useful for automated testing setups | ||
|
||
Happy testing! <3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# chains start script params | ||
export CLIENTS=2 | ||
export CHAIN="TONYCI" | ||
export TEST_ADDY="RPWhA4f4ZTZxNi5K36bcwsWdVjSVDSjUnd" | ||
export TEST_WIF="UpcQympViQpLmv1WzMwszKPrmKUa28zsv8pdLCMgNMXDFBBBKxCN" | ||
export TEST_PUBKEY="02f0ec2d3da51b09e4fc8d9ba334c275b02b3ab6f22ce7be0ea5059cbccbd1b8c7" | ||
export TEST_ADDY2="RHoTHYiHD8TU4k9rbY4Aoj3ztxUARMJikH" | ||
export TEST_WIF2="UwmmwgfXwZ673brawUarPzbtiqjsCPWnG311ZRAL4iUCZLBLYeDu" | ||
export TEST_PUBKEY2="0285f68aec0e2f8b5e817d71a2a20a1fda74ea9943c752a13136a3a30fa49c0149" | ||
export CHAIN_MODE="REGULAR" | ||
export IS_BOOTSTRAP_NEEDED="True" | ||
export BOOTSTRAP_URL="http://159.69.45.70/bootstrap.tar.gz" | ||
|
||
# starting the chains | ||
python3 start_chains.py | ||
|
||
# starting the tests | ||
python3 -m pytest -s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import os | ||
import time | ||
import sys | ||
import subprocess | ||
import wget | ||
import tarfile | ||
from slickrpc import Proxy | ||
|
||
|
||
clients_to_start = int(os.environ['CLIENTS']) | ||
ac_name = os.environ['CHAIN'] | ||
# node1 params | ||
test_address = os.environ['TEST_ADDY'] | ||
test_wif = os.environ['TEST_WIF'] | ||
test_pubkey = os.environ['TEST_PUBKEY'] | ||
# node2 params | ||
test_address2 = os.environ['TEST_ADDY2'] | ||
test_wif2 = os.environ['TEST_WIF2'] | ||
test_pubkey2 = os.environ['TEST_PUBKEY2'] | ||
# expecting REGTEST or REGULAR there | ||
chain_start_mode = os.environ['CHAIN_MODE'] | ||
# expecting True or False string there | ||
is_boostrap_needed = os.environ['IS_BOOTSTRAP_NEEDED'] | ||
bootstrap_url = os.environ['BOOTSTRAP_URL'] | ||
|
||
# pre-creating separate folders and configs | ||
for i in range(clients_to_start): | ||
os.mkdir("node_" + str(i)) | ||
open("node_" + str(i) + "/" + ac_name + ".conf", 'a').close() | ||
with open("node_" + str(i) + "/" + ac_name + ".conf", 'a') as conf: | ||
conf.write("rpcuser=test" + '\n') | ||
conf.write("rpcpassword=test" + '\n') | ||
conf.write("rpcport=" + str(7000 + i) + '\n') | ||
conf.write("rpcbind=0.0.0.0\n") | ||
conf.write("rpcallowip=0.0.0.0/0\n") | ||
|
||
|
||
if is_boostrap_needed == "True": | ||
wget.download(bootstrap_url, "bootstrap.tar.gz") | ||
tf = tarfile.open("bootstrap.tar.gz") | ||
for i in range(clients_to_start): | ||
tf.extractall("node_" + str(i)) | ||
|
||
# start numnodes daemons, changing folder name and port | ||
for i in range(clients_to_start): | ||
# all nodes should search for first "mother" node | ||
if i == 0: | ||
start_args = ['../../../src//komodod', '-ac_name='+ac_name, '-ac_supply=999999', '-ac_reward=100000000000', '-conf=' + sys.path[0] + '/node_' + str(i) + "/" + ac_name + ".conf", | ||
'-rpcport=' + str(7000 + i), '-port=' + str(6000 + i), '-datadir=' + sys.path[0] + '/node_' + str(i), | ||
'-ac_supply=10000000000', '-ac_cc=2', '-pubkey=' + test_pubkey, '-whitelist=127.0.0.1'] | ||
if chain_start_mode == 'REGTEST': | ||
start_args.append('-regtest') | ||
start_args.append('-daemon') | ||
else: | ||
start_args.append('-daemon') | ||
subprocess.call(start_args) | ||
time.sleep(5) | ||
else: | ||
start_args = ['../../../src//komodod', '-ac_name='+ac_name, '-ac_supply=999999', '-ac_reward=100000000000', '-conf=' + sys.path[0] + '/node_' + str(i) + "/" + ac_name + ".conf", | ||
'-rpcport=' + str(7000 + i), '-port=' + str(6000 + i), '-datadir=' + sys.path[0] + '/node_' + str(i), | ||
'-ac_supply=10000000000', '-ac_cc=2', '-addnode=127.0.0.1:6000', '-whitelist=127.0.0.1', '-listen=0', '-pubkey='+test_pubkey] | ||
if i == 1: | ||
start_args.append('-pubkey=' + test_pubkey2) | ||
if chain_start_mode == 'REGTEST': | ||
start_args.append('-regtest') | ||
start_args.append('-daemon') | ||
else: | ||
start_args.append('-daemon') | ||
subprocess.call(start_args) | ||
time.sleep(5) | ||
|
||
|
||
# creating rpc proxies for all nodes | ||
for i in range(clients_to_start): | ||
rpcport = 7000 + i | ||
globals()['proxy_%s' % i] = Proxy("http://%s:%[email protected]:%d"%("test", "test", int(rpcport))) | ||
time.sleep(2) | ||
|
||
|
||
# checking if proxies works as expected | ||
for i in range(clients_to_start): | ||
while True: | ||
try: | ||
getinfo_output = globals()['proxy_%s' % i].getinfo() | ||
print(getinfo_output) | ||
break | ||
except Exception as e: | ||
print(e) | ||
time.sleep(2) | ||
|
||
# in case of bootstrap checking also if blocksamount > 100 | ||
if is_boostrap_needed == "True": | ||
assert proxy_0.getinfo()["blocks"] > 100 | ||
assert proxy_1.getinfo()["blocks"] > 100 | ||
assert proxy_0.getinfo()["blocks"] == proxy_1.getinfo()["blocks"] | ||
|
||
|
||
# importing privkeys | ||
print("IMPORTING PRIVKEYS") | ||
print(proxy_0.importprivkey(test_wif, "", True)) | ||
print(proxy_1.importprivkey(test_wif2, "", True)) | ||
# ensuring that node1 got premine and some balance | ||
assert proxy_0.getbalance() > 777 | ||
|
||
# checking if test addys belongs to relevant nodes wallets | ||
assert proxy_0.validateaddress(test_address)["ismine"] == True | ||
assert proxy_1.validateaddress(test_address2)["ismine"] == True | ||
|
||
# checking if pubkeys set properly | ||
assert proxy_0.getinfo()["pubkey"] == test_pubkey | ||
assert proxy_1.getinfo()["pubkey"] == test_pubkey2 | ||
|
||
# starting blocks creation on second node, mining rewards will get first public node because of pubkey param | ||
if chain_start_mode == 'REGTEST': | ||
while True: | ||
if int(os.environ['CLIENTS']) > 1: | ||
proxy_1.generate(1) | ||
time.sleep(5) | ||
else: | ||
proxy_0.generate(1) | ||
time.sleep(5) | ||
else: | ||
if int(os.environ['CLIENTS']) > 1: | ||
print("Starting mining on node 2") | ||
proxy_1.setgenerate(True, 1) | ||
else: | ||
print("Starting mining on node 1") | ||
proxy_0.setgenerate(True, 1) | ||
|
||
# TODO: just to prepare a boostrap if needed | ||
# while True: | ||
# blocks_amount = proxy_0.getinfo()["blocks"] | ||
# if blocks_amount == 130: | ||
# balance = proxy_0.getbalance() | ||
# tx_id = proxy_0.sendtoaddress(test_address, balance - 0.1) | ||
# elif blocks_amount > 130: | ||
# print("Finished with blocks pre-generation") | ||
# proxy_0.stop() | ||
# proxy_1.stop() | ||
# time.sleep(2) | ||
# sys.exit() | ||
# else: | ||
# print(proxy_0.getinfo()["blocks"]) | ||
# time.sleep(5) |
Oops, something went wrong.