Skip to content

Commit

Permalink
Merge pull request #12 from fjl/legacy-gasprice
Browse files Browse the repository at this point in the history
testgen: increase gas price of legacy test transaction
  • Loading branch information
lightclient authored Jan 3, 2023
2 parents 40ae392 + d10cefc commit 56ac109
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 29 deletions.
8 changes: 2 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"

Expand Down Expand Up @@ -41,10 +40,7 @@ type gethClient struct {
// The client's data directory is set to a temporary location and it
// initializes with the genesis and the provided blocks.
func newGethClient(ctx context.Context, path string, genesis *core.Genesis, blocks []*types.Block, verbose bool) (*gethClient, error) {
tmp, err := ioutil.TempDir("", "geth-")
if err != nil {
return nil, err
}
tmp := os.TempDir()
if err := writeGenesis(fmt.Sprintf("%s/genesis.json", tmp), genesis); err != nil {
return nil, err
}
Expand All @@ -62,7 +58,7 @@ func newGethClient(ctx context.Context, path string, genesis *core.Genesis, bloc
// Run geth init.
options := []string{datadir, loglevel, "init", fmt.Sprintf("%s/genesis.json", tmp)}
options = maybePrepend(isFakepow, options, "--fakepow")
err = runCmd(ctx, path, verbose, options...)
err := runCmd(ctx, path, verbose, options...)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/speccheck/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -63,7 +62,7 @@ func parseRoundTrips(root string, re *regexp.Regexp) ([]*roundTrip, error) {

// parseTest parses a single test into a slice of HTTP round trips.
func parseTest(testname string, filename string) ([]*roundTrip, error) {
data, err := ioutil.ReadFile(filename)
data, err := os.ReadFile(filename)
if err != nil {
return nil, err
}
Expand Down
9 changes: 4 additions & 5 deletions ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"

Expand Down Expand Up @@ -67,14 +66,14 @@ type loggingRoundTrip struct {

func (rt *loggingRoundTrip) RoundTrip(req *http.Request) (*http.Response, error) {
// Read and log the request body.
reqBytes, err := ioutil.ReadAll(req.Body)
reqBytes, err := io.ReadAll(req.Body)
req.Body.Close()
if err != nil {
return nil, err
}
fmt.Fprintf(rt.w, ">> %s\n", bytes.TrimSpace(reqBytes))
reqCopy := *req
reqCopy.Body = ioutil.NopCloser(bytes.NewReader(reqBytes))
reqCopy.Body = io.NopCloser(bytes.NewReader(reqBytes))

// Do the round trip.
resp, err := rt.inner.RoundTrip(&reqCopy)
Expand All @@ -84,12 +83,12 @@ func (rt *loggingRoundTrip) RoundTrip(req *http.Request) (*http.Response, error)
defer resp.Body.Close()

// Read and log the response bytes.
respBytes, err := ioutil.ReadAll(resp.Body)
respBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
respCopy := *resp
respCopy.Body = ioutil.NopCloser(bytes.NewReader(respBytes))
respCopy.Body = io.NopCloser(bytes.NewReader(respBytes))
fmt.Fprintf(rt.w, "<< %s\n", bytes.TrimSpace(respBytes))
return &respCopy, nil
}
5 changes: 2 additions & 3 deletions generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"os"
"time"
Expand Down Expand Up @@ -86,7 +85,7 @@ type chainData struct {
bc *core.BlockChain
gspec *core.Genesis
blocks []*types.Block
bad *types.Block
// bad *types.Block
}

// initChain either attempts to read the chain config from args.ChainDir or it
Expand All @@ -95,7 +94,7 @@ func initChain(ctx context.Context, args *Args) (*chainData, error) {
var chain chainData
if args.ChainDir != "" {
chain.gspec = &core.Genesis{}
if g, err := ioutil.ReadFile(fmt.Sprintf("%s/genesis.json", args.ChainDir)); err != nil {
if g, err := os.ReadFile(fmt.Sprintf("%s/genesis.json", args.ChainDir)); err != nil {
return nil, err
} else if err := json.Unmarshal(g, chain.gspec); err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ go 1.18

require (
github.com/alexflint/go-arg v1.4.3
github.com/ethereum/go-ethereum v1.10.19
github.com/ethereum/go-ethereum v1.10.26
github.com/open-rpc/meta-schema v0.0.0-20210416041958-626a15d0a618
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0
)

require (
Expand All @@ -27,16 +29,14 @@ require (
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/open-rpc/meta-schema v0.0.0-20210416041958-626a15d0a618 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/tsdb v0.7.1 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
)
Loading

0 comments on commit 56ac109

Please sign in to comment.