-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DA): expose configuration options for retry loop backoff (#757)
Co-authored-by: github-actions <[email protected]> Co-authored-by: zale144 <[email protected]> Co-authored-by: Michael Tsitrin <[email protected]>
- Loading branch information
1 parent
fe78b6d
commit 0cd09f3
Showing
9 changed files
with
136 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package celestia | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
uretry "github.com/dymensionxyz/dymint/utils/retry" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCreateConfig(t *testing.T) { | ||
mustMarshal := func(v any) []byte { | ||
bz, _ := json.Marshal(v) | ||
return bz | ||
} | ||
t.Run("simple", func(t *testing.T) { | ||
c := Config{ | ||
BaseURL: TestConfig.BaseURL, | ||
AppNodeURL: TestConfig.AppNodeURL, | ||
Timeout: TestConfig.Timeout, | ||
GasPrices: 42, | ||
Backoff: uretry.NewBackoffConfig(uretry.WithGrowthFactor(1.65)), | ||
RetryAttempts: 10, | ||
RetryDelay: 10 * time.Second, | ||
} | ||
bz := mustMarshal(c) | ||
gotC, err := createConfig(bz) | ||
require.NoError(t, err) | ||
assert.Equal(t, c.Backoff, gotC.Backoff) | ||
assert.Equal(t, c.RetryAttempts, gotC.RetryAttempts) | ||
assert.Equal(t, c.RetryDelay, gotC.RetryDelay) | ||
}) | ||
t.Run("no backoff", func(t *testing.T) { | ||
c := Config{ | ||
BaseURL: TestConfig.BaseURL, | ||
AppNodeURL: TestConfig.AppNodeURL, | ||
Timeout: TestConfig.Timeout, | ||
GasPrices: 42, | ||
} | ||
bz := mustMarshal(c) | ||
gotC, err := createConfig(bz) | ||
require.NoError(t, err) | ||
assert.Equal(t, defaultSubmitBackoff, gotC.Backoff) | ||
}) | ||
t.Run("generate example", func(t *testing.T) { | ||
c := Config{ | ||
BaseURL: TestConfig.BaseURL, | ||
AppNodeURL: TestConfig.AppNodeURL, | ||
Timeout: TestConfig.Timeout, | ||
GasPrices: 0.1, | ||
AuthToken: "TOKEN", | ||
Backoff: defaultSubmitBackoff, | ||
RetryAttempts: 4, | ||
RetryDelay: 3 * time.Second, | ||
} | ||
bz := mustMarshal(c) | ||
t.Log(string(bz)) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters