config: WriteConfigFile should return error (#7169)

This commit is contained in:
Sam Kleinman
2021-10-27 14:46:18 +02:00
committed by GitHub
parent e5d019d51b
commit 93eb940dcd
32 changed files with 318 additions and 154 deletions

View File

@@ -22,7 +22,8 @@ func TestHTTPSimple(t *testing.T) {
// Start a tendermint node (and kvstore) in the background to test against
app := kvstore.NewApplication()
conf := rpctest.CreateConfig("ExampleHTTP_simple")
conf, err := rpctest.CreateConfig("ExampleHTTP_simple")
require.NoError(t, err)
_, closer, err := rpctest.StartTendermint(ctx, conf, app, rpctest.SuppressStdout)
if err != nil {
@@ -71,7 +72,8 @@ func TestHTTPBatching(t *testing.T) {
// Start a tendermint node (and kvstore) in the background to test against
app := kvstore.NewApplication()
conf := rpctest.CreateConfig("ExampleHTTP_batching")
conf, err := rpctest.CreateConfig("ExampleHTTP_batching")
require.NoError(t, err)
_, closer, err := rpctest.StartTendermint(ctx, conf, app, rpctest.SuppressStdout)
if err != nil {

View File

@@ -20,7 +20,8 @@ func NodeSuite(t *testing.T) (service.Service, *config.Config) {
ctx, cancel := context.WithCancel(context.Background())
conf := rpctest.CreateConfig(t.Name())
conf, err := rpctest.CreateConfig(t.Name())
require.NoError(t, err)
// start a tendermint node in the background to test against
dir, err := ioutil.TempDir("/tmp", fmt.Sprint("rpc-client-test-", t.Name()))

View File

@@ -57,15 +57,18 @@ func makeAddrs() (p2pAddr, rpcAddr string) {
return fmt.Sprintf(addrTemplate, randPort()), fmt.Sprintf(addrTemplate, randPort())
}
func CreateConfig(testName string) *config.Config {
c := config.ResetTestRoot(testName)
func CreateConfig(testName string) (*config.Config, error) {
c, err := config.ResetTestRoot(testName)
if err != nil {
return nil, err
}
p2pAddr, rpcAddr := makeAddrs()
c.P2P.ListenAddress = p2pAddr
c.RPC.ListenAddress = rpcAddr
c.Consensus.WalPath = "rpc-test"
c.RPC.CORSAllowedOrigins = []string{"https://tendermint.com/"}
return c
return c, nil
}
type ServiceCloser func(context.Context) error