diff --git a/emily_sidecar/app.py b/emily_sidecar/app.py index 9f430b9a2..c82aaf76d 100644 --- a/emily_sidecar/app.py +++ b/emily_sidecar/app.py @@ -72,5 +72,13 @@ def handle_new_block(): return jsonify({}), 200 +# stacks-node will seldomly send a POST request to /attachments/new +# if the request is not handled, the node will loop and keep retrying +# https://github.com/stacks-network/stacks-core/issues/5558 +@app.route("/attachments/new", methods=["POST"]) +def handle_attachments(): + return jsonify({}), 200 + + if __name__ == "__main__": app.run(host="127.0.0.1", port=5000) diff --git a/emily_sidecar/test.py b/emily_sidecar/test.py index b1062da52..3ac2741a9 100644 --- a/emily_sidecar/test.py +++ b/emily_sidecar/test.py @@ -66,5 +66,26 @@ def test_new_block_post_request_failure(self, mock_post): self.assertIn("Failed to send chainstate", response.get_json()["error"]) +class AttachmentsTestCase(unittest.TestCase): + def setUp(self): + self.app = app.test_client() + self.app.testing = True + + def test_handle_attachments_with_any_json(self): + test_json = {"key": "value"} + response = self.app.post('/attachments/new', json=test_json) + self.assertEqual(response.status_code, 200) + self.assertEqual({}, response.get_json()) + + def test_handle_attachments_with_empty_json(self): + response = self.app.post('/attachments/new', json={}) + self.assertEqual(response.status_code, 200) + self.assertEqual({}, response.get_json()) + + def test_handle_attachments_with_no_json(self): + response = self.app.post('/attachments/new') + self.assertEqual(response.status_code, 200) + self.assertEqual({}, response.get_json()) + if __name__ == '__main__': unittest.main()