<commit_before>#!/bin/bash

################################################################################################
## PLEASE DISABLE DEV OMNI FOR THESE TESTS!!!                                                 ##
##                                                                                            ##
## The fee distribution tests require an exact amount of Omni in each address.  Dev Omni will ##
## skew these tests by increasing the amount of Omni in the Exodus Address.                   ##
## To use this script in regtest mode, temporarily disable Dev Omni and recompile by adding:  ##
##    return 0;                                                                               ##
## as the first line of the function calculate_and_update_devmsc in omnicore.cpp.  This line  ##
## must be removed and Omni Core recompiled to use on mainnet.                                ##
################################################################################################


PASS=0
FAIL=0
clear
printf "Preparing a test environment...\n"
printf "   * Starting a fresh regtest daemon\n"
rm -r ~/.bitcoin/regtest
./src/omnicored --regtest --server --daemon >nul
sleep 3
printf "   * Preparing some mature testnet BTC\n"
./src/omnicore-cli --regtest setgenerate true 102 >null
printf "   * Obtaining a master address to work with\n"
ADDR=$(./src/omnicore-cli --regtest getnewaddress OMNIAccount)
printf "   * Funding the address with some testnet BTC for fees\n"
./src/omnicore-cli --regtest sendtoaddress $ADDR 20 >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "   * Participating in the Exodus crowdsale to obtain some OMNI\n"
JSON="{\"moneyqMan7uh8FqdCA2BV5yZ8qVrc9ikLP\":10,\""$ADDR"\":4}"
./src/omnicore-cli --regtest sendmany OMNIAccount $JSON >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "   * Creating an indivisible test property\n"
./src/omnicore-cli --regtest omni_sendissuancefixed $ADDR 1 1 0 "Z_TestCat" "Z_TestSubCat" "Z_IndivisTestProperty" "Z_TestURL" "Z_TestData" 10000000 >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "   * Creating a divisible test property\n"
./src/omnicore-cli --regtest omni_sendissuancefixed $ADDR 1 2 0 "Z_TestCat" "Z_TestSubCat" "Z_DivisTestProperty" "Z_TestURL" "Z_TestData" 10000 >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "   * Generating addresses to use as fee recipients (OMNI holders)\n"
ADDRESS=()
for i in {1..6}
do
   ADDRESS=("${ADDRESS[@]}" $(./src/omnicore-cli --regtest getnewaddress))
done
printf "   * Using a total of 1000 OMNI\n"
printf "   * Seeding %s with 50.00 OMNI\n" ${ADDRESS[1]}
./src/omnicore-cli --regtest omni_send $ADDR ${ADDRESS[1]} 1 50.0 >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "   * Seeding %s with 100.00 OMNI\n" ${ADDRESS[2]}
./src/omnicore-cli --regtest omni_send $ADDR ${ADDRESS[2]} 1 100.0 >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "   * Seeding %s with 150.00 OMNI\n" ${ADDRESS[3]}
./src/omnicore-cli --regtest omni_send $ADDR ${ADDRESS[3]} 1 150.0 >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "   * Seeding %s with 200.00 OMNI\n" ${ADDRESS[4]}
./src/omnicore-cli --regtest omni_send $ADDR ${ADDRESS[4]} 1 200.0 >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "\nChecking share of fees for recipients...\n"
printf "   * Checking %s has a 5 percent share of fees... " ${ADDRESS[1]}
FEESHARE=$(./src/omnicore-cli --regtest omni_getfeeshare ${ADDRESS[1]} | grep feeshare | cut -d '"' -f4)
if [ $FEESHARE == "5.0000%" ]
  then
    printf "PASS\n"
    PASS=$((PASS+1))
  else
    printf "FAIL (result:%s)\n" $FEESHARE
    FAIL=$((FAIL+1))
fi
printf "   * Checking %s has a 10 percent share of fees... " ${ADDRESS[2]}
FEESHARE=$(./src/omnicore-cli --regtest omni_getfeeshare ${ADDRESS[2]} | grep feeshare | cut -d '"' -f4)
if [ $FEESHARE == "10.0000%" ]
  then
    printf "PASS\n"
    PASS=$((PASS+1))
  else<commit_msg>Update tests to include fees activation via feature ID 9<commit_after>#!/bin/bash

################################################################################################
## PLEASE DISABLE DEV OMNI FOR THESE TESTS!!!                                                 ##
##                                                                                            ##
## The fee distribution tests require an exact amount of Omni in each address.  Dev Omni will ##
## skew these tests by increasing the amount of Omni in the Exodus Address.                   ##
## To use this script in regtest mode, temporarily disable Dev Omni and recompile by adding:  ##
##    return 0;                                                                               ##
## as the first line of the function calculate_and_update_devmsc in omnicore.cpp.  This line  ##
## must be removed and Omni Core recompiled to use on mainnet.                                ##
################################################################################################


