Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj committed Jun 10, 2024
1 parent 7ed9dfe commit 8083858
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
7 changes: 3 additions & 4 deletions integration/obscurogateway/tengateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestTenGateway(t *testing.T) {
DBType: "sqlite",
TenChainID: 443,
StoreIncomingTxs: true,
RateLimitThreshold: 800,
RateLimitThreshold: 1000,
RateLimitDecay: 100,
}

Expand Down Expand Up @@ -158,11 +158,10 @@ func testRateLimiter(t *testing.T, httpURL, wsURL string, w wallet.Wallet) {
Data: nil,
}

gasLimit, err := user0.HTTPClient.EstimateGas(context.Background(), msg)
fmt.Println(gasLimit, err)
user0.HTTPClient.EstimateGas(context.Background(), msg)
}

// second call should fail - rate limit exceeded
// after 1000 requests, the rate limiter should block the user
_, err = user0.HTTPClient.BalanceAt(context.Background(), user0.Wallets[0].Address(), nil)
require.Error(t, err)
require.Equal(t, "rate limit exceeded", err.Error())
Expand Down
3 changes: 2 additions & 1 deletion tools/walletextension/ratelimiter/rate_limiter.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package ratelimiter

import (
"github.com/ethereum/go-ethereum/common"
"sync"
"time"

"github.com/ethereum/go-ethereum/common"
)

type Score struct {
Expand Down
13 changes: 6 additions & 7 deletions tools/walletextension/rpcapi/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ const (
var rpcNotImplemented = fmt.Errorf("rpc endpoint not implemented")

type ExecCfg struct {
account *gethcommon.Address
computeFromCallback func(user *GWUser) *gethcommon.Address
tryAll bool
tryUntilAuthorised bool
adjustArgs func(acct *GWAccount) []any
cacheCfg *CacheCfg
calculateRateLimitScore func() uint32
account *gethcommon.Address
computeFromCallback func(user *GWUser) *gethcommon.Address
tryAll bool
tryUntilAuthorised bool
adjustArgs func(acct *GWAccount) []any
cacheCfg *CacheCfg
}

type CacheStrategy uint8
Expand Down

0 comments on commit 8083858

Please sign in to comment.