Skip to content

Commit

Permalink
Merge branch 'main' into fix-authz-env
Browse files Browse the repository at this point in the history
  • Loading branch information
fmorency authored Jul 8, 2024
2 parents 7061d82 + e0c90b0 commit 888a3a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 1 addition & 2 deletions chain/cosmos/chain_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ func (tn *ChainNode) OverwriteGenesisFile(ctx context.Context, content []byte) e
}

func (tn *ChainNode) PrivValFileContent(ctx context.Context) ([]byte, error) {
fr := dockerutil.NewFileRetriever(tn.logger(), tn.DockerClient, tn.TestName)
gen, err := fr.SingleFileContent(ctx, tn.VolumeName, "config/priv_validator_key.json")
gen, err := tn.ReadFile(ctx, "config/priv_validator_key.json")
if err != nil {
return nil, fmt.Errorf("getting priv_validator_key.json content: %w", err)
}
Expand Down
19 changes: 14 additions & 5 deletions chain/internal/tendermint/tendermint_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,25 @@ func (tn *TendermintNode) HostName() string {
}

func (tn *TendermintNode) GenesisFileContent(ctx context.Context) ([]byte, error) {
fr := dockerutil.NewFileRetriever(tn.logger(), tn.DockerClient, tn.TestName)
gen, err := fr.SingleFileContent(ctx, tn.VolumeName, "config/genesis.json")
gen, err := tn.ReadFile(ctx, "config/genesis.json")
if err != nil {
return nil, fmt.Errorf("getting genesis.json content: %w", err)
}

return gen, nil
}

// ReadFile reads the contents of a single file at the specified path in the docker filesystem.
// relPath describes the location of the file in the docker volume relative to the home directory.
func (tn *TendermintNode) ReadFile(ctx context.Context, relPath string) ([]byte, error) {
fr := dockerutil.NewFileRetriever(tn.logger(), tn.DockerClient, tn.TestName)
gen, err := fr.SingleFileContent(ctx, tn.VolumeName, relPath)
if err != nil {
return nil, fmt.Errorf("failed to read file at %s: %w", relPath, err)
}
return gen, nil
}

func (tn *TendermintNode) OverwriteGenesisFile(ctx context.Context, content []byte) error {
fw := dockerutil.NewFileWriter(tn.logger(), tn.DockerClient, tn.TestName)
if err := fw.WriteFile(ctx, tn.VolumeName, "config/genesis.json", content); err != nil {
Expand Down Expand Up @@ -315,10 +325,9 @@ func (tn *TendermintNode) NodeID(ctx context.Context) (string, error) {
// This used to call p2p.LoadNodeKey against the file on the host,
// but because we are transitioning to operating on Docker volumes,
// we only have to tmjson.Unmarshal the raw content.
fr := dockerutil.NewFileRetriever(tn.logger(), tn.DockerClient, tn.TestName)
j, err := fr.SingleFileContent(ctx, tn.VolumeName, "config/node_key.json")
j, err := tn.ReadFile(ctx, "config/node_key.json")
if err != nil {
return "", fmt.Errorf("getting node_key.json content: %w", err)
return "", fmt.Errorf("getting genesis.json content: %w", err)
}

var nk p2p.NodeKey
Expand Down

0 comments on commit 888a3a2

Please sign in to comment.