remove test account file
package account
import (
+ "os"
+ "path/filepath"
"testing"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
+ "github.com/iotexproject/iotex-address/address"
"github.com/iotexproject/iotex-core/ioctl/config"
"github.com/iotexproject/iotex-core/ioctl/util"
"github.com/iotexproject/iotex-core/test/mock/mock_ioctlclient"
@@ -24,14 +27,19 @@ func TestNewAccountDelete(t *testing.T) {
client.EXPECT().SelectTranslation(gomock.Any()).Return("mockTranslationString",
config.English).AnyTimes()
- client.EXPECT().GetAddress(gomock.Any()).Return("io1kuz56knh9g7x3ht36t2pgfd8fz5g6rxrh5a8dn", nil)
-
- ks := keystore.NewKeyStore(config.ReadConfig.Wallet,
+ testAccountFolder := filepath.Join(os.TempDir(), "testAccount")
+ require.NoError(t, os.Mkdir(testAccountFolder, os.ModePerm))
+ defer func() {
+ require.NoError(t, os.RemoveAll(testAccountFolder))
+ }()
+ ks := keystore.NewKeyStore(testAccountFolder,
keystore.StandardScryptN, keystore.StandardScryptP)
- ks.NewAccount("test")
+ acc, _ := ks.NewAccount("test")
+ accAddr, _ := address.FromBytes(acc.Address.Bytes())
+ client.EXPECT().GetAddress(gomock.Any()).Return(accAddr.String(), nil)
client.EXPECT().NewKeyStore(gomock.Any(), gomock.Any(), gomock.Any()).Return(ks)
+
cmd := NewAccountDelete(client)
- result, err := util.ExecuteCmd(cmd)
- require.NotNil(t, result)
- require.Error(t, err)
+ _, err := util.ExecuteCmd(cmd)
+ require.NoError(t, err)
}
