chore: faster TestCommunityOfflineEdit (#4800)

* chore: faster TestCommunityOfflineEdit
* chore: enable debug logs in TestSyncDeviceSuite
This commit is contained in:
Igor Sirotin 2024-02-27 19:38:40 +00:00 committed by GitHub
parent 9fa396e797
commit 168398d7a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 8 deletions

View File

@ -684,7 +684,8 @@ func (m *Messenger) shouldResendMessage(message *common.RawMessage, t common.Tim
return false, nil
}
//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)
return backoffElapsed, nil
}

View File

@ -3,6 +3,7 @@ package protocol
import (
"database/sql"
"encoding/json"
"time"
"github.com/status-im/status-go/account"
"github.com/status-im/status-go/rpc"
@ -114,13 +115,13 @@ type config struct {
telemetryServerURL string
wakuService *wakuv2.Waku
messageResendMinDelay int
messageResendMinDelay time.Duration
messageResendMaxCount int
}
func messengerDefaultConfig() config {
c := config{
messageResendMinDelay: 30,
messageResendMinDelay: 30 * time.Second,
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 {
c.messageResendMinDelay = minDelay
c.messageResendMaxCount = maxCount

View File

@ -18,6 +18,9 @@ import (
"github.com/status-im/status-go/protocol/tt"
)
const minimumResendDelay = 500 * time.Millisecond
const waitForResentDelay = minimumResendDelay + 100*time.Millisecond
type MessengerOfflineSuite struct {
suite.Suite
@ -91,7 +94,7 @@ func (s *MessengerOfflineSuite) newMessenger(waku types.Waku, logger *zap.Logger
testMessengerConfig: testMessengerConfig{
logger: s.logger,
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
wakuv2.SkipPublishToTopic(false)
time.Sleep(5 * time.Second)
time.Sleep(waitForResentDelay)
s.checkMessageDelivery(ctx, inputMessage)
@ -151,7 +154,7 @@ func (s *MessengerOfflineSuite) TestCommunityOfflineEdit() {
// Check that message is re-sent once back online
wakuv2.SkipPublishToTopic(false)
time.Sleep(5 * time.Second)
time.Sleep(waitForResentDelay)
inputMessage.Text = editedText
s.checkMessageDelivery(ctx, inputMessage)

View File

@ -662,7 +662,7 @@ func defaultNodeConfig(installationID, keyUID string) (*params.NodeConfig, error
// Set mainnet
nodeConfig := &params.NodeConfig{}
nodeConfig.NetworkID = 1
nodeConfig.LogLevel = "ERROR"
nodeConfig.LogLevel = "DEBUG"
nodeConfig.DataDir = filepath.Join("ethereum/mainnet_rpc")
nodeConfig.KeyStoreDir = filepath.Join(keystoreDir, keyUID)
nodeConfig.KeycardPairingDataFile = filepath.Join("keycard", "pairings.json")