diff --git a/backend/config/faucet.go b/backend/config/faucet.go index 288d5af..f029336 100644 --- a/backend/config/faucet.go +++ b/backend/config/faucet.go @@ -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) } diff --git a/backend/config/faucet_test.go b/backend/config/faucet_test.go new file mode 100644 index 0000000..6298964 --- /dev/null +++ b/backend/config/faucet_test.go @@ -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) +} diff --git a/backend/go.mod b/backend/go.mod index 202b316..0be63c2 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -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 ) @@ -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 @@ -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 @@ -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 ) diff --git a/backend/go.sum b/backend/go.sum index 3a6e5de..f64be95 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -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=