Skip to content

Commit

Permalink
use mocked funcs in tests for blockHumber
Browse files Browse the repository at this point in the history
  • Loading branch information
semyon-dev committed Dec 27, 2024
1 parent 9171e88 commit 9559c23
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: download and install
uses: actions/setup-go@v5
with:
go-version: '1.23.1'
go-version: '1.23.4'

- name: install protoc (protobuf)
uses: arduino/setup-protoc@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: download and install
uses: actions/setup-go@v5
with:
go-version: '1.23.1'
go-version: '1.23.4'

- name: install protoc (protobuf)
uses: arduino/setup-protoc@v3
Expand Down
14 changes: 13 additions & 1 deletion escrow/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (validator *FreeCallPaymentValidator) Validate(payment *FreeCallPayment) (e
return NewPaymentError(Unauthenticated, "payment signer is not valid %v , %v", signerAddress.Hex(), validator.freeCallSigner.Hex())
}
if newSignature {
if err := authutils.CheckIfTokenHasExpired(payment.AuthTokenExpiryBlockNumber); err != nil {
if err := validator.CheckIfBlockExpired(payment.AuthTokenExpiryBlockNumber); err != nil {
return err
}
}
Expand Down Expand Up @@ -139,6 +139,18 @@ func (validator *FreeCallPaymentValidator) compareWithLatestBlockNumber(blockNum
return nil
}

func (validator *FreeCallPaymentValidator) CheckIfBlockExpired(expiredBlock *big.Int) error {
currentBlockNumber, err := validator.currentBlock()
if err != nil {
return err
}

if expiredBlock.Cmp(currentBlockNumber) < 0 {
return fmt.Errorf("authentication failed as the Free Call Token passed has expired")
}
return nil
}

// deprecated
func (validator *FreeCallPaymentValidator) getSignerAddressForFreeCall(payment *FreeCallPayment) (signer *common.Address, err error) {

Expand Down

0 comments on commit 9559c23

Please sign in to comment.