Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add uint test for stone node and syncer module #39

Merged
merged 4 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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