Expose methods required for the stream sync service #147
@ -7,7 +7,6 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"path"
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.defalsify.org/vise.git/asm"
|
"git.defalsify.org/vise.git/asm"
|
||||||
"git.defalsify.org/vise.git/db"
|
"git.defalsify.org/vise.git/db"
|
||||||
@ -1064,11 +1063,7 @@ func TestCheckAccountStatus(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
response: &models.TrackStatusResult {
|
response: &models.TrackStatusResult {
|
||||||
CreatedAt: time.Now(),
|
Active: true,
|
||||||
Status: "SUCCESS",
|
|
||||||
TransferValue: json.Number("0.5"),
|
|
||||||
TxHash: "0x123abc456def",
|
|
||||||
TxType: "transfer",
|
|
||||||
},
|
},
|
||||||
expectedResult: resource.Result{
|
expectedResult: resource.Result{
|
||||||
FlagSet: []uint32{flag_account_success},
|
FlagSet: []uint32{flag_account_success},
|
||||||
@ -1079,11 +1074,7 @@ func TestCheckAccountStatus(t *testing.T) {
|
|||||||
name: "Test when the account is not yet on the sarafu network",
|
name: "Test when the account is not yet on the sarafu network",
|
||||||
input: []byte("TrackingId1234"),
|
input: []byte("TrackingId1234"),
|
||||||
response: &models.TrackStatusResult{
|
response: &models.TrackStatusResult{
|
||||||
CreatedAt: time.Now(),
|
Active: false,
|
||||||
Status: "SUCCESS",
|
|
||||||
TransferValue: json.Number("0.5"),
|
|
||||||
TxHash: "0x123abc456def",
|
|
||||||
TxType: "transfer",
|
|
||||||
},
|
},
|
||||||
serverResponse: &api.OKResponse{
|
serverResponse: &api.OKResponse{
|
||||||
Ok: true,
|
Ok: true,
|
||||||
@ -1109,13 +1100,13 @@ func TestCheckAccountStatus(t *testing.T) {
|
|||||||
flagManager: fm.parser,
|
flagManager: fm.parser,
|
||||||
}
|
}
|
||||||
|
|
||||||
status := tt.response.Status
|
status := tt.response.Active
|
||||||
// Define expected interactions with the mock
|
// Define expected interactions with the mock
|
||||||
mockDataStore.On("ReadEntry", ctx, sessionId, common.DATA_PUBLIC_KEY).Return(tt.input, nil)
|
mockDataStore.On("ReadEntry", ctx, sessionId, common.DATA_PUBLIC_KEY).Return(tt.input, nil)
|
||||||
|
|
||||||
mockCreateAccountService.On("CheckAccountStatus", string(tt.input)).Return(tt.response, nil)
|
mockCreateAccountService.On("CheckAccountStatus", string(tt.input)).Return(tt.response, nil)
|
||||||
mockCreateAccountService.On("TrackAccountStatus", string(tt.input)).Return(tt.serverResponse, nil)
|
mockCreateAccountService.On("TrackAccountStatus", string(tt.input)).Return(tt.serverResponse, nil)
|
||||||
mockDataStore.On("WriteEntry", ctx, sessionId, common.DATA_ACCOUNT_STATUS, []byte(status)).Return(nil).Maybe()
|
mockDataStore.On("WriteEntry", ctx, sessionId, common.DATA_ACCOUNT_STATUS, status).Return(nil).Maybe()
|
||||||
|
|
||||||
// Call the method under test
|
// Call the method under test
|
||||||
res, _ := h.CheckAccountStatus(ctx, "check_account_status", tt.input)
|
res, _ := h.CheckAccountStatus(ctx, "check_account_status", tt.input)
|
||||||
|
@ -5,10 +5,14 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TrackStatusResult struct {
|
type Transaction struct {
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
TransferValue json.Number `json:"transferValue"`
|
TransferValue json.Number `json:"transferValue"`
|
||||||
TxHash string `json:"txHash"`
|
TxHash string `json:"txHash"`
|
||||||
TxType string `json:"txType"`
|
TxType string `json:"txType"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TrackStatusResult struct {
|
||||||
|
Active bool `json:"active"`
|
||||||
|
}
|
||||||
|
@ -3,7 +3,6 @@ package testservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.grassecon.net/urdt/ussd/internal/models"
|
"git.grassecon.net/urdt/ussd/internal/models"
|
||||||
"github.com/grassrootseconomics/eth-custodial/pkg/api"
|
"github.com/grassrootseconomics/eth-custodial/pkg/api"
|
||||||
@ -30,11 +29,7 @@ func (tas *TestAccountService) CheckBalance(ctx context.Context, publicKey strin
|
|||||||
|
|
||||||
func (tas *TestAccountService) CheckAccountStatus(ctx context.Context, trackingId string) (*models.TrackStatusResult, error) {
|
func (tas *TestAccountService) CheckAccountStatus(ctx context.Context, trackingId string) (*models.TrackStatusResult, error) {
|
||||||
return &models.TrackStatusResult {
|
return &models.TrackStatusResult {
|
||||||
CreatedAt: time.Now(),
|
Active: true,
|
||||||
Status: "SUCCESS",
|
|
||||||
TransferValue: json.Number("0.5"),
|
|
||||||
TxHash: "0x123abc456def",
|
|
||||||
TxType: "transfer",
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user