depositserver.go 472 B

1234567891011121314151617181920
  1. package mock
  2. import (
  3. "context"
  4. "google.golang.org/grpc/codes"
  5. "google.golang.org/grpc/status"
  6. )
  7. // DepositServer is used for mocking.
  8. type DepositServer struct{}
  9. // Deposit handles the deposit requests.
  10. func (*DepositServer) Deposit(ctx context.Context, req *DepositRequest) (*DepositResponse, error) {
  11. if req.GetAmount() < 0 {
  12. return nil, status.Errorf(codes.InvalidArgument, "cannot deposit %v", req.GetAmount())
  13. }
  14. return &DepositResponse{Ok: true}, nil
  15. }