Skip to content

Commit

Permalink
api-listen: Fix gossip snapshot assertions
Browse files Browse the repository at this point in the history
- Use assert_called_with instead of assert called_with to avoid the
  AttributeError thrown by Python 3.12.
- Use different names for the snapshot files tested on the test_gossip
  and test_gossip_with_dest test cases in case the two tests run
  simultaneously. In this case, the listener would save the two files
  and add a -2 suffix to the second one, which would cause the command
  assertion to fail.
  • Loading branch information
blockstreamsatellite committed Dec 15, 2023
1 parent 21cf87c commit 56211b5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions blocksatcli/api/test_listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,24 +175,24 @@ def test_exec_cmd(self):
@mock.patch('subprocess.run')
def test_gossip(self, mock_subproc_run):
"""Test Lightning gossip reception"""
filename = 'snapshot.gsp'
filename = 'snapshot1.gsp'
gossip_opts = {'cli': 'historian-cli', 'dest': None}
self.loopback_test(filename=filename, gossip_opts=gossip_opts)
expected_cmd = [
'historian-cli', 'snapshot', 'load',
os.path.join(self.download_dir, filename)
]
self.assertTrue(mock_subproc_run.called_with(expected_cmd))
mock_subproc_run.assert_called_with(expected_cmd)

@mock.patch('subprocess.run')
def test_gossip_with_dest(self, mock_subproc_run):
"""Test Lightning gossip reception with a specified destination"""
filename = 'snapshot.gsp'
filename = 'snapshot2.gsp'
dest = '127.0.0.1'
gossip_opts = {'cli': 'historian-cli', 'dest': dest}
self.loopback_test(filename=filename, gossip_opts=gossip_opts)
expected_cmd = [
'historian-cli', 'snapshot', 'load',
os.path.join(self.download_dir, filename), dest
]
self.assertTrue(mock_subproc_run.called_with(expected_cmd))
mock_subproc_run.assert_called_with(expected_cmd)

0 comments on commit 56211b5

Please sign in to comment.