Smoke test on API and signals
This commit is contained in:
parent
65be6f2b96
commit
8b56cb7bfa
|
@ -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
|
||||
}
|
|
@ -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"`
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package signal
|
||||
|
||||
const (
|
||||
localPairingEvent = "localPairing"
|
||||
)
|
||||
|
||||
// SendLocalPairingEvent sends event from services/pairing/events.
|
||||
func SendLocalPairingEvent(event interface{}) {
|
||||
send(localPairingEvent, event)
|
||||
}
|
Loading…
Reference in New Issue