Skip to content

Commit 6299243

Browse files
authored
Merge pull request #627 from pinheadmz/miner-std-single
scenarios: miner_std should accept single --tank option
2 parents 6b3ed49 + ff4b8d7 commit 6299243

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

resources/scenarios/miner_std.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,21 @@ def add_options(self, parser):
4141
action="store_true",
4242
help="When true, generate 101 blocks ONCE per miner",
4343
)
44+
parser.add_argument(
45+
"--tank",
46+
dest="tank",
47+
type=str,
48+
help="Select one tank by name as the only miner",
49+
)
4450

4551
def run_test(self):
4652
self.log.info("Starting miners.")
47-
48-
max_miners = 1
49-
if self.options.allnodes:
50-
max_miners = len(self.nodes)
51-
for index in range(max_miners):
52-
self.miners.append(Miner(self.nodes[index], self.options.mature))
53+
if self.options.tank:
54+
self.miners = [Miner(self.tanks[self.options.tank], self.options.mature)]
55+
else:
56+
max_miners = len(self.nodes) if self.options.allnodes else 1
57+
for index in range(max_miners):
58+
self.miners.append(Miner(self.nodes[index], self.options.mature))
5359

5460
while True:
5561
for miner in self.miners:

test/conf_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@
77

88
from test_base import TestBase
99

10+
from warnet.control import stop_scenario
1011
from warnet.k8s import get_mission
12+
from warnet.status import _get_deployed_scenarios as scenarios_deployed
1113

1214

1315
class ConfTest(TestBase):
1416
def __init__(self):
1517
super().__init__()
1618
self.network_dir = Path(os.path.dirname(__file__)) / "data" / "bitcoin_conf"
19+
self.scen_dir = Path(os.path.dirname(__file__)).parent / "resources" / "scenarios"
1720

1821
def run_test(self):
1922
try:
2023
self.setup_network()
2124
self.check_uacomment()
25+
self.check_single_miner()
2226
finally:
2327
self.cleanup()
2428

@@ -52,6 +56,22 @@ def get_uacomment():
5256

5357
self.wait_for_predicate(get_uacomment)
5458

59+
def check_single_miner(self):
60+
scenario_file = self.scen_dir / "miner_std.py"
61+
self.log.info(f"Running scenario from: {scenario_file}")
62+
# Mine from a tank that is not first or last and
63+
# is one of the only few in the network that even
64+
# has rpc reatewallet method!
65+
self.warnet(f"run {scenario_file} --tank=tank-0026 --interval=1")
66+
self.wait_for_predicate(
67+
lambda: int(self.warnet("bitcoin rpc tank-0026 getblockcount")) >= 10
68+
)
69+
running = scenarios_deployed()
70+
assert len(running) == 1, f"Expected one running scenario, got {len(running)}"
71+
assert running[0]["status"] == "running", "Scenario should be running"
72+
stop_scenario(running[0]["name"])
73+
self.wait_for_all_scenarios()
74+
5575

5676
if __name__ == "__main__":
5777
test = ConfTest()

0 commit comments

Comments
 (0)