Skip to content

Commit

Permalink
add uint test for stone node and syncer module (#39)
Browse files Browse the repository at this point in the history
* add uint test for stone node and syncer module


Co-authored-by: DylanYong <dylan.y@nodereal.io>
Co-authored-by: joeycli <1297465889@qq.com>
  • Loading branch information
3 people authored Jan 10, 2023
1 parent b65e760 commit 450684a
Show file tree
Hide file tree
Showing 14 changed files with 959 additions and 60 deletions.
13 changes: 7 additions & 6 deletions model/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ var (

// stone node service errors
var (
ErrStoneNodeStarted = errors.New("stone node resource is running")
ErrStoneNodeStopped = errors.New("stone node service has stopped")
ErrIntegrityHash = errors.New("secondary integrity hash check error")
ErrRedundancyType = errors.New("unknown redundancy type")
ErrEmptyJob = errors.New("job is empty")
ErrSecondarySPNumber = errors.New("secondary sp is not enough")
ErrStoneNodeStarted = errors.New("stone node resource is running")
ErrStoneNodeStopped = errors.New("stone node service has stopped")
ErrIntegrityHash = errors.New("secondary integrity hash check error")
ErrRedundancyType = errors.New("unknown redundancy type")
ErrEmptyJob = errors.New("job is empty")
ErrSecondarySPNumber = errors.New("secondary sp is not enough")
ErrInvalidSegmentData = errors.New("invalid segment data, length is not equal to 1")
)

func MakeErrMsgResponse(err error) *service.ErrMessage {
Expand Down
2 changes: 1 addition & 1 deletion proto/service/types/v1/stone_hub.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ message PieceJob {
bytes tx_hash = 3;
uint64 object_id = 4;
uint64 payload_size = 5;
repeated uint32 target_idx = 6; // ec number: 1, 2, 3...
repeated uint32 target_idx = 6; // ec number: 1, 2, 3..., start at 1; segment number: 0, 1, 2..., start at 0
pkg.types.v1.RedundancyType redundancy_type = 7;
StorageProviderSealInfo storage_provider_seal_info = 8;
}
Expand Down
64 changes: 64 additions & 0 deletions service/client/mock/piece_store_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

171 changes: 171 additions & 0 deletions service/client/mock/stone_hub_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions service/client/mock/syncer_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions service/client/piece_store_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ import (
"github.com/bnb-chain/inscription-storage-provider/util/log"
)

// PieceStoreAPI provides an interface to enable mocking the
// StoreClient's API operation. This makes unit test to test your code easier.
//
//go:generate mockgen -source=./piece_store_client.go -destination=./mock/piece_store_mock.go -package=mock
type PieceStoreAPI interface {
GetPiece(ctx context.Context, key string, offset, limit int64) ([]byte, error)
PutPiece(key string, value []byte) error
}

type StoreClient struct {
ps *piece.PieceStore
}
Expand Down
Loading

0 comments on commit 450684a

Please sign in to comment.