resolved error in the TestValidateRecipient
This commit is contained in:
parent
ff3f049226
commit
e979742424
@ -1498,10 +1498,10 @@ func TestValidateRecipient(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Test with invalid recepient",
|
name: "Test with invalid recepient",
|
||||||
input: []byte("9234adf5"),
|
input: []byte("7?1234"),
|
||||||
expectedResult: resource.Result{
|
expectedResult: resource.Result{
|
||||||
FlagSet: []uint32{flag_invalid_recipient},
|
FlagSet: []uint32{flag_invalid_recipient},
|
||||||
Content: "9234adf5",
|
Content: "7?1234",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1517,22 +1517,40 @@ func TestValidateRecipient(t *testing.T) {
|
|||||||
input: []byte("0711223344"),
|
input: []byte("0711223344"),
|
||||||
expectedResult: resource.Result{},
|
expectedResult: resource.Result{},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Test with address",
|
||||||
|
input: []byte("0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9"),
|
||||||
|
expectedResult: resource.Result{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Test with alias recepient",
|
||||||
|
input: []byte("alias123"),
|
||||||
|
expectedResult: resource.Result{},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// store a public key for the valid recipient
|
// store a public key for the valid recipient
|
||||||
err = store.WriteEntry(ctx, "0711223344", common.DATA_PUBLIC_KEY, []byte(publicKey))
|
err = store.WriteEntry(ctx, "+254711223344", common.DATA_PUBLIC_KEY, []byte(publicKey))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
mockAccountService := new(mocks.MockAccountService)
|
||||||
// Create the Handlers instance
|
// Create the Handlers instance
|
||||||
h := &Handlers{
|
h := &Handlers{
|
||||||
flagManager: fm.parser,
|
flagManager: fm.parser,
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
|
accountService: mockAccountService,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aliasResponse := &dataserviceapi.AliasAddress{
|
||||||
|
Address: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
||||||
|
}
|
||||||
|
|
||||||
|
mockAccountService.On("CheckAliasAddress", string(tt.input)).Return(aliasResponse, nil)
|
||||||
|
|
||||||
// Call the method
|
// Call the method
|
||||||
res, err := h.ValidateRecipient(ctx, "validate_recepient", tt.input)
|
res, err := h.ValidateRecipient(ctx, "validate_recepient", tt.input)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user