@@ -80,7 +80,7 @@ func (store *mockTransientStore) Persist(txid string, blockHeight uint64, res *r
80
80
store .t .Fatal ("Shouldn't have persisted" , res )
81
81
}
82
82
delete (store .persists , key )
83
- store .Called (txid , res )
83
+ store .Called (txid , blockHeight , res )
84
84
return nil
85
85
}
86
86
@@ -163,6 +163,9 @@ func (mock *committerMock) Commit(block *common.Block) error {
163
163
164
164
func (mock * committerMock ) LedgerHeight () (uint64 , error ) {
165
165
args := mock .Called ()
166
+ if args .Get (0 ) == nil {
167
+ return uint64 (0 ), args .Error (1 )
168
+ }
166
169
return args .Get (0 ).(uint64 ), args .Error (1 )
167
170
}
168
171
@@ -787,7 +790,7 @@ func TestCoordinatorStoreBlock(t *testing.T) {
787
790
Payload : [][]byte {[]byte ("rws-pre-image" )},
788
791
},
789
792
}, nil )
790
- store .On ("Persist" , mock .Anything , mock .Anything ).
793
+ store .On ("Persist" , mock .Anything , uint64 ( 1 ), mock .Anything ).
791
794
expectRWSet ("ns1" , "c2" , []byte ("rws-pre-image" )).
792
795
expectRWSet ("ns2" , "c1" , []byte ("rws-pre-image" )).Return (nil )
793
796
pvtData = pdFactory .addRWSet ().addNSRWSet ("ns1" , "c1" ).create ()
@@ -831,7 +834,7 @@ func TestCoordinatorStoreBlock(t *testing.T) {
831
834
}
832
835
}).Return (nil )
833
836
store .On ("GetTxPvtRWSetByTxid" , "tx3" , mock .Anything ).Return (& mockRWSetScanner {err : errors .New ("uh oh" )}, nil )
834
- store .On ("Persist" , mock .Anything , mock .Anything ).expectRWSet ("ns3" , "c3" , []byte ("rws-pre-image" ))
837
+ store .On ("Persist" , mock .Anything , uint64 ( 1 ), mock .Anything ).expectRWSet ("ns3" , "c3" , []byte ("rws-pre-image" ))
835
838
committer = & committerMock {}
836
839
committer .On ("CommitWithPvtData" , mock .Anything ).Run (func (args mock.Arguments ) {
837
840
var privateDataPassed2Ledger privateData = args .Get (0 ).(* ledger.BlockAndPvtData ).BlockPvtData
@@ -1032,3 +1035,30 @@ func TestCoordinatorGetBlocks(t *testing.T) {
1032
1035
assert .Empty (t , returnedPrivateData )
1033
1036
assert .Error (t , err )
1034
1037
}
1038
+
1039
+ func TestCoordinatorStorePvtData (t * testing.T ) {
1040
+ cs := createcollectionStore (common.SignedData {}).thatAcceptsAll ()
1041
+ committer := & committerMock {}
1042
+ committer .On ("LedgerHeight" ).Return (uint64 (5 ), nil ).Once ()
1043
+ store := & mockTransientStore {t : t }
1044
+ store .On ("Persist" , mock .Anything , uint64 (5 ), mock .Anything ).
1045
+ expectRWSet ("ns1" , "c1" , []byte ("rws-pre-image" )).Return (nil )
1046
+ fetcher := & fetcherMock {t : t }
1047
+ coordinator := NewCoordinator (Support {
1048
+ CollectionStore : cs ,
1049
+ Committer : committer ,
1050
+ Fetcher : fetcher ,
1051
+ TransientStore : store ,
1052
+ Validator : & validatorMock {},
1053
+ }, common.SignedData {})
1054
+ pvtData := (& pvtDataFactory {}).addRWSet ().addNSRWSet ("ns1" , "c1" ).create ()
1055
+ // Green path: ledger height can be retrieved from ledger/committer
1056
+ err := coordinator .StorePvtData ("tx1" , pvtData [0 ].WriteSet )
1057
+ assert .NoError (t , err )
1058
+
1059
+ // Bad path: ledger height cannot be retrieved from ledger/committer
1060
+ committer .On ("LedgerHeight" ).Return (uint64 (0 ), errors .New ("I/O error: file system full" ))
1061
+ err = coordinator .StorePvtData ("tx1" , pvtData [0 ].WriteSet )
1062
+ assert .Error (t , err )
1063
+ assert .Contains (t , err .Error (), "I/O error: file system full" )
1064
+ }
0 commit comments