@@ -52,7 +52,7 @@ func TestSelfDialRetrievalGoodError(t *testing.T) {
 	assert.Error(t, err)
 	var cmdOutBytes []byte
 	w := bytes.NewBuffer(cmdOutBytes)
-	env.GenesisMiner.DumpLastOutput(w)
+	env.GenesisMiner.DumpLastStdErr(w)
 	outputStr := string(w.Bytes())
 	expectedErrStr := "attempting to retrieve piece from self"
 	assert.Contains(t, outputStr, expectedErrStr)
package commands_test

import (
	"bytes"
	"context"
	"math/big"
	"testing"

	"github.com/ipfs/go-ipfs-files"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"

	"github.com/filecoin-project/go-filecoin/address"
	tf "github.com/filecoin-project/go-filecoin/testhelpers/testflags"
	"github.com/filecoin-project/go-filecoin/tools/fast"
	"github.com/filecoin-project/go-filecoin/tools/fast/fastesting"
	"github.com/filecoin-project/go-filecoin/tools/fast/series"
)

func TestSelfDialRetrievalGoodError(t *testing.T) {
	tf.IntegrationTest(t)

	ctx := context.Background()

	ctx, env := fastesting.NewTestEnvironment(ctx, t, fast.EnvironmentOpts{})
	// Teardown after test ends.
	defer func() {
		err := env.Teardown(ctx)
		require.NoError(t, err)
	}()

	// Update genesis miner's peerid
	var minerAddr address.Address
	err := env.GenesisMiner.ConfigGet(ctx, "mining.minerAddress", &minerAddr)
	require.NoError(t, err)
	details, err := env.GenesisMiner.ID(ctx)
	require.NoError(t, err)
	msgCid, err := env.GenesisMiner.MinerUpdatePeerid(ctx, minerAddr, details.ID, fast.AOPrice(big.NewFloat(1.0)), fast.AOLimit(300))
	require.NoError(t, err)

	series.CtxMiningOnce(ctx)
	_, err = env.GenesisMiner.MessageWait(ctx, msgCid)
	require.NoError(t, err)

	// Add data to Genesis Miner.
	f := files.NewBytesFile([]byte("satyamevajayate"))
	cid, err := env.GenesisMiner.ClientImport(ctx, f)
	require.NoError(t, err)

	// Genesis Miner fails on self dial when retrieving from itself.
	_, err = env.GenesisMiner.RetrievalClientRetrievePiece(ctx, cid, minerAddr)
	assert.Error(t, err)
	var cmdOutBytes []byte
	w := bytes.NewBuffer(cmdOutBytes)
	env.GenesisMiner.DumpLastOutput(w)
	outputStr := string(w.Bytes())
	expectedErrStr := "attempting to retrieve piece from self"
	assert.Contains(t, outputStr, expectedErrStr)
}

I was thinking instead of using a dump like this we would either just return the Stderr reader directly or even just return the bytes / string. Not 100% which is better. I think what we want is a way to get _just_ the stderr without any extra bits. `DumpLastOutput` is more for debugging than it is for making assertions. We could also clean this up with the `AssertStdErrContains` (eg: `AssertStdErrContains(t, env.GenesisMiner, expectedErrStr)`) Some how we should try to provide context that it's for the last executed action / command, and not the stderr of the daemon itself.