@@ -321,6 +321,52 @@ func TestBolt4(ot *testing.T) {
321
321
assertBoltState (t , bolt4_ready , bolt )
322
322
})
323
323
324
+ // Verifies that current stream is discarded correctly even if it is larger
325
+ // than what is served by a single pull.
326
+ ot .Run ("Commit while streams, explicit consume" , func (t * testing.T ) {
327
+ qid := int64 (2 )
328
+ bolt , cleanup := connectToServer (t , func (srv * bolt4server ) {
329
+ srv .accept (4 )
330
+ srv .waitForTxBegin ()
331
+ srv .send (msgSuccess , map [string ]interface {}{})
332
+ // First RunTx
333
+ srv .waitForRun ()
334
+ srv .waitForPullN (1 )
335
+ // Send Pull response
336
+ srv .send (msgSuccess , map [string ]interface {}{"fields" : []interface {}{"k" }, "t_first" : int64 (1 ), "qid" : qid })
337
+ // Driver should discard this stream which is small
338
+ srv .send (msgRecord , []interface {}{"v1" })
339
+ srv .send (msgSuccess , map [string ]interface {}{"has_more" : false })
340
+ // Second RunTx
341
+ srv .waitForRun ()
342
+ srv .waitForPullN (1 )
343
+ srv .send (msgSuccess , map [string ]interface {}{"fields" : []interface {}{"k" }, "t_first" : int64 (1 ), "qid" : qid })
344
+ // Driver should discard this stream, which is small
345
+ srv .send (msgRecord , []interface {}{"v1" })
346
+ srv .send (msgSuccess , map [string ]interface {}{"has_more" : false })
347
+ // Wait for the commit
348
+ srv .waitForTxCommit ()
349
+ srv .send (msgSuccess , map [string ]interface {}{"bookmark" : "x" })
350
+ })
351
+ defer cleanup ()
352
+ defer bolt .Close ()
353
+
354
+ tx , err := bolt .TxBegin (db.TxConfig {Mode : db .ReadMode })
355
+ AssertNoError (t , err )
356
+ s , err := bolt .RunTx (tx , db.Command {Cypher : "Whatever" , FetchSize : 1 })
357
+ AssertNoError (t , err )
358
+ _ , err = bolt .Consume (s )
359
+ AssertNoError (t , err )
360
+ s , err = bolt .RunTx (tx , db.Command {Cypher : "Whatever" , FetchSize : 1 })
361
+ AssertNoError (t , err )
362
+ _ , err = bolt .Consume (s )
363
+ AssertNoError (t , err )
364
+
365
+ err = bolt .TxCommit (tx )
366
+ AssertNoError (t , err )
367
+ assertBoltState (t , bolt4_ready , bolt )
368
+ })
369
+
324
370
ot .Run ("Begin transaction with bookmark success" , func (t * testing.T ) {
325
371
committedBookmark := "cbm"
326
372
bolt , cleanup := connectToServer (t , func (srv * bolt4server ) {
@@ -655,6 +701,7 @@ func TestBolt4(ot *testing.T) {
655
701
sum , err := bolt .Consume (stream )
656
702
AssertNoError (t , err )
657
703
AssertNotNil (t , sum )
704
+ assertBoltState (t , bolt4_ready , bolt )
658
705
// The bookmark should be set
659
706
AssertStringEqual (t , bolt .Bookmark (), runBookmark )
660
707
AssertStringEqual (t , sum .Bookmark , runBookmark )
@@ -696,6 +743,7 @@ func TestBolt4(ot *testing.T) {
696
743
sum , err = bolt .Consume (stream )
697
744
AssertNoError (t , err )
698
745
AssertNotNil (t , sum )
746
+ assertBoltState (t , bolt4_ready , bolt )
699
747
700
748
// The bookmark should be set
701
749
AssertStringEqual (t , bolt .Bookmark (), bookmark )
0 commit comments