Skip to content

Commit

Permalink
pm: return error from validateTicketParams() if ticket params is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
kyriediculous committed Mar 26, 2021
1 parent d8c8f50 commit af682a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pm/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ func (s *sender) ValidateTicketParams(ticketParams *TicketParams) error {

// validateTicketParams checks if ticket params are acceptable for a specific number of tickets
func (s *sender) validateTicketParams(ticketParams *TicketParams, numTickets int) error {
if ticketParams == nil {
return fmt.Errorf("ticketParams is nil")
}

if ticketParams.ExpirationBlock.Int64() == 0 {
return nil
}
Expand Down
5 changes: 5 additions & 0 deletions pm/sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@ func TestCreateTicketBatch_ConcurrentCallsForSameSession_SenderNonceIncrementsCo
assert.Equal(totalTickets, len(uniqueNonces))
}

func TestValidateTicketParams_NilTicketParams_ReturnsError(t *testing.T) {
sender := defaultSender(t)
assert.EqualError(t, sender.validateTicketParams(nil, 1), "ticketParams is nil")
}

func TestValidateParams_ValidateSender(t *testing.T) {
sender := defaultSender(t)
sm := sender.senderManager.(*stubSenderManager)
Expand Down

0 comments on commit af682a3

Please sign in to comment.