@@ -90,10 +90,6 @@ func TestStoreBasicCommitAndRetrieval(t *testing.T) {
9090 assert .NoError (store .Prepare (1 , testData , blk1MissingData ))
9191 assert .NoError (store .Commit ())
9292
93- // pvt data with block 2 - rollback
94- assert .NoError (store .Prepare (2 , testData , nil ))
95- assert .NoError (store .Rollback ())
96-
9793 // pvt data retrieval for block 0 should return nil
9894 var nilFilter ledger.PvtNsCollFilter
9995 retrievedData , err := store .GetPvtDataByBlockNum (0 , nilFilter )
@@ -773,83 +769,7 @@ func testCollElgEnabled(t *testing.T) {
773769 assert .Equal (expectedMissingPvtDataInfo , missingPvtDataInfo )
774770}
775771
776- func TestRollBack (t * testing.T ) {
777- btlPolicy := btltestutil .SampleBTLPolicy (
778- map [[2 ]string ]uint64 {
779- {"ns-1" , "coll-1" }: 0 ,
780- {"ns-1" , "coll-2" }: 0 ,
781- },
782- )
783- env := NewTestStoreEnv (t , "TestRollBack" , btlPolicy )
784- defer env .Cleanup ()
785- assert := assert .New (t )
786- store := env .TestStore
787- assert .NoError (store .Prepare (0 , nil , nil ))
788- assert .NoError (store .Commit ())
789-
790- pvtdata := []* ledger.TxPvtData {
791- produceSamplePvtdata (t , 0 , []string {"ns-1:coll-1" , "ns-1:coll-2" }),
792- produceSamplePvtdata (t , 5 , []string {"ns-1:coll-1" , "ns-1:coll-2" }),
793- }
794- missingData := make (ledger.TxMissingPvtDataMap )
795- missingData .Add (1 , "ns-1" , "coll-1" , true )
796- missingData .Add (5 , "ns-1" , "coll-1" , true )
797- missingData .Add (5 , "ns-2" , "coll-2" , false )
798-
799- for i := 1 ; i <= 9 ; i ++ {
800- assert .NoError (store .Prepare (uint64 (i ), pvtdata , missingData ))
801- assert .NoError (store .Commit ())
802- }
803-
804- datakeyTx0 := & dataKey {
805- nsCollBlk : nsCollBlk {ns : "ns-1" , coll : "coll-1" },
806- txNum : 0 ,
807- }
808- datakeyTx5 := & dataKey {
809- nsCollBlk : nsCollBlk {ns : "ns-1" , coll : "coll-1" },
810- txNum : 5 ,
811- }
812- eligibleMissingdatakey := & missingDataKey {
813- nsCollBlk : nsCollBlk {ns : "ns-1" , coll : "coll-1" },
814- isEligible : true ,
815- }
816-
817- // test store state before preparing for block 10
818- testPendingBatch (false , assert , store )
819- testLastCommittedBlockHeight (10 , assert , store )
820-
821- // prepare for block 10 and test store for presence of datakeys and eligibile missingdatakeys
822- assert .NoError (store .Prepare (10 , pvtdata , missingData ))
823- testPendingBatch (true , assert , store )
824- testLastCommittedBlockHeight (10 , assert , store )
825-
826- datakeyTx0 .blkNum = 10
827- datakeyTx5 .blkNum = 10
828- eligibleMissingdatakey .blkNum = 10
829- assert .True (testDataKeyExists (t , store , datakeyTx0 ))
830- assert .True (testDataKeyExists (t , store , datakeyTx5 ))
831- assert .True (testMissingDataKeyExists (t , store , eligibleMissingdatakey ))
832-
833- // rollback last prepared block and test store for absence of datakeys and eligibile missingdatakeys
834- store .Rollback ()
835- testPendingBatch (false , assert , store )
836- testLastCommittedBlockHeight (10 , assert , store )
837- assert .False (testDataKeyExists (t , store , datakeyTx0 ))
838- assert .False (testDataKeyExists (t , store , datakeyTx5 ))
839- assert .False (testMissingDataKeyExists (t , store , eligibleMissingdatakey ))
840-
841- // For previously committed blocks the datakeys and eligibile missingdatakeys should still be present
842- for i := 1 ; i <= 9 ; i ++ {
843- datakeyTx0 .blkNum = uint64 (i )
844- datakeyTx5 .blkNum = uint64 (i )
845- eligibleMissingdatakey .blkNum = uint64 (i )
846- assert .True (testDataKeyExists (t , store , datakeyTx0 ))
847- assert .True (testDataKeyExists (t , store , datakeyTx5 ))
848- assert .True (testMissingDataKeyExists (t , store , eligibleMissingdatakey ))
849- }
850- }
851-
852- // TODO Add tests for simulating a crash between calls `Prepare` and `Commit`/`Rollback` - [FAB-13099]
772+ // TODO Add tests for simulating a crash between calls `Prepare` and `Commit` - [FAB-13099]
853773
854774func testEmpty (expectedEmpty bool , assert * assert.Assertions , store Store ) {
855775 isEmpty , err := store .IsEmpty ()
0 commit comments