@@ -14,14 +14,12 @@ import (
1414 "time"
1515
1616 tmrand "github.com/cometbft/cometbft/libs/rand"
17- "github.com/cosmos/cosmos-sdk/types"
1817 "github.com/golang/mock/gomock"
1918 ds "github.com/ipfs/go-datastore"
2019 ds_sync "github.com/ipfs/go-datastore/sync"
2120 "github.com/stretchr/testify/assert"
2221 "github.com/stretchr/testify/require"
2322
24- appfibre "github.com/celestiaorg/celestia-app/v8/fibre"
2523 "github.com/celestiaorg/celestia-app/v8/pkg/wrapper"
2624 "github.com/celestiaorg/go-header/store"
2725 libshare "github.com/celestiaorg/go-square/v4/share"
@@ -36,8 +34,6 @@ import (
3634 "github.com/celestiaorg/celestia-node/share/ipld"
3735 "github.com/celestiaorg/celestia-node/share/shwap"
3836 "github.com/celestiaorg/celestia-node/share/shwap/getters/mock"
39- "github.com/celestiaorg/celestia-node/state"
40- "github.com/celestiaorg/celestia-node/state/txclient"
4137)
4238
4339func TestBlobService_Get (t * testing.T ) {
@@ -904,7 +900,7 @@ func createServiceWithSub(ctx context.Context, t testing.TB, blobs []*Blob) (*Se
904900 nd , err := eds .NamespaceData (ctx , accessor , ns )
905901 return nd , err
906902 })
907- return NewService (nil , nil , shareGetter , fn , fn2 ), headers
903+ return NewService (nil , shareGetter , fn , fn2 ), headers
908904}
909905
910906func createService (ctx context.Context , t testing.TB , shares []libshare.Share ) * Service {
@@ -948,7 +944,7 @@ func createService(ctx context.Context, t testing.TB, shares []libshare.Share) *
948944 fn2 := func (ctx context.Context ) (<- chan * header.ExtendedHeader , error ) {
949945 return nil , fmt .Errorf ("not implemented" )
950946 }
951- return NewService (nil , nil , shareGetter , fn , fn2 )
947+ return NewService (nil , shareGetter , fn , fn2 )
952948}
953949
954950// TestProveCommitmentAllCombinations tests proving all the commitments in a block.
@@ -1157,127 +1153,6 @@ func buildEDS(t *testing.T, shares []libshare.Share) (*rsmt2d.ExtendedDataSquare
11571153 return eds , roots .Hash ()
11581154}
11591155
1160- // mockSubmitter implements the Submitter interface for testing.
1161- type mockSubmitter struct {
1162- height int64
1163- err error
1164- called bool
1165- }
1166-
1167- func (m * mockSubmitter ) SubmitPayForBlob (
1168- context.Context ,
1169- []* libshare.Blob ,
1170- * state.TxConfig ,
1171- ) (* types.TxResponse , error ) {
1172- m .called = true
1173- if m .err != nil {
1174- return nil , m .err
1175- }
1176- return & types.TxResponse {Height : m .height }, nil
1177- }
1178-
1179- // mockFibreSubmitter implements the FibreSubmitter interface for testing.
1180- type mockFibreSubmitter struct {
1181- height uint64
1182- err error
1183- calls int
1184- }
1185-
1186- func (m * mockFibreSubmitter ) Submit (context.Context , libshare.Namespace , []byte , * txclient.TxConfig ,
1187- ) (* appfibre.PutResult , * appfibre.PaymentPromise , error ) {
1188- m .calls ++
1189- if m .err != nil {
1190- return nil , nil , m .err
1191- }
1192- return & appfibre.PutResult {Height : m .height }, nil , nil
1193- }
1194-
1195- func newTestFibreBlob (t * testing.T ) * Blob {
1196- t .Helper ()
1197- ns := libshare .RandomBlobNamespace ()
1198- commitment := bytes .Repeat ([]byte {0xAA }, libshare .FibreCommitmentSize )
1199- signer := bytes .Repeat ([]byte {0xBB }, 20 )
1200- libBlob , err := libshare .NewV2Blob (ns , 0 , commitment , signer )
1201- require .NoError (t , err )
1202- blob , err := convertBlobs (libBlob )
1203- require .NoError (t , err )
1204- return blob [0 ]
1205- }
1206-
1207- func TestService_Submit_AllFibreBlobs (t * testing.T ) {
1208- fibreSub := & mockFibreSubmitter {height : 42 }
1209- blobSub := & mockSubmitter {height : 100 }
1210-
1211- svc := & Service {
1212- blobSubmitter : blobSub ,
1213- fibreSubmitter : fibreSub ,
1214- }
1215- svc .ctx , svc .cancel = context .WithCancel (context .Background ())
1216- defer svc .cancel ()
1217-
1218- blobs := []* Blob {newTestFibreBlob (t ), newTestFibreBlob (t )}
1219- height , err := svc .Submit (context .Background (), blobs , nil )
1220- require .NoError (t , err )
1221- assert .Equal (t , uint64 (42 ), height )
1222- assert .Equal (t , 2 , fibreSub .calls )
1223- assert .False (t , blobSub .called )
1224- }
1225-
1226- func TestService_Submit_AllRegularBlobs (t * testing.T ) {
1227- fibreSub := & mockFibreSubmitter {height : 42 }
1228- blobSub := & mockSubmitter {height : 100 }
1229-
1230- svc := & Service {
1231- blobSubmitter : blobSub ,
1232- fibreSubmitter : fibreSub ,
1233- }
1234- svc .ctx , svc .cancel = context .WithCancel (context .Background ())
1235- defer svc .cancel ()
1236-
1237- libBlobs , err := libshare .GenerateV0Blobs ([]int {10 , 10 }, false )
1238- require .NoError (t , err )
1239- blobs , err := convertBlobs (libBlobs ... )
1240- require .NoError (t , err )
1241-
1242- height , err := svc .Submit (context .Background (), blobs , nil )
1243- require .NoError (t , err )
1244- assert .Equal (t , uint64 (100 ), height )
1245- assert .True (t , blobSub .called )
1246- assert .Equal (t , 0 , fibreSub .calls )
1247- }
1248-
1249- func TestService_Submit_MixedBlobsError (t * testing.T ) {
1250- svc := & Service {
1251- blobSubmitter : & mockSubmitter {height : 100 },
1252- fibreSubmitter : & mockFibreSubmitter {height : 42 },
1253- }
1254- svc .ctx , svc .cancel = context .WithCancel (context .Background ())
1255- defer svc .cancel ()
1256-
1257- libBlobs , err := libshare .GenerateV0Blobs ([]int {10 }, false )
1258- require .NoError (t , err )
1259- regularBlobs , err := convertBlobs (libBlobs ... )
1260- require .NoError (t , err )
1261-
1262- mixed := []* Blob {regularBlobs [0 ], newTestFibreBlob (t )}
1263- _ , err = svc .Submit (context .Background (), mixed , nil )
1264- require .ErrorIs (t , err , ErrMixedBlobTypes )
1265- }
1266-
1267- func TestService_Submit_FibreWithoutSubmitter (t * testing.T ) {
1268- svc := & Service {
1269- blobSubmitter : & mockSubmitter {height : 100 },
1270- fibreSubmitter : nil ,
1271- }
1272- svc .ctx , svc .cancel = context .WithCancel (context .Background ())
1273- defer svc .cancel ()
1274-
1275- blobs := []* Blob {newTestFibreBlob (t )}
1276- _ , err := svc .Submit (context .Background (), blobs , nil )
1277- require .Error (t , err )
1278- assert .Contains (t , err .Error (), "fibre submitter is not available" )
1279- }
1280-
12811156func rawBlobSize (totalSize int ) int {
12821157 return totalSize - delimLen (uint64 (totalSize ))
12831158}
0 commit comments