PASS=0
FAIL=0
clear
printf "Preparing a test environment...\n"
printf "   * Starting a fresh regtest daemon\n"
rm -r ~/.bitcoin/regtest
./src/omnicored --regtest --server --daemon --omniactivationallowsender=any >nul
sleep 3
printf "   * Preparing some mature testnet BTC\n"
./src/omnicore-cli --regtest setgenerate true 102 >null
printf "   * Obtaining a master address to work with\n"
ADDR=$(./src/omnicore-cli --regtest getnewaddress OMNIAccount)
printf "   * Funding the address with some testnet BTC for fees\n"
./src/omnicore-cli --regtest sendtoaddress $ADDR 20 >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "   * Participating in the Exodus crowdsale to obtain some OMNI\n"
JSON="{\"moneyqMan7uh8FqdCA2BV5yZ8qVrc9ikLP\":10,\""$ADDR"\":4}"
./src/omnicore-cli --regtest sendmany OMNIAccount $JSON >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "   * Creating an indivisible test property\n"
./src/omnicore-cli --regtest omni_sendissuancefixed $ADDR 1 1 0 "Z_TestCat" "Z_TestSubCat" "Z_IndivisTestProperty" "Z_TestURL" "Z_TestData" 10000000 >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "   * Creating a divisible test property\n"
./src/omnicore-cli --regtest omni_sendissuancefixed $ADDR 1 2 0 "Z_TestCat" "Z_TestSubCat" "Z_DivisTestProperty" "Z_TestURL" "Z_TestData" 10000 >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "   * Generating addresses to use as fee recipients (OMNI holders)\n"
ADDRESS=()
for i in {1..6}
do
   ADDRESS=("${ADDRESS[@]}" $(./src/omnicore-cli --regtest getnewaddress))
done
printf "   * Using a total of 1000 OMNI\n"
printf "   * Seeding %s with 50.00 OMNI\n" ${ADDRESS[1]}
./src/omnicore-cli --regtest omni_send $ADDR ${ADDRESS[1]} 1 50.0 >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "   * Seeding %s with 100.00 OMNI\n" ${ADDRESS[2]}
./src/omnicore-cli --regtest omni_send $ADDR ${ADDRESS[2]} 1 100.0 >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "   * Seeding %s with 150.00 OMNI\n" ${ADDRESS[3]}
./src/omnicore-cli --regtest omni_send $ADDR ${ADDRESS[3]} 1 150.0 >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "   * Seeding %s with 200.00 OMNI\n" ${ADDRESS[4]}
./src/omnicore-cli --regtest omni_send $ADDR ${ADDRESS[4]} 1 200.0 >null
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "\nActivating the fee system...\n"
printf "   * Sending the activation\n"
BLOCKS=$(./src/omnicore-cli --regtest getblockcount)
TXID=$(./src/omnicore-cli --regtest omni_sendactivation $ADDR 9 $(($BLOCKS + 8)) 999)
./src/omnicore-cli --regtest setgenerate true 1 >null
printf "     # Checking the activation transaction was valid..."
RESULT=$(./src/omnicore-cli --regtest omni_gettransaction $TXID | grep valid | cut -c15-)
if [ $RESULT == "true," ]
  then
    printf "PASS\n"
    PASS=$((PASS+1))
  else
    printf "FAIL (result:%s)\n" $RESULT
    FAIL=$((FAIL+1))
fi
printf "   * Mining 10 blocks to forward past the activation block\n"
./src/omnicore-cli --regtest setgenerate true 10 >null
printf "     # Checking the activation went live as expected..."
FEATUREID=$(./src/omnicore-cli --regtest omni_getactivations | grep -A 10 completed | grep featureid | cut -c27)
if [ $FEATUREID == "9" ]
  then
    printf "PASS\n"
    PASS=$((PASS+1))
  else
    printf "FAIL (result:%s)\n" $FEATUREID
    FAIL=$((FAIL+1))
fi
printf "\nChecking share of fees for recipients...\n"
printf "   * Checking %s has a 5 percent share of fees... " ${ADDRESS[1]}
FEESHARE=$(./src/omnicore-cli --regtest omni_getfeeshare ${ADDRESS[1]} | grep feeshare | cut -d '"' -f4)
if [ $FEESHARE == "5.0000%" ]
  then
    printf "PASS\n"
    PASS=$((PASS+1))
  else
    printf "FAIL (result:%s)\n" $FEESHARE
    FAIL=$((FAIL+1))
fi
printf "   * Checking %s has a 10 percent share of fees... " ${ADDRESS[2]}
FEESHARE=$(./src/omnicore-cli --regtest omni_getfeeshare ${ADDRESS[2]} | grep feeshare | cut -d '"' -f4)
if [ $FEESHARE == "10.0000%" ]
  then
    printf "PASS\n"
    PASS=$((PASS+1))
  else
{'fraction_non_alphanumeric': 0.17269429482246895, 'fraction_numerical': 0.028800703528635813, 'mean_word_length': 3.0435555555555553, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6914380', 'n_tokens_mistral': 3151, 'n_tokens_neox': 2867, 'n_words': 919}