Skip to content

Commit 7145827

Browse files
committed
test: cover signet miner using bitcoin-util grinder
1 parent d93861e commit 7145827

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python3
2+
3+
from commander import Commander
4+
5+
6+
class SignetGrinder(Commander):
7+
def set_test_params(self):
8+
self.num_nodes = 0
9+
10+
def run_test(self):
11+
self.generatetoaddress(self.tanks["miner"], 1, "tb1qjfplwf7a2dpjj04cx96rysqeastvycc0j50cch")
12+
13+
14+
def main():
15+
SignetGrinder().main()
16+
17+
18+
if __name__ == "__main__":
19+
main()

test/data/signet/network.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
nodes:
22
- name: miner
3+
image:
4+
tag: "29.0-util"
35
- name: tank-1
46
image:
57
tag: "0.16.1"

test/signet_test.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def run_test(self):
2222
self.setup_network()
2323
self.check_signet_miner()
2424
self.check_signet_recon()
25+
self.check_signet_scenario_miner()
2526
finally:
2627
self.cleanup()
2728

@@ -60,6 +61,28 @@ def check_scenario_clean_exit():
6061

6162
self.wait_for_predicate(check_scenario_clean_exit)
6263

64+
def check_signet_scenario_miner(self):
65+
before_count = int(self.warnet("bitcoin rpc tank-1 getblockcount"))
66+
67+
self.log.info("Generate 1 signet block from a scenario using the bitcoin-util grinder")
68+
self.scen_dir = Path(os.path.dirname(__file__)).parent / "resources" / "scenarios"
69+
scenario_file = self.scen_dir / "test_scenarios" / "signet_grinder.py"
70+
self.log.info(f"Running scenario from: {scenario_file}")
71+
self.warnet(f"run {scenario_file} --source_dir={self.scen_dir} --admin")
72+
self.wait_for_all_scenarios()
73+
74+
after_count = int(self.warnet("bitcoin rpc tank-1 getblockcount"))
75+
assert after_count - before_count == 1
76+
77+
deployed = scenarios_deployed()
78+
found = False
79+
for sc in deployed:
80+
if "grinder" in sc["name"]:
81+
found = True
82+
log = self.warnet(f"logs {sc['name']}")
83+
assert "Error grinding" not in log
84+
assert found
85+
6386

6487
if __name__ == "__main__":
6588
test = SignetTest()

0 commit comments

Comments
 (0)