Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
adg-flare committed Oct 3, 2024
1 parent 167e3b5 commit 005d052
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion client/protocol/protocol_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func TestSubmitter(t *testing.T) {
epoch: &utils.Epoch{Start: time.Unix(0, 0), Period: time.Hour},
subProtocols: []*SubProtocol{subProtocol},
submitRetries: 1,
submitTimeout: 1 * time.Second,
dataFetchRetries: 1,
dataFetchTimeout: 1 * time.Second,
name: "test",
Expand Down Expand Up @@ -170,7 +171,7 @@ type sentTxInfo struct {
}

func (c *testEthClient) SendRawTx(
privateKey *ecdsa.PrivateKey, to common.Address, payload []byte, _ *clientConfig.GasConfig,
privateKey *ecdsa.PrivateKey, to common.Address, payload []byte, _ *clientConfig.GasConfig, _ time.Duration,
) error {
c.sentTxs = append(c.sentTxs, &sentTxInfo{
privateKey: privateKey,
Expand Down
4 changes: 4 additions & 0 deletions client/protocol/submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ func (s *SignatureSubmitter) RunEpoch(currentEpoch int64) {
//
// Note: If GasPriceFixed is used, the retry multiplier will not be applied.
func gasConfigForAttempt(cfg *config.GasConfig, ri int) *config.GasConfig {
if cfg.GasPriceFixed.Cmp(common.Big0) != 0 {
return cfg
}

retryMultiplier := min(10.0, math.Pow(1.5, float64(ri)))

return &config.GasConfig{
Expand Down
14 changes: 13 additions & 1 deletion client/protocol/submitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ func TestGasConfigForAttempt(t *testing.T) {
GasPriceMultiplier: 1.5,
},
},
{
name: "retry 1 - no config",
cfg: config.GasConfig{
GasPriceFixed: big.NewInt(0),
GasPriceMultiplier: 0,
},
ri: 1,
expected: config.GasConfig{
GasPriceFixed: big.NewInt(0),
GasPriceMultiplier: 1.5,
},
},
{
name: "retry 2",
cfg: config.GasConfig{
Expand All @@ -57,7 +69,7 @@ func TestGasConfigForAttempt(t *testing.T) {
},
ri: 1,
expected: config.GasConfig{
GasPriceFixed: big.NewInt(150),
GasPriceFixed: big.NewInt(100),
GasPriceMultiplier: 0,
},
},
Expand Down

0 comments on commit 005d052

Please sign in to comment.