From 19a5e244927f521f0468ca212fc27221a2d0f53d Mon Sep 17 00:00:00 2001 From: dylanyang Date: Tue, 5 Mar 2024 22:11:42 +0800 Subject: [PATCH] add Test change name --- common/model/api_request.go | 12 +++--------- common/model/user_operation.go | 4 ++-- service/dashboard_service/dashboard_service.go | 11 ++++++++++- service/operator/get_support_entry_point_test.go | 1 + service/operator/get_support_strategy_text.go | 1 + service/operator/try_pay_user_op_test.go | 7 ++++++- 6 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 service/operator/get_support_entry_point_test.go create mode 100644 service/operator/get_support_strategy_text.go diff --git a/common/model/api_request.go b/common/model/api_request.go index b7d7966f..793721e5 100644 --- a/common/model/api_request.go +++ b/common/model/api_request.go @@ -8,21 +8,15 @@ type TryPayUserOpRequest struct { ForceTokens string `json:"force_tokens"` ForceEntryPointAddress string `json:"force_entry_point_address"` UserOperation UserOperationItem `json:"user_operation"` - Apikey string `json:"apikey"` Extra interface{} `json:"extra"` } -func (sender *TryPayUserOpRequest) Validate() error { - if len(sender.Apikey) == 0 { - return errors.New("apikey mustn't empty") - } - - if len(sender.ForceStrategyId) == 0 { - if len(sender.ForceNetWork) == 0 || len(sender.ForceTokens) == 0 || len(sender.ForceEntryPointAddress) == 0 { +func (request *TryPayUserOpRequest) Validate() error { + if len(request.ForceStrategyId) == 0 { + if len(request.ForceNetWork) == 0 || len(request.ForceTokens) == 0 || len(request.ForceEntryPointAddress) == 0 { return errors.New("strategy configuration illegal") } } - return nil } diff --git a/common/model/user_operation.go b/common/model/user_operation.go index c13b4fb1..d7e2c9c1 100644 --- a/common/model/user_operation.go +++ b/common/model/user_operation.go @@ -3,12 +3,12 @@ package model type UserOperationItem struct { Sender string `json:"sender" binding:"required"` Nonce string `json:"nonce" binding:"required"` - InitCode string `json:"init_code" binding:"required"` + InitCode string `json:"init_code"` CallGasLimit string `json:"call_gas_limit" binding:"required"` VerificationGasList string `json:"verification_gas_list" binding:"required"` PerVerificationGas string `json:"per_verification_gas" binding:"required"` MaxFeePerGas string `json:"max_fee_per_gas" binding:"required"` MaxPriorityFeePerGas string `json:"max_priority_fee_per_gas" binding:"required"` - Signature string `json:"signature" binding:"required"` + Signature string `json:"signature"` //paymasterAndData string `json:"paymaster_and_data"` } diff --git a/service/dashboard_service/dashboard_service.go b/service/dashboard_service/dashboard_service.go index a0a2e6e2..e3368b87 100644 --- a/service/dashboard_service/dashboard_service.go +++ b/service/dashboard_service/dashboard_service.go @@ -2,6 +2,15 @@ package dashboard_service import "AAStarCommunity/EthPaymaster_BackService/common/model" +var mockStrategyMap = map[string]model.Strategy{} + +func init() { + mockStrategyMap["1"] = model.Strategy{ + Id: "1", + EntryPointAddress: "0x123", + PayMasterAddress: "0x123", + } +} func GetStrategyById(strategyId string) model.Strategy { - return model.Strategy{} + return mockStrategyMap[strategyId] } diff --git a/service/operator/get_support_entry_point_test.go b/service/operator/get_support_entry_point_test.go new file mode 100644 index 00000000..18b97f2b --- /dev/null +++ b/service/operator/get_support_entry_point_test.go @@ -0,0 +1 @@ +package operator diff --git a/service/operator/get_support_strategy_text.go b/service/operator/get_support_strategy_text.go new file mode 100644 index 00000000..18b97f2b --- /dev/null +++ b/service/operator/get_support_strategy_text.go @@ -0,0 +1 @@ +package operator diff --git a/service/operator/try_pay_user_op_test.go b/service/operator/try_pay_user_op_test.go index e6d03af2..47cbe0b6 100644 --- a/service/operator/try_pay_user_op_test.go +++ b/service/operator/try_pay_user_op_test.go @@ -2,13 +2,18 @@ package operator import ( "AAStarCommunity/EthPaymaster_BackService/common/model" + "fmt" "testing" ) func TestTryPayUserOpExecute(t *testing.T) { request := getMockTryPayUserOpRequest() - TryPayUserOpExecute(request) + result, err := TryPayUserOpExecute(request) + if err != nil { + t.Errorf("Error: %v", err) + } + fmt.Printf("Result: %v", result) }