Skip to content

Commit

Permalink
copy chain files to output directory
Browse files Browse the repository at this point in the history
  • Loading branch information
fjl committed Jan 17, 2024
1 parent 16ad6df commit 8a59637
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
"errors"
"fmt"
"os"
"path/filepath"
"time"

"github.com/cespare/cp"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/rpc"
"github.com/lightclient/rpctestgen/testgen"
Expand All @@ -22,6 +24,9 @@ func runGenerator(ctx context.Context) error {
if err != nil {
return err
}
if err := copyChainFiles(args.ChainDir, args.OutDir); err != nil {
return err
}

// Start Ethereum client.
client, err := spawnClient(ctx, args)
Expand Down Expand Up @@ -130,6 +135,24 @@ func mkdir(path string) error {
return nil
}

func copyChainFiles(chainDir, outDir string) error {
err := os.MkdirAll(outDir, 0755)
if err != nil {
return err
}
fmt.Println("copying genesis.json")
err = cp.CopyFile(filepath.Join(outDir, "genesis.json"), filepath.Join(chainDir, "genesis.json"))
if err != nil {
return err
}
fmt.Println("copying chain.rlp")
err = cp.CopyFile(filepath.Join(outDir, "chain.rlp"), filepath.Join(chainDir, "chain.rlp"))
if err != nil {
return err
}
return nil
}

// tryConnection checks if a client's JSON-RPC API is accepting requests.
func tryConnection(ctx context.Context, addr string, waitTime time.Duration) error {
c, err := rpc.DialOptions(ctx, addr)
Expand Down

0 comments on commit 8a59637

Please sign in to comment.