forked from EOSIO/taurus-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodeos_protocol_feature_test.py
More file actions
executable file
·74 lines (61 loc) · 2.65 KB
/
nodeos_protocol_feature_test.py
File metadata and controls
executable file
·74 lines (61 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
from testUtils import Utils
from Cluster import Cluster, PFSetupPolicy
from TestHelper import TestHelper
from WalletMgr import WalletMgr
from Node import Node
import signal
import json
from os.path import join
from datetime import datetime
###############################################################
# nodeos_protocol_feature_test
#
# Many smaller tests centered around irreversible mode
#
###############################################################
# Parse command line arguments
args = TestHelper.parse_args({"-v","--clean-run","--dump-error-details","--leave-running","--keep-logs"})
Utils.Debug = args.v
killAll=args.clean_run
dumpErrorDetails=args.dump_error_details
dontKill=args.leave_running
killEosInstances=not dontKill
killWallet=not dontKill
keepLogs=args.keep_logs
# The following test case will test the Protocol Feature JSON reader of the blockchain
def restartNode(node: Node, chainArg=None, addSwapFlags=None):
if not node.killed:
node.kill(signal.SIGTERM)
isRelaunchSuccess = node.relaunch(chainArg, addSwapFlags=addSwapFlags, timeout=10, cachePopen=True)
assert isRelaunchSuccess, "Fail to relaunch"
walletMgr=WalletMgr(True)
cluster=Cluster(walletd=True)
cluster.setWalletMgr(walletMgr)
testSuccessful = False
try:
TestHelper.printSystemInfo("BEGIN")
cluster.killall(allInstances=killAll)
cluster.cleanup()
cluster.launch(extraNodeosArgs=" --plugin eosio::producer_api_plugin --http-max-response-time-ms 990000 ",
dontBootstrap=True,
pfSetupPolicy=PFSetupPolicy.NONE)
biosNode = cluster.biosNode
# Modify the JSON file and then restart the node so it updates the internal state
newSubjectiveRestrictions = {
"earliest_allowed_activation_time": "2030-01-01T00:00:00.000",
"preactivation_required": True,
"enabled": False
}
biosNode.modifyBuiltinPFSubjRestrictions("PREACTIVATE_FEATURE", newSubjectiveRestrictions)
restartNode(biosNode)
supportedProtocolFeatureDict = biosNode.getSupportedProtocolFeatureDict()
preactivateFeatureSubjectiveRestrictions = supportedProtocolFeatureDict["PREACTIVATE_FEATURE"]["subjective_restrictions"]
# Ensure that the PREACTIVATE_FEATURE subjective restrictions match the value written in the JSON
assert preactivateFeatureSubjectiveRestrictions == newSubjectiveRestrictions,\
"PREACTIVATE_FEATURE subjective restrictions are not updated according to the JSON"
testSuccessful = True
finally:
TestHelper.shutdown(cluster, walletMgr, testSuccessful, killEosInstances, killWallet, keepLogs, killAll, dumpErrorDetails)
exitCode = 0 if testSuccessful else 1
exit(exitCode)