From 3730d46dada70b86d8c8ff7d75a4fae0b4285439 Mon Sep 17 00:00:00 2001 From: Mike Ellery Date: Tue, 27 Feb 2018 09:59:03 -0800 Subject: [PATCH] Fix intermittent failure in Subscribe_test: Fixes: RIPD-1601 Fix intermittent failure in server stream sub/unsub test. Root cause is LoadManager thread *sometimes* running and causing a fee change event which got published before our test could unsubscribe. Fixed by explicitly stopping the LoadManager for this test. --- src/test/rpc/Subscribe_test.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/test/rpc/Subscribe_test.cpp b/src/test/rpc/Subscribe_test.cpp index b3dc646e7e..f041256c53 100644 --- a/src/test/rpc/Subscribe_test.cpp +++ b/src/test/rpc/Subscribe_test.cpp @@ -16,6 +16,7 @@ //============================================================================== #include +#include #include #include #include @@ -53,6 +54,12 @@ public: BEAST_EXPECT(jv[jss::status] == "success"); } + // here we forcibly stop the load manager because it can (rarely but + // every-so-often) cause fees to raise or lower AFTER we've called the + // first findMsg but BEFORE we unsubscribe, thus causing the final + // findMsg check to fail since there is one unprocessed ws msg created + // by the loadmanager + env.app().getLoadManager().onStop(); { // Raise fee to cause an update auto& feeTrack = env.app().getFeeTrack(); @@ -88,7 +95,8 @@ public: env.app().getOPs().reportFeeChange(); // Check stream update - BEAST_EXPECT(! wsc->getMsg(10ms)); + auto jvo = wsc->getMsg(10ms); + BEAST_EXPECTS(!jvo, "getMsg: " + to_string(jvo.get()) ); } }