-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-1101 Add integration test for p2p-listen-address specification of …
…:trx
- Loading branch information
Showing
3 changed files
with
281 additions
and
0 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
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,130 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import signal | ||
import json | ||
import time | ||
|
||
from TestHarness import Account, Cluster, TestHelper, Utils, WalletMgr, CORE_SYMBOL | ||
from TestHarness.TestHelper import AppArgs | ||
|
||
############################################################### | ||
# p2p_no_blocks_test | ||
# | ||
# Test p2p-listen-address trx only option | ||
# | ||
############################################################### | ||
|
||
Print=Utils.Print | ||
errorExit=Utils.errorExit | ||
|
||
appArgs = AppArgs() | ||
appArgs.add(flag='--plugin',action='append',type=str,help='Run nodes with additional plugins') | ||
appArgs.add(flag='--connection-cleanup-period',type=int,help='Interval in whole seconds to run the connection reaper and metric collection') | ||
|
||
args=TestHelper.parse_args({"-d","--keep-logs" | ||
,"--dump-error-details","-v","--leave-running" | ||
,"--unshared"}, | ||
applicationSpecificArgs=appArgs) | ||
pnodes=1 | ||
delay=args.d | ||
debug=args.v | ||
prod_count = 2 | ||
total_nodes=4 | ||
activateIF=True | ||
dumpErrorDetails=args.dump_error_details | ||
|
||
Utils.Debug=debug | ||
testSuccessful=False | ||
|
||
cluster=Cluster(unshared=args.unshared, keepRunning=args.leave_running, keepLogs=args.keep_logs) | ||
walletMgr=WalletMgr(True) | ||
|
||
try: | ||
TestHelper.printSystemInfo("BEGIN") | ||
|
||
cluster.setWalletMgr(walletMgr) | ||
|
||
Print(f'producing nodes: {pnodes}, delay between nodes launch: {delay} second{"s" if delay != 1 else ""}') | ||
|
||
Print("Stand up cluster") | ||
# Custom topology: | ||
# prodNode00 <-> nonProdNode01 | ||
# -> noBlocks02 :9902 (p2p-listen-address with trx only) (speculative mode) | ||
# -> noBlocks03 :9903 (p2p-listen-address with trx only) | ||
# | ||
# 01-nonProdNode connects to 02 & 03, but 02 & 03 do not connect to 01 so they will not receive any blocks | ||
# 02 & 03 are connected to the bios node to get blocks until bios node is killed. | ||
# | ||
specificExtraNodeosArgs = {} | ||
# nonProdNode01 will connect normally but will not send blocks because 02 & 03 have specified :trx only | ||
specificExtraNodeosArgs[1] = f'--p2p-peer-address localhost:9902 --p2p-peer-address localhost:9903 ' | ||
# add a trx only listen endpoint to noBlocks02 & noBlocks03 | ||
specificExtraNodeosArgs[2] = f'--p2p-peer-address localhost:9776 --read-mode speculative ' # connect to bios | ||
specificExtraNodeosArgs[2] += f'--p2p-listen-endpoint localhost:9878 --p2p-server-address localhost:9878 ' | ||
specificExtraNodeosArgs[2] += f'--p2p-listen-endpoint localhost:9902:trx --p2p-server-address localhost:9902:trx ' | ||
specificExtraNodeosArgs[3] = f'--p2p-peer-address localhost:9776 ' # connect to bios | ||
specificExtraNodeosArgs[3] += f'--p2p-listen-endpoint localhost:9879 --p2p-server-address localhost:9879 ' | ||
specificExtraNodeosArgs[3] += f'--p2p-listen-endpoint localhost:9903:trx --p2p-server-address localhost:9903:trx ' | ||
if cluster.launch(pnodes=pnodes, unstartedNodes=2, totalNodes=total_nodes, prodCount=prod_count, | ||
extraNodeosArgs="--connection-cleanup-period 3", specificExtraNodeosArgs=specificExtraNodeosArgs, | ||
topo='./tests/p2p_no_blocks_test_shape.json', delay=delay, activateIF=activateIF, biosFinalizer=False) is False: | ||
errorExit("Failed to stand up eos cluster.") | ||
|
||
prodNode00 = cluster.getNode(0) | ||
nonProdNode01 = cluster.getNode(1) | ||
|
||
noBlocks02 = cluster.unstartedNodes[0] | ||
noBlocks03 = cluster.unstartedNodes[1] | ||
|
||
Print("Launch no block nodes 02 & 03") | ||
cluster.launchUnstarted(2) | ||
|
||
assert noBlocks02.verifyAlive(), "node 02 did not launch" | ||
assert noBlocks03.verifyAlive(), "node 03 did not launch" | ||
|
||
headBlockNum = nonProdNode01.getHeadBlockNum() | ||
|
||
Print("Sync from bios") | ||
assert noBlocks02.waitForBlock(headBlockNum), "node02 did not sync from bios" | ||
assert noBlocks03.waitForBlock(headBlockNum), "node03 did not sync from bios" | ||
|
||
# create transfer transaction now so it has a valid TAPOS | ||
eosioBalanceBefore = nonProdNode01.getAccountEosBalance("eosio") | ||
defprodueraBalanceBefore = nonProdNode01.getAccountEosBalance("defproducera") | ||
transferAmount="50.0000 {0}".format(CORE_SYMBOL) | ||
trx=nonProdNode01.transferFunds(cluster.eosioAccount, cluster.defproduceraAccount, transferAmount, dontSend=True) | ||
|
||
Print("Killing bios node") | ||
cluster.biosNode.kill(signal.SIGTERM) | ||
|
||
Print("Verify head no longer advancing after bios killed") | ||
assert not noBlocks02.waitForHeadToAdvance(), "head advanced on node02 unexpectedly" | ||
assert not noBlocks03.waitForHeadToAdvance(), "head advanced on node03 unexpectedly" | ||
|
||
Print("Send transfer trx") | ||
cmdDesc = "push transaction --skip-sign" | ||
cmd = "%s '%s'" % (cmdDesc, json.dumps(trx)) | ||
trans = nonProdNode01.processCleosCmd(cmd, cmdDesc, silentErrors=False, exitOnError=True) | ||
|
||
# can't wait for transaction in block, so just sleep | ||
time.sleep(0.5) | ||
|
||
eosioBalanceNode02 = noBlocks02.getAccountEosBalance("eosio") | ||
defprodueraBalanceNode02 = noBlocks02.getAccountEosBalance("defproducera") | ||
eosioBalanceNode03 = noBlocks03.getAccountEosBalance("eosio") | ||
defprodueraBalanceNode03 = noBlocks03.getAccountEosBalance("defproducera") | ||
|
||
assert eosioBalanceBefore - 500000 == eosioBalanceNode02, f"{eosioBalanceBefore - 500000} != {eosioBalanceNode02}" | ||
assert defprodueraBalanceBefore + 500000 == defprodueraBalanceNode02, f"{defprodueraBalanceBefore + 500000} != {defprodueraBalanceNode02}" | ||
|
||
assert eosioBalanceBefore == eosioBalanceNode03, f"{eosioBalanceBefore} != {eosioBalanceNode03}" | ||
assert defprodueraBalanceBefore == defprodueraBalanceNode03, f"{defprodueraBalanceBefore} != {defprodueraBalanceNode03}" | ||
|
||
cluster.biosNode.relaunch() | ||
|
||
testSuccessful=True | ||
finally: | ||
TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, dumpErrorDetails=dumpErrorDetails) | ||
|
||
exitCode = 0 if testSuccessful else 1 | ||
exit(exitCode) |
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,147 @@ | ||
{ | ||
"name": "testnet_", | ||
"nodes": { | ||
"bios": { | ||
"index": -100, | ||
"name": "bios", | ||
"keys": [ | ||
{ | ||
"pubkey": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", | ||
"privkey": "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3", | ||
"blspubkey": "PUB_BLS_sGOyYNtpmmjfsNbQaiGJrPxeSg9sdx0nRtfhI_KnWoACXLL53FIf1HjpcN8wX0cYQyOE60NLSI9iPY8mIlT4GkiFMT3ez7j2IbBBzR0D1MthC0B_fYlgYWwjcbqCOowSaH48KA", | ||
"blsprivkey": "PVT_BLS_QgHHJ5vprZcjG7P0xWoIdX4yKPQXoG4k3e28TpLIQicB7GL_", | ||
"blspop": "SIG_BLS_HDzwmlF7wSJGetlSfhIGKVtjiMTeYoM4oCbNoHi1tyh0_KnZCsdLUzplexSXD80P0NAkCjlA6YFt2M5_JsZkRTqn2faFSnH6zwKIK9yr2cV3a14W4WcIC90mTP2D-HEPOBjM2gTmWCA0gYfPdV3tB3I0matrYh5R0I1FG0V6p_RVKacXMgV_M3lNUokRI84MPZlc8OVbJ0RbjoBnYylVeYtR31vSJvvk6RvykIjTktZOA0s32-TR5EcxuaFSsVQU7nSQxA" | ||
} | ||
], | ||
"peers": [ | ||
"testnet_00" | ||
], | ||
"producers": [ | ||
"eosio" | ||
], | ||
"dont_start": false, | ||
"p2p_port": 9776, | ||
"http_port": 8788, | ||
"host_name": "localhost", | ||
"public_name": "localhost", | ||
"listen_addr": "0.0.0.0", | ||
"_dot_label": "localhost:9776\nbios\nprod=eosio" | ||
}, | ||
"testnet_00": { | ||
"index": 0, | ||
"name": "testnet_00", | ||
"keys": [ | ||
{ | ||
"pubkey": "EOS7D6jfN6bbJD9cYheyhnBT4bmUWc3Qf4Yphf5GBeAAy58okcwHU", | ||
"privkey": "5KkmnyunnpCQzgFoLMEtU3j7BRBa5aWmsBNru49ke7LdnZKFhmt", | ||
"blspubkey": "PUB_BLS_X6Wzge0CMkDLu0svywBWGBdIuMfol_hAG7zeukAddsbQsArgcuZ6tz3LLoLRurUMhz6ZpOHdYCPU0Rg8Fo8n4UDsT6pcHSmwWMKWIhyS-Ms0O_dYCRQ2Q5HLxBGMxyIWaltxlw", | ||
"blsprivkey": "PVT_BLS_TvIkGjiwy3b5k9yc6YnwHPQp1n_9x8yP4mZQl5Ke1yvp2_vv", | ||
"blspop": "SIG_BLS_Zzi_eRG51GhBgAFhnG048Pa3OjlenLwKtO03CBkZxQB4sdhyYWmqrJDdjpgPwvcPwbRK1jIlaUG9mJVPjJHrmocC-br8_t1EqLAHN3lyuyJ7UZWkzj2E339zNJ8aE28NmF4rmZ0UV3sUP54qZw9k75G7y0toL8djkMkPNzbz9OD0vZQDjQ-PVWQg11t-eP4MbFt8uONuk2NpEBEbT8JXPvnzh1e1-WBxId0Mra5-Pa1ca3zkrqgHdnpWKCUjBr0Kj8yZPg" | ||
} | ||
], | ||
"peers": [ | ||
"bios" | ||
], | ||
"producers": [ | ||
"defproducera", | ||
"defproducerb", | ||
"defproducerc", | ||
"defproducerd", | ||
"defproducere", | ||
"defproducerf", | ||
"defproducerg", | ||
"defproducerh", | ||
"defproduceri", | ||
"defproducerj", | ||
"defproducerk", | ||
"defproducerl", | ||
"defproducerm", | ||
"defproducern", | ||
"defproducero", | ||
"defproducerp", | ||
"defproducerq", | ||
"defproducerr", | ||
"defproducers", | ||
"defproducert", | ||
"defproduceru" | ||
], | ||
"dont_start": false, | ||
"p2p_port": 9876, | ||
"http_port": 8888, | ||
"host_name": "localhost", | ||
"public_name": "localhost", | ||
"listen_addr": "0.0.0.0", | ||
"_dot_label": "localhost:9876\ntestnet_00\nprod=defproducera\ndefproducerb\ndefproducerc\ndefproducerd\ndefproducere\ndefproducerf\ndefproducerg\ndefproducerh\ndefproduceri\ndefproducerj\ndefproducerk\ndefproducerl\ndefproducerm\ndefproducern\ndefproducero\ndefproducerp\ndefproducerq\ndefproducerr\ndefproducers\ndefproducert\ndefproduceru" | ||
}, | ||
"testnet_01": { | ||
"index": 1, | ||
"name": "testnet_01", | ||
"keys": [ | ||
{ | ||
"pubkey": "EOS5tZqxLB8y9q2yHkgcXU4QFBEV6QKN3NQ54ygaFLWHJbjqYzFhw", | ||
"privkey": "5KBs4qR7T8shJjCJUeFQXd77iKrok5TCtZiQhWJpCpc1VRxpNAs", | ||
"blspubkey": "PUB_BLS_UmHR2Ez-gUJVkptOXXlWBCSu2aPQ3EBk69L7IzXn-pAXiWv5gP6fgQv5Js4n3VcJL6TK1M9rB9wAPhnr7b6xdKg2_zWD62qUoal9GYmBS5doxlCdKDY8ZFj6fbGS02oY_-ItrQ", | ||
"blsprivkey": "PVT_BLS_IRjJHkfSSII-mDq7iVOsznvka_sRMsmxJSJwXQyr5mqmERAV", | ||
"blspop": "SIG_BLS_wzTA_EfQTVoWRO4HZqoyDcQGCnlvHCkqoZXVSRbwSf7az4U4nbveWgCMRCgQZsgEJbPt6-NslwwRXJDLnFN0Hnm8F5qhmsGlWMP9tH7syPibNvldJ0RUFDH7azSZulcJ2uMxQAobCB-21c3PiUQc8JbuJFbUp9klAnXIJP60P-PT6ZUNmhNjLqHl2IlMsq8ZdFPvHVF3Z8HpfhJVKedI4yTvzWAIIOW2uSHkOmKbLP_QYc2YLRHUWV56mM-hsRwP4-hWVA" | ||
} | ||
], | ||
"peers": [ | ||
"testnet_00" | ||
], | ||
"producers": [], | ||
"dont_start": false, | ||
"p2p_port": 9877, | ||
"http_port": 8889, | ||
"host_name": "localhost", | ||
"public_name": "localhost", | ||
"listen_addr": "0.0.0.0", | ||
"_dot_label": "localhost:9877\ntestnet_01\nprod=<none>" | ||
}, | ||
"testnet_02": { | ||
"index": 2, | ||
"name": "testnet_02", | ||
"keys": [ | ||
{ | ||
"pubkey": "EOS5FBPf5EN9bYEqmsKfPx9bxyUZ9grDiE24zqLFXtPa6UpVzMjE7", | ||
"privkey": "5HtVDiAsD24seDm5sdswTcdZpx672XbBW9gBkyrzbsj2j9Y9JeC", | ||
"blspubkey": "PUB_BLS_JzblSr2sf_UhxQjGxOtHbRCBkHgSB1RG4xUbKKl-fKtUjx6hyOHajnVQT4IvBF4PutlX7JTC14IqIjADlP-3_G2MXRhBlkB57r2u59OCwRQQEDqmVSADf6CoT8zFUXcSgHFw7w", | ||
"blsprivkey": "PVT_BLS_QRxLAVbe2n7RaPWx2wHbur8erqUlAs-V_wXasGhjEA78KlBq", | ||
"blspop": "SIG_BLS_Z5fJqFv6DIsHFhBFpkHmL_R48h80zVKQHtB5lrKGOVZTaSQNuVaXD_eHg7HBvKwY6zqgA_vryCLQo5W0Inu6HtLkGL2gYX2UHJjrZJZpfJSKG0ynqAZmyrCglxRLNm8KkFdGGR8oJXf5Yzyu7oautqTPniuKLBvNeQxGJGDOQtHSQ0uP3mD41pWzPFRoi10BUor9MbwUTQ7fO7Of4ZjhVM3IK4JrqX1RBXkDX83Wi9xFzs_fdPIyMqmgEzFgolgUa8XN4Q" | ||
} | ||
], | ||
"peers": [ | ||
], | ||
"producers": [], | ||
"dont_start": true, | ||
"p2p_port": 9878, | ||
"http_port": 8890, | ||
"host_name": "localhost", | ||
"public_name": "localhost", | ||
"listen_addr": "0.0.0.0", | ||
"_dot_label": "localhost:9878\ntestnet_02\nprod=<none>" | ||
}, | ||
"testnet_03": { | ||
"index": 3, | ||
"name": "testnet_03", | ||
"keys": [ | ||
{ | ||
"pubkey": "EOS8XH2gKxsef9zxmMHm4vaSvxQUhg7W4GC3nK2KSRxyYrNG5gZFS", | ||
"privkey": "5JcoRRhDcgm51dkBrRTmErceTqrYhrq22UnmUjTZToMpH91B9N1", | ||
"blspubkey": "PUB_BLS_rYRa_-bT7uLOSAfPIBy6NlXFB0YxwROeSuqHzw6s-1cuK_-GJUKqp20ktyAnsO4ZuHdx3BEPDaLronpnL22MXKWM7bvZnkCfbGCD6OzizQqxXkM9N5z5R-OUA4Ime6cF5YTSFg", | ||
"blsprivkey": "PVT_BLS_GQjR0E8Hu8KrsTCvLKnlOCIwQijAj2-5KDizQwF-bAY6pise", | ||
"blspop": "SIG_BLS_syFMuifUnX2zQQKr0cuHYzQQjsuPrNG75_z6y8fOyYg_twqMICZ0kT7ObbwIOUsLfXx9PVb4-QLEgUYGSRg1NSfeHGjIGkhea82wa3ayfI8elUEU1MStKbeKpys7xUAQz1PEgwcz5dClq3HyLQmMAjpoL74N_Znf0KiNEVZMte-DLF7x_6sAfp_834LthyYHjZYTmdG7belyzlYHKJb6upnZy9nR_zoKpx9jeTd3tzVhoTCuAN6aFw68D_ItY5cWiY2dhA" | ||
} | ||
], | ||
"peers": [ | ||
], | ||
"producers": [], | ||
"dont_start": true, | ||
"p2p_port": 9879, | ||
"http_port": 8891, | ||
"host_name": "localhost", | ||
"public_name": "localhost", | ||
"listen_addr": "0.0.0.0", | ||
"_dot_label": "localhost:9879\ntestnet_03\nprod=<none>" | ||
} | ||
} | ||
} |