chore: faster TestCommunityOfflineEdit (#4800)
* chore: faster TestCommunityOfflineEdit * chore: enable debug logs in TestSyncDeviceSuite
This commit is contained in:
parent
9fa396e797
commit
168398d7a5
|
@ -684,7 +684,8 @@ func (m *Messenger) shouldResendMessage(message *common.RawMessage, t common.Tim
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
//exponential backoff depends on how many attempts to send message already made
|
//exponential backoff depends on how many attempts to send message already made
|
||||||
backoff := uint64(math.Pow(2, float64(message.SendCount-1))) * uint64(m.config.messageResendMinDelay) * uint64(time.Second.Milliseconds())
|
power := math.Pow(2, float64(message.SendCount-1))
|
||||||
|
backoff := uint64(power) * uint64(m.config.messageResendMinDelay.Milliseconds())
|
||||||
backoffElapsed := t.GetCurrentTime() > (message.LastSent + backoff)
|
backoffElapsed := t.GetCurrentTime() > (message.LastSent + backoff)
|
||||||
return backoffElapsed, nil
|
return backoffElapsed, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package protocol
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/status-im/status-go/account"
|
"github.com/status-im/status-go/account"
|
||||||
"github.com/status-im/status-go/rpc"
|
"github.com/status-im/status-go/rpc"
|
||||||
|
@ -114,13 +115,13 @@ type config struct {
|
||||||
telemetryServerURL string
|
telemetryServerURL string
|
||||||
wakuService *wakuv2.Waku
|
wakuService *wakuv2.Waku
|
||||||
|
|
||||||
messageResendMinDelay int
|
messageResendMinDelay time.Duration
|
||||||
messageResendMaxCount int
|
messageResendMaxCount int
|
||||||
}
|
}
|
||||||
|
|
||||||
func messengerDefaultConfig() config {
|
func messengerDefaultConfig() config {
|
||||||
c := config{
|
c := config{
|
||||||
messageResendMinDelay: 30,
|
messageResendMinDelay: 30 * time.Second,
|
||||||
messageResendMaxCount: 3,
|
messageResendMaxCount: 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +154,7 @@ func WithVerifyTransactionClient(client EthClient) Option {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithResendParams(minDelay int, maxCount int) Option {
|
func WithResendParams(minDelay time.Duration, maxCount int) Option {
|
||||||
return func(c *config) error {
|
return func(c *config) error {
|
||||||
c.messageResendMinDelay = minDelay
|
c.messageResendMinDelay = minDelay
|
||||||
c.messageResendMaxCount = maxCount
|
c.messageResendMaxCount = maxCount
|
||||||
|
|
|
@ -18,6 +18,9 @@ import (
|
||||||
"github.com/status-im/status-go/protocol/tt"
|
"github.com/status-im/status-go/protocol/tt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const minimumResendDelay = 500 * time.Millisecond
|
||||||
|
const waitForResentDelay = minimumResendDelay + 100*time.Millisecond
|
||||||
|
|
||||||
type MessengerOfflineSuite struct {
|
type MessengerOfflineSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
|
|
||||||
|
@ -91,7 +94,7 @@ func (s *MessengerOfflineSuite) newMessenger(waku types.Waku, logger *zap.Logger
|
||||||
testMessengerConfig: testMessengerConfig{
|
testMessengerConfig: testMessengerConfig{
|
||||||
logger: s.logger,
|
logger: s.logger,
|
||||||
extraOptions: []Option{
|
extraOptions: []Option{
|
||||||
WithResendParams(3, 3),
|
WithResendParams(minimumResendDelay, 1),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -134,7 +137,7 @@ func (s *MessengerOfflineSuite) TestCommunityOfflineEdit() {
|
||||||
|
|
||||||
// Check that message is re-sent once back online
|
// Check that message is re-sent once back online
|
||||||
wakuv2.SkipPublishToTopic(false)
|
wakuv2.SkipPublishToTopic(false)
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(waitForResentDelay)
|
||||||
|
|
||||||
s.checkMessageDelivery(ctx, inputMessage)
|
s.checkMessageDelivery(ctx, inputMessage)
|
||||||
|
|
||||||
|
@ -151,7 +154,7 @@ func (s *MessengerOfflineSuite) TestCommunityOfflineEdit() {
|
||||||
|
|
||||||
// Check that message is re-sent once back online
|
// Check that message is re-sent once back online
|
||||||
wakuv2.SkipPublishToTopic(false)
|
wakuv2.SkipPublishToTopic(false)
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(waitForResentDelay)
|
||||||
inputMessage.Text = editedText
|
inputMessage.Text = editedText
|
||||||
|
|
||||||
s.checkMessageDelivery(ctx, inputMessage)
|
s.checkMessageDelivery(ctx, inputMessage)
|
||||||
|
|
|
@ -662,7 +662,7 @@ func defaultNodeConfig(installationID, keyUID string) (*params.NodeConfig, error
|
||||||
// Set mainnet
|
// Set mainnet
|
||||||
nodeConfig := ¶ms.NodeConfig{}
|
nodeConfig := ¶ms.NodeConfig{}
|
||||||
nodeConfig.NetworkID = 1
|
nodeConfig.NetworkID = 1
|
||||||
nodeConfig.LogLevel = "ERROR"
|
nodeConfig.LogLevel = "DEBUG"
|
||||||
nodeConfig.DataDir = filepath.Join("ethereum/mainnet_rpc")
|
nodeConfig.DataDir = filepath.Join("ethereum/mainnet_rpc")
|
||||||
nodeConfig.KeyStoreDir = filepath.Join(keystoreDir, keyUID)
|
nodeConfig.KeyStoreDir = filepath.Join(keystoreDir, keyUID)
|
||||||
nodeConfig.KeycardPairingDataFile = filepath.Join("keycard", "pairings.json")
|
nodeConfig.KeycardPairingDataFile = filepath.Join("keycard", "pairings.json")
|
||||||
|
|
Loading…
Reference in New Issue