Smoke test on API and signals

This commit is contained in:
Samuel Hawksby-Robinson 2022-01-27 09:52:13 +00:00
parent 65be6f2b96
commit 8b56cb7bfa
4 changed files with 96 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package local_pairing
import (
"time"
"github.com/status-im/status-go/signal"
)
func NewAPI() *API {
return &API{}
}
type API struct {}
func (a *API) StartSendingServer(password string) (string, error){
go func() {
time.Sleep(time.Second)
signal.SendLocalPairingEvent(Event{Type: EventConnectionSuccess})
time.Sleep(time.Second)
signal.SendLocalPairingEvent(Event{Type: EventTransferSuccess})
time.Sleep(time.Second)
signal.SendLocalPairingEvent(Event{Type: EventSuccess})
}()
return password, nil
}

View File

@ -0,0 +1,25 @@
package local_pairing
// EventType type for event types.
type EventType string
const (
EventConnectionError EventType = "connection-error"
EventConnectionSuccess EventType = "connection-success"
EventTransferError EventType = "transfer-error"
EventTransferSuccess EventType = "transfer-success"
EventDecryptionError EventType = "decryption-error"
EventInstallationError EventType = "installation-error"
EventSuccess EventType = "success"
)
// Event is a type for transfer events.
type Event struct {
Type EventType `json:"type"`
}

View File

@ -0,0 +1,32 @@
package local_pairing
import (
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rpc"
)
type Service struct {}
func (s *Service) Start() error {
return nil
}
func (s *Service) Stop() error {
return nil
}
func (s *Service) APIs() []rpc.API {
return []rpc.API{
{
Namespace: "localPairing",
Version: "0.1.0",
Service: NewAPI(),
Public: true,
},
}
}
func (s *Service) Protocols() []p2p.Protocol {
return nil
}

10
signal/events_pairing.go Normal file
View File

@ -0,0 +1,10 @@
package signal
const (
localPairingEvent = "localPairing"
)
// SendLocalPairingEvent sends event from services/pairing/events.
func SendLocalPairingEvent(event interface{}) {
send(localPairingEvent, event)
}