Skip to content

Commit

Permalink
Merge pull request #435 from HorizenOfficial/sc_creation_version
Browse files Browse the repository at this point in the history
  • Loading branch information
cronicc committed Mar 14, 2022
2 parents bb69ac6 + 3bb2c20 commit 3d540f9
Show file tree
Hide file tree
Showing 99 changed files with 3,041 additions and 743 deletions.
2 changes: 2 additions & 0 deletions qa/pull-tester/rpc-tests.sh
Expand Up @@ -99,6 +99,7 @@ testScripts=(
'sc_bwt_request.py'
'sc_cert_quality_wallet.py'
'ws_messages.py'
'ws_getsidechainversions.py'
'sc_cert_ceasing_split.py'
'sc_async_proof_verifier.py'
'sc_quality_blockchain.py'
Expand Down Expand Up @@ -131,6 +132,7 @@ testScripts=(
'txindex.py'
'getblockexpanded.py'
'sc_rpc_cmds_json_output.py'
'sc_getscgenesisinfo.py'
);
testScriptsExt=(
'getblocktemplate_longpoll.py'
Expand Down
10 changes: 8 additions & 2 deletions qa/rpc-tests/getblockexpanded.py
Expand Up @@ -56,8 +56,14 @@ def run_test(self):
vk = mcTest.generate_params("sc1")
constant = generate_random_field_element_hex()

cmdInput = {'withdrawalEpochLength': EPOCH_LENGTH, 'toaddress': "dada", 'amount': creation_amount, 'wCertVk': vk,
'constant': constant}
cmdInput = {
"version": 0,
'withdrawalEpochLength': EPOCH_LENGTH,
'toaddress': "dada",
'amount': creation_amount,
'wCertVk': vk,
'constant': constant
}

ret = self.nodes[0].sc_create(cmdInput)
creating_tx = ret['txid']
Expand Down
11 changes: 9 additions & 2 deletions qa/rpc-tests/getblockmerkleroots.py
Expand Up @@ -97,8 +97,15 @@ def run_test(self):
vk = mcTest.generate_params("sc1")
constant = generate_random_field_element_hex()

cmdInput = {'withdrawalEpochLength': 123, 'toaddress': "dada", 'amount': 3.0, 'wCertVk': vk,
'customData': "bb" * 1024, 'constant': constant}
cmdInput = {
'version': 0,
'withdrawalEpochLength': 123,
'toaddress': "dada",
'amount': 3.0,
'wCertVk': vk,
'customData': "bb" * 1024,
'constant': constant
}
ret = self.nodes[0].sc_create(cmdInput)
scid = ret['scid']
self.sync_all()
Expand Down
11 changes: 9 additions & 2 deletions qa/rpc-tests/getblocktemplate_proposals.py
Expand Up @@ -161,8 +161,15 @@ def run_test(self):
vk = mcTest.generate_params("sc1")
constant = generate_random_field_element_hex()

cmdInput = {'withdrawalEpochLength': SC_EPOCH_LENGTH, 'toaddress': "dada", 'amount': SC_CREATION_AMOUNT, 'wCertVk': vk,
'customData': "bb" * 1024, 'constant': constant}
cmdInput = {
'version': 0,
'withdrawalEpochLength': SC_EPOCH_LENGTH,
'toaddress': "dada",
'amount': SC_CREATION_AMOUNT,
'wCertVk': vk,
'customData': "bb" * 1024,
'constant': constant
}
ret = self.nodes[1].sc_create(cmdInput)
creating_tx = ret['txid']
scid = ret['scid']
Expand Down
10 changes: 9 additions & 1 deletion qa/rpc-tests/listtransactions.py
Expand Up @@ -361,7 +361,15 @@ def run_test(self):
vk = mcTest.generate_params("sc1")
constant = generate_random_field_element_hex()

cmdInput = {'fromaddress': fromaddr, 'toaddress': sidechain_address, 'amount': sc_creation_amount, 'fee': fee, 'wCertVk': vk, "constant": constant}
cmdInput = {
'version': 0,
'fromaddress': fromaddr,
'toaddress': sidechain_address,
'amount': sc_creation_amount,
'fee': fee,
'wCertVk': vk,
'constant': constant
}
try:
res = self.nodes[1].sc_create(cmdInput)
tx = res['txid']
Expand Down
1 change: 1 addition & 0 deletions qa/rpc-tests/merkle_blocks.py
Expand Up @@ -120,6 +120,7 @@ def run_test(self):

sc_cr = []
sc_cr.append({
"version": 0,
"epoch_length": sc_epoch_len,
"amount": sc_cr_amount,
"address": sc_address,
Expand Down
23 changes: 23 additions & 0 deletions qa/rpc-tests/rawtransactions.py
Expand Up @@ -221,6 +221,7 @@ def run_test(self):

sc_cr = []
sc_cr.append({
"version": 0,
"epoch_length": sc_epoch_len,
"amount": sc_cr_amount,
"address": sc_address,
Expand All @@ -230,6 +231,7 @@ def run_test(self):
})

sc_cr.append({
"version": 0,
"epoch_length": sc_epoch2_len,
"amount": sc_cr_amount2,
"address": sc_address,
Expand All @@ -238,8 +240,19 @@ def run_test(self):
"constant": constant
})

# missing sc version
sc_cr_without_version = [ {
"epoch_length": sc_epoch_len,
"amount": sc_cr_amount,
"address": sc_address,
"wCertVk": vk,
"wCeasedVk": cswVk,
"constant": constant
}]

# too big an epoch (max is 4032)
sc_cr_bad = [ {
"version": 0,
"epoch_length": 4033,
"amount": sc_cr_amount2,
"address": sc_address,
Expand All @@ -248,6 +261,15 @@ def run_test(self):
"constant": constant
} ]

#Try create a SC without providing the version
print("Try creating a SC without version")

try:
rawtx=self.nodes[0].createrawtransaction([], {}, [], sc_cr_without_version)
except JSONRPCException as e:
errorString = e.error['message']
assert_equal("version" in errorString, True)

#Try create a SC with too big an epoch len
print("Try creating a SC with an epoch too big")

Expand Down Expand Up @@ -408,6 +430,7 @@ def run_test(self):
cswVk2 = self.cswMcTest.generate_params("csw2")
constant2 = generate_random_field_element_hex()
sc_cr2 = [{
"version": 0,
"epoch_length": sc_epoch_len,
"amount": Decimal("4.0"),
"address": "ccc",
Expand Down
2 changes: 1 addition & 1 deletion qa/rpc-tests/run_sc_tests.sh
Expand Up @@ -4,7 +4,7 @@ set -o pipefail

rm /tmp/result.log

for i in sbh_rpc_cmds.py rawtransactions.py getblocktemplate_proposals.py listtransactions.py ws_messages.py sc_*py
for i in sbh_rpc_cmds.py rawtransactions.py getblocktemplate_proposals.py listtransactions.py ws_messages.py ws_getsidechainversions.py sc_*py
do
echo "$i ---------------------------" | tee -a /tmp/result.log
time stdbuf --output=L python2 ./$i 2>&1 | tee -a /tmp/result.log
Expand Down
1 change: 1 addition & 0 deletions qa/rpc-tests/sbh_rpc_cmds.py
Expand Up @@ -110,6 +110,7 @@ def run_test(self):
minconf = 1
fee = Decimal("0.000025")
cmdInput = {
"version": 0,
"withdrawalEpochLength": EPOCH_LENGTH,
"fromaddress": taddr_1,
"toaddress": sc_toaddress,
Expand Down
1 change: 1 addition & 0 deletions qa/rpc-tests/sc_async_proof_verifier.py
Expand Up @@ -115,6 +115,7 @@ def run_test(self):

sc_cr = []
sc_cr.append({
"version": 0,
"epoch_length": sc_epoch_len,
"amount": sc_cr_amount,
"address": sc_address,
Expand Down
19 changes: 14 additions & 5 deletions qa/rpc-tests/sc_big_block.py
Expand Up @@ -8,7 +8,8 @@
from test_framework.test_framework import MINIMAL_SC_HEIGHT
from test_framework.util import assert_true, assert_equal, initialize_chain_clean, \
start_nodes, stop_nodes, wait_bitcoinds, sync_blocks, sync_mempools, connect_nodes_bi, mark_logs, \
dump_sc_info, dump_sc_info_record, get_epoch_data, get_spendable, swap_bytes, advance_epoch
dump_sc_info, dump_sc_info_record, get_epoch_data, get_spendable, swap_bytes, advance_epoch, \
get_field_element_with_padding
from test_framework.mc_test.mc_test import *
import os
import pprint
Expand Down Expand Up @@ -160,9 +161,17 @@ def advance_sidechains_epoch(num_of_scs):
cmtCfg.append([[254*4, 151]])

cmdInput = {
'withdrawalEpochLength': EPOCH_LENGTH, 'amount': amount, 'fee': fee,
'constant':constant , 'wCertVk': certVk, 'wCeasedVk': cswVk, 'toaddress':"cdcd",
'vFieldElementCertificateFieldConfig':feCfg[0], 'vBitVectorCertificateFieldConfig':cmtCfg[0] }
'version': 0,
'withdrawalEpochLength': EPOCH_LENGTH,
'amount': amount,
'fee': fee,
'constant':constant ,
'wCertVk': certVk,
'wCeasedVk': cswVk,
'toaddress':"cdcd",
'vFieldElementCertificateFieldConfig':feCfg[0],
'vBitVectorCertificateFieldConfig':cmtCfg[0]
}

scids = []
scc_txs = []
Expand All @@ -177,7 +186,7 @@ def advance_sidechains_epoch(num_of_scs):
vCfe = ["ab000100"]
vCmt = [BIT_VECTOR_BUF]

fe1 = "ab000100" + "00000000000000000000000000000000000000000000000000000000"
fe1 = get_field_element_with_padding("ab000100", 0)
fe2 = BIT_VECTOR_FE

proofCfeArray = [fe1, fe2]
Expand Down
9 changes: 7 additions & 2 deletions qa/rpc-tests/sc_block_partitions.py
Expand Up @@ -98,8 +98,13 @@ def create_sc(cmdInput, node):

#-------------------------------------------------------
cmdInput = {
'withdrawalEpochLength': EPOCH_LENGTH, 'amount': amount, 'fee': 0.0001,
'constant':constant , 'wCertVk': certVk, 'toaddress':"cdcd",
'version': 0,
'withdrawalEpochLength': EPOCH_LENGTH,
'amount': amount,
'fee': 0.0001,
'constant':constant ,
'wCertVk': certVk,
'toaddress':"cdcd",
}

tx, scid = create_sc(cmdInput, self.nodes[0])
Expand Down
4 changes: 3 additions & 1 deletion qa/rpc-tests/sc_bwt_request.py
Expand Up @@ -99,6 +99,7 @@ def run_test(self):

fee_cr1 = Decimal("0.0002")
cmdInput = {
"version": 0,
"withdrawalEpochLength":EPOCH_LENGTH,
"toaddress":"dada",
"amount":creation_amount1,
Expand Down Expand Up @@ -306,6 +307,7 @@ def run_test(self):
prev_epoch_hash_2 = self.nodes[0].getbestblockhash()
epoch_len_2 = 10
cmdInput = {
"version": 0,
"withdrawalEpochLength":epoch_len_2,
"toaddress":"dada",
"amount":creation_amount2,
Expand Down Expand Up @@ -350,7 +352,7 @@ def run_test(self):
mark_logs("Node0 creates a tx with a few bwt request and mixed outputs using raw version of cmd", self.nodes, DEBUG_MODE)
outputs = { self.nodes[0].getnewaddress() :4.998 }
sc_cr_amount = 1.0
sc_cr = [ {"epoch_length":10, "amount":sc_cr_amount, "address":"effe", "wCertVk":vk3, "constant":c3} ]
sc_cr = [ {"version": 0, "epoch_length":10, "amount":sc_cr_amount, "address":"effe", "wCertVk":vk3, "constant":c3} ]
ft_amount_1 = 1.0
ft_amount_2 = 2.0
mc_return_address = self.nodes[0].getnewaddress()
Expand Down
13 changes: 8 additions & 5 deletions qa/rpc-tests/sc_cert_addressindex.py
Expand Up @@ -89,11 +89,14 @@ def run_test(self):
vk = mcTest.generate_params("sc1")
constant = generate_random_field_element_hex()

cmdInput = {'withdrawalEpochLength': EPOCH_LENGTH,
'toaddress': "dada",
'amount': creation_amount,
'wCertVk': vk,
'constant': constant}
cmdInput = {
'version': 0,
'withdrawalEpochLength': EPOCH_LENGTH,
'toaddress': "dada",
'amount': creation_amount,
'wCertVk': vk,
'constant': constant
}

ret = self.nodes[0].sc_create(cmdInput)
creating_tx = ret['txid']
Expand Down
13 changes: 8 additions & 5 deletions qa/rpc-tests/sc_cert_addrmempool.py
Expand Up @@ -112,11 +112,14 @@ def run_test(self):
constant = generate_random_field_element_hex()

# Create a SC
cmdInput = {'withdrawalEpochLength': EPOCH_LENGTH,
'toaddress': "dada",
'amount': creation_amount,
'wCertVk': vk,
'constant': constant}
cmdInput = {
'version': 0,
'withdrawalEpochLength': EPOCH_LENGTH,
'toaddress': "dada",
'amount': creation_amount,
'wCertVk': vk,
'constant': constant
}

ret = self.nodes[0].sc_create(cmdInput)
scid = ret['scid']
Expand Down
2 changes: 2 additions & 0 deletions qa/rpc-tests/sc_cert_base.py
Expand Up @@ -83,6 +83,7 @@ def run_test(self):
vk = mcTest.generate_params("sc1")
constant = generate_random_field_element_hex()
cmdInput = {
"version": 0,
"withdrawalEpochLength":EPOCH_LENGTH,
"toaddress":"dada",
"amount":creation_amount,
Expand Down Expand Up @@ -693,6 +694,7 @@ def run_test(self):
mark_logs("Node0 creates new sidechain", self.nodes, DEBUG_MODE)
vk2 = mcTest.generate_params("sc2", "cert_no_const")
cmdInput = {
"version": 0,
"withdrawalEpochLength":EPOCH_LENGTH,
"toaddress":"dada",
"amount":creation_amount,
Expand Down
13 changes: 8 additions & 5 deletions qa/rpc-tests/sc_cert_bt_immature_balances.py
Expand Up @@ -113,11 +113,14 @@ def run_test(self):
mcTest = CertTestUtils(self.options.tmpdir, self.options.srcdir)
vk = mcTest.generate_params("sc1")
constant = generate_random_field_element_hex()
cmdInput = {'withdrawalEpochLength': EPOCH_LENGTH,
'toaddress': "dada",
'amount': creation_amount,
'wCertVk': vk,
'constant': constant}
cmdInput = {
'version': 0,
'withdrawalEpochLength': EPOCH_LENGTH,
'toaddress': "dada",
'amount': creation_amount,
'wCertVk': vk,
'constant': constant
}

# Create a SC with a budget of 10 coins
ret = self.nodes[0].sc_create(cmdInput)
Expand Down
9 changes: 7 additions & 2 deletions qa/rpc-tests/sc_cert_bwt_amount_rounding.py
Expand Up @@ -84,8 +84,13 @@ def create_sc(cmdInput, node):
fee = 0.000025

cmdInput = {
'withdrawalEpochLength': EPOCH_LENGTH, 'amount': cr_amount, 'fee': fee,
'constant':constant , 'wCertVk': certVk, 'toaddress':"cdcd"
'version': 0,
'withdrawalEpochLength': EPOCH_LENGTH,
'amount': cr_amount,
'fee': fee,
'constant':constant,
'wCertVk': certVk,
'toaddress':"cdcd"
}

tx, scid = create_sc(cmdInput, self.nodes[0])
Expand Down
3 changes: 2 additions & 1 deletion qa/rpc-tests/sc_cert_ceasing.py
Expand Up @@ -93,12 +93,13 @@ def run_test(self):
tag = "sc"+str(i+1)
vk = mcTest.generate_params(tag)
cmdInput = {
"version": 0,
"withdrawalEpochLength": EPOCH_LENGTH,
"toaddress": "dada",
"amount": creation_amount[i],
"wCertVk": vk,
"constant": constant,
'customData': "abcdef"
"customData": "abcdef"
}

ret = self.nodes[0].sc_create(cmdInput)
Expand Down
1 change: 1 addition & 0 deletions qa/rpc-tests/sc_cert_ceasing_sg.py
Expand Up @@ -89,6 +89,7 @@ def run_test(self):
#----------------------------------------------------------------------
vk = mcTest.generate_params("sc1")
cmdInput = {
"version": 0,
"withdrawalEpochLength": EPOCH_LENGTH,
"toaddress": "dada",
"amount": creation_amount,
Expand Down
1 change: 1 addition & 0 deletions qa/rpc-tests/sc_cert_ceasing_split.py
Expand Up @@ -101,6 +101,7 @@ def run_test(self):
constant = generate_random_field_element_hex()

cmdInput = {
'version': 0,
'withdrawalEpochLength': sc_epoch_len,
'amount': sc_cr_amount,
'toaddress': sc_address,
Expand Down
1 change: 1 addition & 0 deletions qa/rpc-tests/sc_cert_change.py
Expand Up @@ -75,6 +75,7 @@ def run_test(self):
vk = mcTest.generate_params("sc1")
constant = generate_random_field_element_hex()
cmdInput = {
"version": 0,
"withdrawalEpochLength": EPOCH_LENGTH,
"toaddress": "dada",
"amount": creation_amount,
Expand Down

0 comments on commit 3d540f9

Please sign in to comment.