From 7a575960cc44be8451af5a2a0b86c884ecc3c7c5 Mon Sep 17 00:00:00 2001 From: dylanyang Date: Tue, 5 Mar 2024 23:36:36 +0800 Subject: [PATCH] fix bug --- common/model/api_response.go | 2 +- service/operator/try_pay_user_op_execute.go | 4 ++-- service/operator/try_pay_user_op_test.go | 5 ++--- .../{userOpValidator.go => user_op_validator.go} | 0 .../chain/{IChainValidator.go => base_chain_validator.go} | 0 .../{EthereumValidator.go => ethereum_validator.go} | 6 +++--- 6 files changed, 8 insertions(+), 9 deletions(-) rename service/validator_service/{userOpValidator.go => user_op_validator.go} (100%) rename validator/chain/{IChainValidator.go => base_chain_validator.go} (100%) rename validator/chain/ethereum/{EthereumValidator.go => ethereum_validator.go} (64%) diff --git a/common/model/api_response.go b/common/model/api_response.go index 39c7bf36..176d3ada 100644 --- a/common/model/api_response.go +++ b/common/model/api_response.go @@ -6,7 +6,7 @@ type TryPayUserOpResponse struct { PayMasterAddress string `json:"pay_master_address"` PayMasterSignature string `json:"pay_master_signature"` PayReceipt interface{} `json:"pay_receipt"` - GasInfo *ComputeGasResponse `json:"gaf_info"` + GasInfo *ComputeGasResponse `json:"gas_info"` } type ComputeGasResponse struct { diff --git a/service/operator/try_pay_user_op_execute.go b/service/operator/try_pay_user_op_execute.go index 3491526a..496d1f12 100644 --- a/service/operator/try_pay_user_op_execute.go +++ b/service/operator/try_pay_user_op_execute.go @@ -74,7 +74,7 @@ func strategyGenerate(request *model.TryPayUserOpRequest) (*model.Strategy, erro if forceStrategyId := request.ForceStrategyId; forceStrategyId != "" { //force strategy strategy := dashboard_service.GetStrategyById(forceStrategyId) - if strategy == (model.Strategy{}) { + if &strategy == nil { return &model.Strategy{}, xerrors.Errorf("Not Support Strategy ID: [%w]", forceStrategyId) } return &strategy, nil @@ -84,7 +84,7 @@ func strategyGenerate(request *model.TryPayUserOpRequest) (*model.Strategy, erro if err != nil { return &model.Strategy{}, err } - if suitableStrategy == (model.Strategy{}) { + if &suitableStrategy == nil { return &model.Strategy{}, xerrors.Errorf("Empty Strategies") } return &suitableStrategy, nil diff --git a/service/operator/try_pay_user_op_test.go b/service/operator/try_pay_user_op_test.go index 54a0da98..cb6fe023 100644 --- a/service/operator/try_pay_user_op_test.go +++ b/service/operator/try_pay_user_op_test.go @@ -3,6 +3,7 @@ package operator import ( "AAStarCommunity/EthPaymaster_BackService/common/model" "fmt" + "github.com/stretchr/testify/assert" "testing" ) @@ -10,9 +11,7 @@ import ( func TestTryPayUserOpExecute(t *testing.T) { request := getMockTryPayUserOpRequest() result, err := TryPayUserOpExecute(&request) - if err != nil { - t.Errorf("Error: %v", err) - } + assert.NoError(t, err) fmt.Printf("Result: %v", result) } diff --git a/service/validator_service/userOpValidator.go b/service/validator_service/user_op_validator.go similarity index 100% rename from service/validator_service/userOpValidator.go rename to service/validator_service/user_op_validator.go diff --git a/validator/chain/IChainValidator.go b/validator/chain/base_chain_validator.go similarity index 100% rename from validator/chain/IChainValidator.go rename to validator/chain/base_chain_validator.go diff --git a/validator/chain/ethereum/EthereumValidator.go b/validator/chain/ethereum/ethereum_validator.go similarity index 64% rename from validator/chain/ethereum/EthereumValidator.go rename to validator/chain/ethereum/ethereum_validator.go index e84d4325..542bc86b 100644 --- a/validator/chain/ethereum/EthereumValidator.go +++ b/validator/chain/ethereum/ethereum_validator.go @@ -8,17 +8,17 @@ type EthValidator struct { *chain.Base } -func (e EthValidator) IsSupport() bool { +func (e *EthValidator) IsSupport() bool { //TODO implement me panic("implement me") } -func (e EthValidator) PreValidate() (err error) { +func (e *EthValidator) PreValidate() (err error) { //TODO implement me panic("implement me") } -func (e EthValidator) AfterGasValidate() (err error) { +func (e *EthValidator) AfterGasValidate() (err error) { //TODO implement me panic("implement me") }