Skip to content

Commit

Permalink
fix: don't do exponential funding
Browse files Browse the repository at this point in the history
  • Loading branch information
0x416e746f6e committed Mar 12, 2024
1 parent f914b18 commit 881ea6a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
7 changes: 2 additions & 5 deletions backend/config/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ type Faucet struct {
Payout int64 `yaml:"payout"`
}

var (
bigInt = big.NewInt(0)
eth = bigInt.Exp(big.NewInt(10), big.NewInt(18), nil)
)

func (f Faucet) PayoutWei() *big.Int {
bigInt := big.NewInt(0)
eth := bigInt.Exp(big.NewInt(10), big.NewInt(18), nil)
return bigInt.Mul(big.NewInt(f.Payout), eth)
}
18 changes: 18 additions & 0 deletions backend/config/faucet_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package config_test

import (
"testing"

"github.com/flashbots/eth-faucet/config"
"github.com/stretchr/testify/assert"
)

func TestPayoutWei(t *testing.T) {
f := config.Faucet{
Payout: 10,
}
val1, _ := f.PayoutWei().Float64()
assert.Equal(t, 1e+19, val1)
val2, _ := f.PayoutWei().Float64()
assert.Equal(t, 1e+19, val2)
}
4 changes: 4 additions & 0 deletions backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/golang-jwt/jwt/v5 v5.2.0
github.com/google/uuid v1.3.0
github.com/redis/go-redis/v9 v9.5.1
github.com/stretchr/testify v1.8.4
github.com/urfave/cli/v2 v2.27.1
go.uber.org/zap v1.27.0
)
Expand All @@ -21,6 +22,7 @@ require (
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
Expand All @@ -30,6 +32,7 @@ require (
github.com/gorilla/websocket v1.4.2 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/supranational/blst v0.3.11 // indirect
Expand All @@ -43,5 +46,6 @@ require (
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/tools v0.15.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
3 changes: 3 additions & 0 deletions backend/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8=
golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk=
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
Expand Down

0 comments on commit 881ea6a

Please sign in to comment.