@@ -3804,30 +3804,53 @@ TEST(Sync_MultipleSyncAgentsNotAllowed)
38043804 // particular session participant over the "temporally overlapping access"
38053805 // relation.
38063806
3807+ TEST_DIR (server_dir);
38073808 TEST_CLIENT_DB (db);
3808- Client::Config config;
3809- config.logger = test_context.logger ;
3810- auto socket_provider = std::make_shared<websocket::DefaultSocketProvider>(
3811- config.logger , " " , nullptr , websocket::DefaultSocketProvider::AutoStart{false });
3812- config.socket_provider = socket_provider;
3813- config.reconnect_mode = ReconnectMode::testing;
3814- Client client{config};
3815- {
3816- Session::Config config_1;
3817- config_1.realm_identifier = " blablabla" ;
3818- Session::Config config_2;
3819- config_2.realm_identifier = config_1.realm_identifier ;
3820- Session session_1{client, db, nullptr , nullptr , std::move (config_1)};
3821- Session session_2{client, db, nullptr , nullptr , std::move (config_2)};
3822- session_1.bind ();
3823- session_2.bind ();
3824- CHECK_THROW (
3825- websocket::DefaultSocketProvider::OnlyForTesting::run_event_loop_on_current_thread (socket_provider.get ()),
3826- MultipleSyncAgents);
3827- websocket::DefaultSocketProvider::OnlyForTesting::prep_event_loop_for_restart (socket_provider.get ());
3809+
3810+ auto pf = util::make_promise_future<void >();
3811+ struct Observer : BindingCallbackThreadObserver {
3812+ unit_test::TestContext& test_context;
3813+ util::Promise<void >& got_error;
3814+ Observer (unit_test::TestContext& test_context, util::Promise<void >& got_error)
3815+ : test_context(test_context)
3816+ , got_error(got_error)
3817+ {
3818+ }
3819+
3820+ bool has_handle_error () override
3821+ {
3822+ return true ;
3823+ }
3824+ bool handle_error (const std::exception& e) override
3825+ {
3826+ CHECK (dynamic_cast <const MultipleSyncAgents*>(&e));
3827+ got_error.emplace_value ();
3828+ return true ;
3829+ }
3830+ };
3831+
3832+ auto observer = std::make_shared<Observer>(test_context, pf.promise );
3833+ ClientServerFixture::Config config;
3834+ config.socket_provider_observer = observer;
3835+ ClientServerFixture fixture (server_dir, test_context, std::move (config));
3836+ fixture.start ();
3837+
3838+ {
3839+ Session session = fixture.make_session (db, " /test" );
3840+ session.bind ();
3841+ Session session2 = fixture.make_session (db, " /test" );
3842+ session2.bind ();
3843+ pf.future .get ();
3844+
3845+ // The exception caused the event loop to stop so we need to restart it
3846+ fixture.start_client (0 );
38283847 }
38293848
3830- socket_provider->start ();
3849+ // Verify that after the error occurs (and is ignored) things are still
3850+ // in a functional state
3851+ Session session = fixture.make_session (db, " /test" );
3852+ session.bind ();
3853+ session.wait_for_upload_complete_or_client_stopped ();
38313854}
38323855
38333856TEST (Sync_CancelReconnectDelay)
0 commit comments