mirror of
https://github.com/status-im/status-go.git
synced 2025-02-26 13:45:34 +00:00
All envelopes might be delivered in multiple batches (#1483)
This commit is contained in:
parent
79ede28ab7
commit
d5a172a358
@ -132,17 +132,28 @@ func TestSubscriptionWhisperEnvelopes(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
var (
|
||||||
case event := <-signals:
|
total int
|
||||||
validateShhEvent(t, event, subID, numberOfEnvelopes, topic, payload)
|
after = time.After(2 * time.Second)
|
||||||
case <-time.After(2 * time.Second):
|
exit bool
|
||||||
require.Fail(t, "timeout waiting for subscription")
|
)
|
||||||
|
for !exit {
|
||||||
|
select {
|
||||||
|
case event := <-signals:
|
||||||
|
total += validateShhEvent(t, event, subID, topic, payload)
|
||||||
|
if total == numberOfEnvelopes {
|
||||||
|
exit = true
|
||||||
|
}
|
||||||
|
case <-after:
|
||||||
|
exit = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
require.Equal(t, numberOfEnvelopes, total, "total number of envelopes must be equal to sent number of envelopes")
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * utility methods below * * * * * * * * * * *
|
// * * * * * * * * * * utility methods below * * * * * * * * * * *
|
||||||
|
|
||||||
func validateShhEvent(t *testing.T, jsonEvent string, expectedSubID string, numberOfEnvelopes int, topic string, payload string) {
|
func validateShhEvent(t *testing.T, jsonEvent string, expectedSubID string, topic string, payload string) int {
|
||||||
result := struct {
|
result := struct {
|
||||||
Event signal.SubscriptionDataEvent `json:"event"`
|
Event signal.SubscriptionDataEvent `json:"event"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
@ -153,13 +164,12 @@ func validateShhEvent(t *testing.T, jsonEvent string, expectedSubID string, numb
|
|||||||
require.Equal(t, signal.EventSubscriptionsData, result.Type)
|
require.Equal(t, signal.EventSubscriptionsData, result.Type)
|
||||||
require.Equal(t, expectedSubID, result.Event.FilterID)
|
require.Equal(t, expectedSubID, result.Event.FilterID)
|
||||||
|
|
||||||
require.Equal(t, numberOfEnvelopes, len(result.Event.Data))
|
|
||||||
|
|
||||||
for _, item := range result.Event.Data {
|
for _, item := range result.Event.Data {
|
||||||
dict := item.(map[string]interface{})
|
dict := item.(map[string]interface{})
|
||||||
require.Equal(t, dict["topic"], topic)
|
require.Equal(t, dict["topic"], topic)
|
||||||
require.Equal(t, dict["payload"], payload)
|
require.Equal(t, dict["payload"], payload)
|
||||||
}
|
}
|
||||||
|
return len(result.Event.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateTxEvent(t *testing.T, expectedSubID string, jsonEvent string, txID string) {
|
func validateTxEvent(t *testing.T, expectedSubID string, jsonEvent string, txID string) {
|
||||||
@ -194,9 +204,9 @@ func createSubscription(t *testing.T, backend *StatusBackend, params string) str
|
|||||||
createSubFmt := `
|
createSubFmt := `
|
||||||
{
|
{
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"id": 10,
|
"id": 10,
|
||||||
"method": "eth_subscribeSignal",
|
"method": "eth_subscribeSignal",
|
||||||
"params": [%s]
|
"params": [%s]
|
||||||
|
|
||||||
}`
|
}`
|
||||||
|
|
||||||
@ -221,7 +231,7 @@ func initNodeAndLogin(t *testing.T, backend *StatusBackend) (string, string) {
|
|||||||
unlockFmt := `
|
unlockFmt := `
|
||||||
{
|
{
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"id": 11,
|
"id": 11,
|
||||||
"method": "personal_unlockAccount",
|
"method": "personal_unlockAccount",
|
||||||
"params": ["%s", "%s"]
|
"params": ["%s", "%s"]
|
||||||
}`
|
}`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user